Summary (Overview)

  • FastContext is a dedicated exploration subagent that separates repository exploration from the main agent's problem-solving, reducing token consumption and improving resolution rates in coding agents.
  • The system uses specialized exploration models (4B–30B parameters) trained via supervised fine-tuning (SFT) and reinforcement learning (RL) with task-grounded rewards.
  • Integrating FastContext into Mini-SWE-Agent improves end-to-end resolution rates up to 5.5% while reducing main-agent token consumption up to 60% across three benchmarks (SWE-bench Multilingual, SWE-bench Pro, SWE-QA).
  • FastContext exposes only three language-agnostic read-only tools (READ, GLOB, GREP) and returns compact file-and-line citations as focused context.
  • Standalone evaluation shows trained FastContext checkpoints reach 73.71 file-level F1 and 60.35 module-level F1, outperforming existing localization baselines.

Introduction and Theoretical Foundation

Background

Coding agents powered by Large Language Models (LLMs) have achieved strong results on software engineering tasks, but repository exploration remains a major bottleneck. The authors observe that:

  • Locating relevant code consumes substantial token budget and pollutes the agent's context with irrelevant snippets.
  • In most agents, the same model explores the repository and solves the task, leaving exploratory reads and searches in the solver's history.
  • Benchmarks like SWE-bench and SWE-QA require navigating large, multi-file codebases, making exploration a critical factor in both task success and inference efficiency.

Preliminary Analysis

The paper presents a detailed analysis of 300 GPT-5.4-high trajectories on SWE-bench Multilingual:

  • Reading and searching dominate the full trajectory, accounting for 56.2% of all tool-use turns and 46.5% of the main agent's total tokens.
  • The agent starts editing at turn 8.47 on average, with a median of 6 sequential exploration turns and 15.5 exploration tool calls before the first edit.
  • Unresolved trajectories are associated with more pre-edit exploration turns than resolved ones (8.34 vs. 6.67 turns on average).

This motivates the design of FastContext as a reusable exploration component that can be delegated to a subagent performing parallel search and returning compact evidence.


Methodology

3.1 FastContext Subagent Architecture

FastContext is a runtime delegation mechanism that separates repository exploration from solving:

  • The main agent delegates exploration to the explorer, which returns evidence rather than a patch.
  • The subagent exposes only three language-agnostic tools:
    • READ: reads line-numbered file contents
    • GLOB: discovers paths via pattern matching
    • GREP*: regex search over repository text
  • Multiple tool calls in the same turn are executed in parallel.
  • The output contract is a compact final answer block containing file paths and line ranges:
<final_answer>
/src/router.py:42-58 (Router definition)
/tests/test_router.py:101-119
</final_answer>

3.2 Policy Initialization with Supervised Fine-Tuning

The initial exploration policy is trained via SFT with 2,954 filtered examples from Sonnet 4.6 exploration traces, split into three sources:

  1. parallel_toolcalls (990 examples): targets broad first-turn search with nonredundant parallel tool calls.
  2. multiturn_traj (983 examples): targets multi-turn evidence gathering with full trajectories.
  3. linerange (981 examples): targets precise citation generation with narrow <final_answer> blocks.

The SFT objective is:

LSFT=1Dsft(x,y)Dsftt=1ymtlogpθ(ytx,y<t)\mathcal{L}_{\mathrm{SFT}} = - \frac{1}{|\mathcal{D}_{\mathrm{sft}}|} \sum_{(x, y) \in \mathcal{D}_{\mathrm{sft}}} \sum_{t = 1}^{|y|} m_{t} \log p_{\theta}(y_{t} \mid x, y_{<t})

where mtm_t masks out non-assistant tokens.

3.3 Policy Refinement with Reinforcement Learning

The explorer is refined with task-grounded RL using a 400-prompt set derived from issue-resolution tasks with reference patches. The reward function is:

R=F1(Pf,Gf)+F1(Pl,Gl)task outcome+rparallelparallel function callrformatpenaltyR = \underbrace{F_1(P_f, G_f) + F_1(P_l, G_l)}_{\text{task outcome}} + \underbrace{r_{\text{parallel}}}_{\text{parallel function call}} - \underbrace{r_{\text{format}}}_{\text{penalty}}

Where:

  • GfG_f and GlG_l: target file and line sets from the reference patch
  • PfP_f and PlP_l: predicted sets parsed from the model's final citations
  • rparallelr_{\text{parallel}}: small bonus for bounded multi-call exploration
  • rformatr_{\text{format}}: penalty for empty, overly long, malformed, or excessive-fan-out outputs

The format penalty is:

rformat=101[nC<1nC>20bC>0pmax>6]r_{\text{format}} = 10 \cdot \mathbf{1}[n_C < 1 \lor n_C > 20 \lor b_C > 0 \lor p_{\max} > 6]

and the bounded-parallelism bonus is:

rparallel=1[3<pmax6]r_{\text{parallel}} = \mathbf{1}[3 < p_{\max} \leq 6]

The models are optimized with GRPO (Group Relative Policy Optimization), initialized from the SFT checkpoint.


Empirical Validation / Results

4.2 End-to-End Results

Table 1: End-to-end performance and efficiency across three benchmarks

Main AgentSubagentSWE-bench Multilingual ScoreTokensSWE-bench Pro ScoreTokensSWE-QA ScoreTokens
GPT-5.4w/o Explore71.7457k46.0818k81.3418k
GPT-5.4GPT-5.473.3 ↑1.6379k ↓17.1%51.5 ↑5.5703k ↓14.1%81.4 ↑0.1166k ↓60.3%
GPT-5.4FC-30B-SFT75.0 ↑3.3356k ↓22.1%49.0 ↑3.0688k ↓15.9%82.0 ↑0.7206k ↓50.7%
GPT-5.4FC-4B-SFT73.3 ↑1.6364k ↓20.4%47.0 ↑1.0689k ↓15.8%81.9 ↑0.6213k ↓49.0%
GPT-5.4FC-4B-RL74.7 ↑3.0338k ↓26.0%48.5 ↑2.5701k ↓14.3%82.0 ↑0.7210k ↓49.8%
GLM-5.1w/o Explore72.32514k17.52692k72.7401k
GLM-5.1GLM-5.173.3 ↑1.01994k ↓20.7%18.0 ↑0.52356k ↓12.5%73.4 ↑0.7249k ↓37.9%
GLM-5.1FC-30B-SFT73.7 ↑1.41797k ↓28.5%20.0 ↑2.52370k ↓12.0%73.3 ↑0.6292k ↓27.2%
GLM-5.1FC-4B-RL73.7 ↑1.41971k ↓21.6%22.5 ↑5.02210k ↓17.9%73.5 ↑0.8302k ↓24.7%
Kimi-K2.6w/o Explore76.31553k31.02383k71.6510k
Kimi-K2.6FC-4B-RL78.3 ↑2.01384k ↓10.9%33.5 ↑2.52158k ↓9.4%72.6 ↑1.0378k ↓25.9%

Key findings:

  • FastContext improves end-to-end accuracy for every main agent and benchmark.
  • Largest gains on SWE-bench Pro: GPT-5.4 improves from 46.0 to 51.5, GLM-5.1 from 17.5 to 22.5.
  • Largest token savings on SWE-QA: 60.3% for GPT-5.4.
  • 4B-RL can outperform the larger 30B-SFT explorer in several settings.

4.4 Standalone Exploration Quality

Table 2: Standalone exploration quality on SWE-bench Verified

ScaffoldLLMFile-level F1Module-level F1Function-level F1
OpenHands-BashCODESCOUT-14B68.5750.8840.32
FastContextFC-30B-SFT73.7160.3540.74
FastContextFC-4B-SFT70.5555.2637.48
FastContextFC-4B-RL71.4856.2638.45

Trained FastContext checkpoints reach 73.71 file-level F1 and 60.35 module-level F1, compared with 68.57 and 50.88 for the best non-FastContext rows.

Cost Audit

Table 3: Token and cost audit for GPT-5.4 SWE-bench Multilingual run

ComponentTokensAPI cost
Direct main457k / task$282.47
Main + 4B-RL338k / task$208.92
4B-RL explorer22.58M total$4.52
Augmented total-$213.44
Net saving-$69.03

The explorer accounts for only 2.1% of the augmented total cost.


Theoretical and Practical Implications

Theoretical Contributions

  1. Modular view of coding agents: The paper demonstrates that repository exploration can be treated as a first-class, trainable component rather than an implicit cost inside monolithic solver trajectories.

  2. Separation of concerns: By decoupling exploration from solving, FastContext shows that specialized small models can effectively handle navigation tasks, enabling collaboration between smaller specialized models and stronger main agents.

  3. Task-grounded RL effectiveness: The results show that a 4B-parameter model trained with RL can outperform a 30B-SFT model, suggesting that task-grounded optimization is more important than raw model scale for exploration tasks.

Practical Implications

  1. Token efficiency: FastContext reduces frontier-model token consumption by up to 60%, directly translating to inference cost savings.

  2. Deployment feasibility: The 4B explorer is designed for local serving, eliminating per-token API costs while maintaining performance.

  3. Cleaner context: The main agent receives focused file-line evidence rather than noisy exploratory context, improving both resolution rates and reasoning quality.


Conclusion

Main Takeaways

  • Repository exploration should be separated from solving and handled by specialized models.
  • FastContext's SFT + RL training recipe effectively bootstraps compact exploration models from reference trajectories.
  • The architecture enables parallel tool use and returns compact file-and-line citations that are directly consumable by the main agent.

Future Directions

  1. Broader integration: Adapting FastContext to other coding-agent frameworks with different tool interfaces and orchestration mechanisms.
  2. Smaller main models: Exploring FastContext paired with 30B-class coding agents.
  3. Smaller explorers: Investigating whether the same recipe supports 1.7B or 0.6B parameter models.
  4. Benchmark decontamination: Addressing potential overlap between public benchmarks and frontier-model training data.

Limitations

  • Evaluation is currently limited to Mini-SWE-Agent as the main-agent scaffold.
  • Experiments focus on strong frontier models (GPT-5.4, GLM-5.1, Kimi-K2.6).
  • The smallest explorer trained has 4B parameters; smaller variants remain to be explored.

The paper concludes that repository navigation can be optimized and evaluated separately from patch generation or answer synthesis, encouraging future systems to expose exploration as an explicit interface with clearer context boundaries.

Related papers