Plate IIAgent SystemsHOWARDISM

Repository Exploration Subagent

FastContext's thesis that repository exploration (read/search/localization) should be decoupled from solving into a dedicated read-only subagent that issues parallel tool calls and returns compact file-line citations, keeping the solver's context clean — cutting main-agent tokens up to 60% and lifting SWE-bench resolution up to 5.5%

Article metadata
Publication details
Published:
Filed:Concept
Domain:Agent Systems
Reading:19 min
Source:AI-synthesised
About this piece

Articles in this journal are synthesised by AI agents from a curated wiki and are refreshed automatically as new concepts arrive. Topics, framing, and editorial direction are curated by Howardism.

Illustration for Repository Exploration Subagent

Sources#

Summary#

In most coding agents, one model both explores the repository (reading files, globbing paths, grepping for symbols to locate the relevant code) and solves the task (editing, running tests, producing a patch). Exploration is expensive and it pollutes: every exploratory read and search stays in the solver's conversation history, consuming token budget and burying the actual decision point under irrelevant snippets. FastContext (Shaoqiu Zhang et al., Microsoft CoreAI + Shanghai Jiao Tong University, June 2026) argues that repository exploration should instead be a first-class, separable, trainable component — a dedicated subagent invoked on demand that runs read-only parallel tool calls and returns only compact file-and-line citations as focused context. Integrated into Mini-SWE-Agent, this lifts end-to-end resolution up to 5.5% while cutting main-agent token consumption up to 60%, with marginal overhead. See the system instance at FastContext.

The bottleneck: exploration dominates the solver trajectory#

The motivating analysis runs all 300 GPT-5.4-high Mini-SWE-Agent trajectories on SWE-bench Multilingual and categorizes tool calls into reading, searching, editing, testing, and other:

  • Reading + searching = 9.96 of 17.72 tool-use turns (56.2%) and 46.5% of the main agent's total tokens. That token share is direct inference cost and context the solver must carry forward.
  • Exploration is a long sequential prelude before editing. Across the 284 trajectories where a first source edit is identifiable, the agent starts editing at turn 8.47 on average. Even with parallel tool calls enabled, the median trajectory still requires 6 sequential exploration turns and 15.5 exploration tool calls before the first edit.
  • Harder issues explore more. Unresolved trajectories average 8.34 pre-edit exploration turns vs. 6.67 for resolved ones. The claim is not that exploration causes failure but that it is (a) costly enough to matter and (b) structured enough to delegate.

Two distinct harms follow: a token/context-cost harm (the solver pays for and carries every exploratory snippet — see Context Window Smart Zone) and a noise harm (when exploration misses key files or accumulates irrelevant context, the solver reasons from a polluted window and may spend later turns repairing a mistaken hypothesis rather than fixing the true cause).

This is the same bottleneck that motivated SWE-Pruner (Wang et al., 2026, context pruning for coding agents) — and the contrast is instructive. Pruning removes the polluted context after the fact; the exploration-subagent approach never pollutes it by keeping search in a separate conversation. Two strategies, same problem.

Refined 2026-08-03 by Tool-Output Pruning: SWE-Pruner's successor prunes at the agent-environment boundary — the tool response is replaced between turns, so it survives exactly one generation and never accumulates. "After the fact" described the 2026 predecessor accurately and is too strong for the current state of the art; the two strategies now differ by one turn of exposure rather than by accumulation. That makes their composition a sharper question, not a settled one — see the open question below.

The delegation contract#

FastContext is a runtime delegation mechanism, not a new model architecture. The main agent hands it a natural-language query ("find the code paths for Goldmark image render hooks…") and receives back evidence, not a patch. Three deliberate design choices define the contract:

  1. Three language-agnostic read-only tools, and nothing else: READ (line-numbered file contents), GLOB (path discovery), GREP (regex search, ripgrep). The explorer cannot edit files or submit patches — it is structurally incapable of solving, only of locating.
  2. Parallel-by-turn. At each turn the explorer either issues one or more tool calls (executed concurrently, to cover complementary hypotheses before synthesizing) or stops with a final answer.
  3. A compact output contract. The return is a <final_answer> block of path:line-range entries with optional short relevance notes, e.g.:
<final_answer>
/src/router.py:42-58 (Router definition)
/tests/test_router.py:101-119
</final_answer>

Only this block re-enters the main agent's context. The explorer's intermediate tool observations and reasoning are written to separate subagent logs and never appended to the solver trajectory — this is the mechanism that keeps the main context clean. In Mini-SWE-Agent it runs as a CLI helper inside the same task container (fastcontext -q "..." --format concise).

This is the open, published mirror of the proprietary "subagent" features shipping in Claude Code, Codex, GitHub Copilot CLI, and Cursor — the paper's stated motivation is that those exploration mechanisms are closed, leaving no open training/evaluation recipe.

Training recipe: SFT then task-grounded RL#

The explorers are trained, not just prompted, in two stages (backbones: Qwen3-4B-Instruct for the 4B explorer, Qwen3-Coder-30BA3B for the 30B):

  • SFT (policy initialization). 2,954 filtered examples from Sonnet 4.6 (Anthropic) exploration traces, decomposed into three sub-sources that mirror the runtime behaviors: parallel_toolcalls (990 — broad nonredundant first-turn search), multiturn_traj (983 — full multi-turn evidence-gathering trajectories), and linerange (981 — precise final-citation generation). Assistant-token-only loss masks raw tool observations while keeping both assistant text and structured tool-call arguments in the objective.
  • RL (task-grounded refinement). GRPO from the SFT checkpoint over 400 prompts / 395 repositories. The key move: the reward is derived from the reference patch. Each issue's gold patch is parsed into target file/line ranges (avg 11.07 ranges/prompt), and the reward combines (a) file-level + line-level F1 of the explorer's citations against those targets, (b) a small bounded-parallelism bonus (1 if 3 < max-parallel-calls ≤ 6), and (c) a format penalty rejecting empty, overly long, malformed, or excessive-fan-out outputs. The explorer is rolled out as the real subagent (up to 8 turns, 16 sampled trajectories/prompt). SFT teaches imitation of exploration behavior; RL aligns the output with the code locations that actually matter for the fix.

Three findings worth keeping#

  1. The architectural separation is the durable win; the trained model is the optimization. A baseline called same-model exploration — the frontier model itself performs the delegated search through the subagent interface, with no specialized training — already improves score and cuts tokens versus monolithic solving. So a real share of the benefit comes purely from moving exploration out of the solver's context, independent of any small trained model. The trained explorer is then a Pareto improvement on top (often dominating same-model exploration in both score and tokens).
  2. A 4B-RL explorer can beat a 30B-SFT one. On GLM-5.1 / SWE-bench Pro, the 4B-RL explorer reaches 22.5 vs. 20.0 for 30B-SFT while using fewer tokens, and 4B-RL improves or ties 4B-SFT in all nine end-to-end settings. Task-grounded RL beats raw scale for this narrow role; the RL gains come mainly from higher recall at similar precision — exactly what a patch-coverage reward optimizes for. (Standalone localization: trained FastContext reaches 73.71 file-level F1 / 60.35 module-level F1, the strongest non-frontier group, with the clearest edge at module/function granularity.)
  3. The explorer is cheap. Token/cost audit on GPT-5.4 / SWE-bench Multilingual: direct solving is $282.47/task; main+4B-RL is $208.92 + $4.52 explorer = $213.44, a net saving of ~$69/task (the 4B explorer billed at a $0.20/Mtok serverless tier). Efficiency is the whole point — exploration has to be cheap enough to run as a routine helper, which is why the 4B model (not the 30B) is the deployment target.

Handing the solver code, priced under prefix caching (Yang et al., 2026-11)#

FastContext's audit prices an explorer that returns compact citations. Yang et al. (arXiv 2611.22238, Huawei, 2026-11-17, empirical) price the two neighbouring designs on SWE-bench Verified with open models. Costs are counted from each run's own cache hits, at a cached-input price of a tenth.

  • Pasted retrieval cuts exploration and raises cost. A retrieved evidence package (three candidate functions in full, seven more by location, and related code up to ~14K tokens) cuts read and search commands 18–34%. Same-length random code cuts nothing. Cost still rises ~33–42% at c = 0.1 for the main model, and +95% for Qwen3-Coder, because the package is re-read on every turn until it is replaced. Resolution shows no established gain: +0.0 points on 217 fresh tasks, preregistered as equivalent within ±5. Pointers are the cheap form. Replacing the package with an index of its locations at the first edit pays in 91–97% of runs, and the three candidate functions alone (~1.2K tokens) cost between −12% and +5% of no evidence while delivering a third to a half of the exploration cut. Approached from cost rather than quality, this lands where CAPC's graphify study does (see Connections): a small amount of actual code is the efficient form, and a large paste is not.
  • A cheap untrained scout does not pay for itself. A Qwen3.5-9B scout explored read-only for up to 15 commands and handed the Qwen3.6-27B solver 1–5 verified locations. The solver's exploration fell about as much as with the package (−5.98 commands) and its own cost fell 20%. Counting the scout at 9/27 of the solver's price, the total saving (−8%) was not significant. Counted at full price, the total rose 15%, and edit accuracy fell 0.10 below the package. This is an untrained scout without parallel calls, so it does not test FastContext's trained explorer. It does show that "the explorer is cheap" depends on the explorer's price ratio, which FastContext's audit sets at a $0.20/Mtok serverless tier.
  • Retrieval and the agent complement each other at localization. Appending the retrieval ranking to the agent's own one or two named locations raised function Acc@10 by 14–20 points for three models, at no token cost. The agent's own picks are mostly correct, and retrieval fills the slots it leaves empty.

Connections#

  • Context Edits Under Prefix Caching (the Price-Dependent Sign) — the add-context side priced under prefix caching. Pasted retrieval cuts exploration and raises cost, pointers are cheap, and a cheap scout's savings vanish once its own calls are priced at full rate
  • FastContext — the system instance: the trained 4B–30B explorers, model variants, training stack, and open release
  • Tool-Output Pruning — the other half of the same bottleneck, now measured. Where FastContext routes the search elsewhere, SWE-Pruner Pro compresses the observation at the boundary — and its headline finding is that the keep-or-prune signal is already in the coding agent's own hidden states (frozen-backbone linear probe: AUC 0.83, best-F1 0.63 against a 0.46 majority-class bound), so no separate scorer and no goal-hint query are needed. The corollary matters here: pruners that do pay for an external signal spend more tokens acquiring it than compression returns, and five of six prior methods inflate end-to-end tokens somewhere in the grid. Composition with an exploration subagent remains untested, and the risk is concrete rather than abstract — both target the same exploratory reads and searches, so an explorer already returning compact citations leaves a per-line pruner very little to remove
  • Context Lifecycle Management — the other half of main-agent token load: keep the noise out (delegate search to a read-only subagent) versus govern it once it's in (fold/mask/prune indexed objects with recoverable sidecars). Complementary, not competing — exploration isolation can't help a trace that already accumulated, and object GC can't un-pollute a solver's window prospectively
  • Deep Modules for Agents — an exploration subagent is a deep module: a thin interface (NL query → file-line citations) hiding large behavior (multi-turn parallel search), and a concrete realization of Pocock's "reviewer in fresh context" / Sandcastle pattern applied to search rather than review — the solver delegates and keeps a clean window
  • Agent Harness Engineering — decoupling exploration from solving and returning only compact evidence is harness design: progressive context disclosure and isolation enforced mechanically (the explorer cannot edit), not by instruction
  • Client-Side Agent Optimization — FastContext extends AgentOpt's model-per-role logic one step further: don't just assign an existing model to the explorer role, train a bespoke small model for it; the explorer-vs-solver split is exactly a per-role combo decision
  • Context Window Smart Zone — the noise harm is a smart-zone argument: exploratory snippets push the solver into the dumb zone; offloading search keeps the solver's reasoning window clean
  • The Bitter Lesson — a live tension: training a specialized explorer adds hand-built structure, seemingly against "dissolve the harness into the model." The same-model exploration result is the reconciliation — the durable gain is the architecture (context separation), while the trained explorer is an efficiency play the bitter lesson predicts will shrink as base models get cheaper
  • Harness Shrinkage as Models Improve — same tension from the harness side: is a trained exploration component load-bearing scaffolding or transient? The paper's own framing ("expose exploration as an explicit interface so smaller specialized models and stronger main agents collaborate") bets the interface persists even if the model inside it changes
  • Verification as the New Bottleneck — localization/exploration is the upstream sibling of verification: both are the non-solving work that dominates real agent trajectories; the patch-derived F1 reward is a verifiable signal for the explorer
  • Prompt-Cache Economics — the same last-mile problem with the compact return taken to its limit. CAPC's graphify study measures what a knowledge-graph indexer actually emits — node labels, source_file, line locations, community IDs, and no source code — and finds pointers alone are worse than no index at all on a codebase the model knows (0.613 vs 0.647 with no graph) while lifting a codebase it doesn't from 0.300 to 0.637. The fix is a per-query layer that dereferences the pointers and ships ~40 lines of verbatim source. Read against FastContext's file-line citations, the shared lesson is that a compact return has to carry some content, and the right amount is a function of the model's prior on the repo
  • Deep Research Agents — structurally parallel: deep-research decomposes a query into search + synthesis; FastContext decomposes a coding task into exploration + solving. Both isolate iterative search behind a compact synthesized return
  • Task Time-Horizon Scaling — the SWE-bench family (Multilingual, Pro, Verified, SWE-QA) is the evaluation surface here; longer-horizon tasks (SWE-bench Pro) show the largest accuracy gains, consistent with exploration cost compounding over horizon
  • Claude Code — the proprietary analog whose subagent mechanism FastContext open-sources
  • Symphony — another modular agent architecture (ticket-driven); both treat coding agents as composable components rather than monolithic loops
  • LLM-as-Compiler Knowledge Base — the compile-at-ingest counterpart: Cognition's DeepWiki pre-compiles 50K+ public repos into per-repo wikis that ground Devin's retrieval — the same decoupling of repo grounding from solving, done once per repo as a shared artifact instead of per task in a disposable explorer window
  • Deterministic Engineering for Agent Code Review — the distribute-rather-than-delegate answer to the same context-pollution problem. Where FastContext centralizes exploration into one read-only subagent returning compact citations, OpenCodeReview partitions it — one SubAgent per changed file, each with its own bounded read tools (file_read, code_search, file_read_diff) and its own window, cross-file dependencies pulled on demand rather than pre-gathered. The file-level grain is a deliberate choice against per-hunk or per-function partitioning, on the argument that finer splits fragment a coherent change — the coherence-versus-efficiency trade-off a single centralized explorer never has to make. Neither architecture has been benchmarked against the other
  • LLM-Driven Vulnerability Research — the same decoupling in a domain where the solver is an auditor, and the one place the "does the architecture or the search buy it" question has a same-model control. Antaeus (arXiv 2607.01138) reduces 186,859 in-scope C/C++ functions to 6,112 analyzed (30.6×) with keyword pruning plus a single agentic ranking pass over a signature-and-callees-only compression of the repository, then hands each survivor a fixed evidence bundle — depth-one callee bodies, macro and constant definitions, typedefs, imports — instead of letting the analyst search. Three results transfer. Prioritization recall was 100%: every ground-truth vulnerable function survived the 30.6× cut, which is the "does cheap selection drop the thing you needed" worry answered on one benchmark. The evidence bundle is not free and not interchangeable: withholding the local bundle costs 20→13 detections and withholding the repository-level bundle 20→11, so which evidence the explorer returns dominates here in a way FastContext's F1 numbers cannot see. And letting the model explore unaided loses to being handed the same candidates: an Opus 4.7 agent given Antaeus's own ranked function list finds 13 of 35 bugs against the pipeline's 20, at a lower FP count only because it curtails the search itself. Depth-one is a budget choice the authors defend explicitly — deeper call-graph expansion "dilutes the model's attention without guaranteeing complete interprocedural coverage" — which is the compact-return trade-off above, priced

Derived#

  • Single General Agent vs. Multi-Agent Coding Architecture — the "same-model exploration" result (architectural separation, not the trained model, is the durable win) is the load-bearing evidence that context-isolation specialization beats a monolithic-context agent independent of model scale

Open Questions#

  • Does the gain survive better main models? The same-model-exploration result suggests the architectural benefit is somewhat model-independent, but the trained-explorer margin may erode as frontier models get cheaper and better at staying in their smart zone unaided. The bitter-lesson question is unresolved. Settler: FastContext's explorer-vs-no-explorer comparison re-run with a current frontier main model, reporting the margin per model.
  • Prune vs. don't-pollute. SWE-Pruner removes context after the fact; FastContext avoids accumulating it. Are these complementary (prune the solver and delegate exploration) or substitutes? Not tested together. Sharpened (2026-08-03): Tool-Output Pruning moves pruning to the agent-environment boundary, so the two now differ by one turn of exposure rather than by accumulation, and both target the same exploratory reads — which makes overlap, not additivity, the default expectation. Still measured on no benchmark together.
  • How small can the explorer go? The authors flag 1.7B / 0.6B as future work — if the recipe holds, the explorer becomes nearly free and the architecture dominates. Settler: the authors' stated 1.7B / 0.6B runs, or an independent replication at those sizes. Annotated (2026-11-23): Yang et al. (empirical) price an untrained Qwen3.5-9B scout feeding a 27B solver under own-cache accounting. The solver saves 20%, but the total saving is not significant at a 9/27 price ratio and turns into a 15% increase at full price. So "nearly free" depends on the explorer's price ratio as well as its size, and a size result needs the explorer's calls priced in the same cache-aware units.
  • Generality beyond Mini-SWE-Agent. Only one (deliberately minimal) main-agent scaffold is tested; richer harnesses with their own memory/subagent orchestration may already capture part of the benefit or interact differently. Settler: FastContext run inside a richer harness with its own memory or subagent orchestration (e.g. OpenHands or Claude Code), compared against that harness unaided.
  • Patch-derived reward leakage. Training the explorer's reward on the gold patch's file/line ranges risks overfitting to where fixes landed rather than where evidence lives; the F1-vs-recall behavior partly mitigates this, but the proxy is imperfect. Settler: an ablation training the explorer on evidence-location labels instead of gold-patch ranges, scored on held-out repositories.

Sources#

§ end
Cited by 18
Related articles
  • Agent Harness Engineering

    Patterns for scaffolding long-running LLM agents: environment design, progressive context disclosure, mechanical archit…

  • Cost-per-Task Over Cost-per-Token

    Anthropic's inverted model-selection default: start with the most capable model and dial effort down — a stronger model…

  • Client-Side Agent Optimization

    AgentOpt's framing of developer-controlled agent optimization (model-per-role, budget, routing) as distinct from server…

  • Open Questions Backlog

    Generated by `_system/lint.py --write-backlog`. Do not hand-edit. Domain and Watching sections carry one row per page —…

  • Claude Code Best Practices

    Anthropic's guide to effective Claude Code usage: context management, verification-driven development, explore→plan→cod…