Back

Scout-Grep Mini:
Half the Model,
None of the Blindness

Matching 4B code search quality in 2.0-second multi-turn retrieval via on-policy distillation and TreeDeCA

Published Nov 17, 2026 · 15 min read

In agentic software engineering, generating code rarely dominates end-to-end latency anymore. Frontier models can plan refactors, synthesize patches, and iterate against test suites faster than humans can review them. What slows an agent down, increasingly, is everything that happens before the first line is edited: navigating large repositories to find the exact files and lines that matter.

Offloading retrieval from the main reasoning model to a specialized search subagent keeps noise out of the main context window, but it concentrates the wait time inside multi-turn search latency. A single code search is not one model call—it is a sequential loop of five or six calls where each grep and file read depends on the last. Every hundred milliseconds added to a forward pass multiplies across the entire loop, and every slice of per-turn overhead we shave off immediately speeds up interactive coding and high-volume agent rollouts.

Today we are sharing how we shrank Scout-Grep in half—from four billion to two billion parameters. Built on Qwen3.5-2B, Scout-Grep mini cuts model weights from 9 GB to 4.4 GB, reduces average multi-turn search latency by 37%, and drops median end-to-end deployment latency on a single B200 from 3.4 seconds to 2.0 seconds—running unquantized and without speculative decoding. On the 50 held-out tasks of ContextBench Verified, it matches our 4B Scout-Grep model point for point (0.411 F0.5F_{0.5} for both, up from 0.127 on the untuned base model).

Getting a half-size model there required solving a problem that affects anyone training small multi-turn tool agents: standard reinforcement learning raised recall by spamming cheap filename searches while destroying precision. To fix it without hand-patching rewards, we introduce TreeDeCA (Tree-aware Decision-token Credit Assignment), a parameter-free self-distillation objective that assigns credit first to the right turn via tree rollouts, and then to the exact high-entropy tokens where tool decisions are made.

Search quality (F0.5)0.10.20.30.40.50.60.00 s5 s10 s15 s20 s25 s30 sMean time per multi-turn searchQwen3.5-2B baseScout-Grep (4B)Scout-Grep 4B, experimentalScout-Grep mini (2B)Scout-Grep mini0.411search quality, equal tothe 4B Scout-Grep−37%time per search vs. 4B2Bparameters, 4.4 GBBase model: 0.12750 held-out ContextBench tasks × 4 samples · Bars: 95% bootstrap intervalUnquantized, no speculative decoding

Fig. 01Half the parameters, the same quality, 37% faster search

Only the underlying model changes inside a fixed Quick Search environment. Horizontal axis: mean wall-clock time per multi-turn search. Vertical axis: search quality (mean of file-level and line-level F0.5F_{0.5}) across 50 held-out tasks from ContextBench Verified (4 rollouts per task).

1.Why code search compounds latency

Scout-Grep exists because of a simple division of labor: a frontier model should spend its compute budget reasoning over code and writing patches, while a small, fast specialist locates the relevant context first. Because one search chains five or six sequential tool turns, per-turn inference speed dominates user-perceived latency and agent rollout throughput.

Cutting the parameter count in half shrinks the memory footprint from roughly 9 GB to 4.4 GB and immediately unlocks 37% faster multi-turn execution under identical serving conditions—dropping median production latency from 3.4 seconds to 2.0 seconds on a dedicated B200.

The catch is that the untuned base model can barely perform multi-turn repository navigation. While it can emit syntactically valid tool calls, across our 50 held-out evaluation tasks it locates just 18% of ground-truth files and 3% of ground-truth lines (0.127 F0.5F_{0.5}). Shrinking the model without losing search quality meant answering a fundamental training question: how do you transfer multi-step investigative judgment into a half-size policy when trajectory-level rewards are too coarse to guide it?

2.Inside our three-stage training recipe

No single training objective bridges the gap from 0.127 to 0.411. Imitation alone stalls on recall; reinforcement learning alone hacks the tool interface. Our recipe separates the problem into three stages—teaching search habits, enforcing outcome accountability, and sharpening per-token credit assignment:

StageMethodWhy it mattersTraining scale
1On-policy distillation + corrective SFTTeach the 4B teacher’s search habits on the student’s own states; eliminate tool syntax errors16 updates (92 tasks) + 1 corrective round
2Reinforcement learning (GSPO)Push the policy to optimize end-to-end search recall against real outcomes44 updates (699 tasks)
3TreeDeCA (proposed)Route outcome credit to specific turns and high-entropy decision tokens60 updates (461 tasks)

Every stage runs directly against real repositories checked out at exact commits—the model executes live grep and file-read calls, and raw tool outputs stream straight into context. Nothing is simulated or cached offline. We keep the exact reward function from our 4B Scout-Grep post, with strict zero-overlap separation between all training tasks and the 50 held-out evaluation tasks.

Search quality (F0.5)0.10.20.30.40.50.00.127Qwen3.5-2Bbase0.315+0.189On-policydistillationStage 10.294−0.022ReinforcementlearningStage 20.411+0.118TreeDeCAStage 3Scout-Grep 4B, experimental0.474Scout-Grep (4B)0.411Same evaluation environment · 50 held-out tasks × 4 samplesDeltas are task-paired differences

Fig. 02Three stages from 0.127 to 0.411 F0.5F_{0.5}

Search quality after each stage. On-policy distillation delivers the largest initial jump; standard RL expands recall at the expense of precision; TreeDeCA recovers precision and brings mini to parity with its 4B predecessor.

3.Stage 1: On-policy distillation builds habits

3.1Learning from the student’s own mistakes

The most obvious way to compress a 4B agent to half its size is supervised fine-tuning (SFT) on the teacher’s search logs. It completely fails. Teacher logs only show trajectories where navigation went smoothly. As soon as the smaller student searches independently, it wanders into states the teacher never visited—a weak regex, a noisy directory listing, an irrelevant file—where offline demonstrations offer zero recovery signal. When we tested SFT on 1,353 teacher turns, search quality did not budge and repetitive generation got worse.

On-policy distillation flips the loop. The student rolls out full multi-turn searches on its own. We pass those exact student-generated trajectories—mistakes included—to a frozen 4B teacher (alternating between two 4B teachers across tasks) and compute token-level distributions over every token the student produced. Rather than answering “How would a 4B model solve this from scratch?”, the teacher answers “Given the mess you just walked into, what should you do next?”

Because tool outputs are masked as observations and the student resamples fresh trajectories after every step, learning is remarkably sample-efficient: 16 updates across 92 tasks (~120K output tokens) are enough to transform the model’s behavior.

ModelSearch quality (F0.5)File precisionFile recallLine precisionLine recall
Base model (Qwen3.5-2B)0.1270.2280.1810.1530.033
After on-policy distillation0.3150.5500.4610.3850.081

Search quality jumps +18.9 points (paired 95% CI: +13.7 to +24.0), improving 41 out of 50 tasks. More importantly, the student absorbs the teacher’s investigative discipline: 71% of its grep calls inspect matching line contents directly, and 67% of the files it cites in its final answer are files it actually opened and read.

3.2Repairing tool syntax before RL

Even after distillation, the smaller model exhibits brittle tool formatting—most commonly duplicating parameter keys inside a single call. Each malformed call burns an entire turn and injects error tracebacks into context; left unaddressed, formatting failures drown out task rewards during subsequent RL.

Rather than mixing generic SFT data, we applied Harness Adaptation via Corrective SFT, correcting errors strictly inside the states the student naturally reaches:

  • Train only on the student’s own rollouts where format failures actually surface.
  • Truncate at the first malformed call so downstream error messages never contaminate supervision.
  • Supervise the full repaired tool call alongside valid calls to preserve structural fluency.

A single corrective round cut development-set format errors from 45 to 6. It also surfaced an insight that became central to Stage 3: inside a 150-token tool turn, almost everything is deterministic syntax—only a handful of decision tokens govern what the agent actually does.

3.3Where imitation hits a recall ceiling

At 0.315 F0.5F_{0.5}, the distilled student is precise when it answers, but it stops short—recovering just 8.1% of ground-truth lines. Matching a teacher’s local token distribution teaches plausible next steps, not exhaustive coverage. To care about missing files, the policy has to optimize against end-to-end search outcomes directly.

4.Stage 2: Outcome RL trades reading for recall

To push coverage up, we ran outcome-driven reinforcement learning (GSPO) across 699 tasks, sampling 8 rollouts per task. We kept the exact 4B reward structure: 55% on final-answer accuracy and completeness, 35% on encountering ground-truth evidence during search, and 10% on tool-budget efficiency.

On surface recall metrics, RL worked exactly as intended—file recall jumped +15 points and line recall +18 points. Yet overall search quality stalled completely:

StageSearch quality (F0.5)File precisionFile recallLine precisionLine recall
After distillation0.3150.5500.4610.3850.081
After RL (GSPO)0.2940.4180.6060.2690.257

Precision collapsed by roughly the same margin recall gained, leaving net quality flat (−0.022, 95% CI: −0.068 to +0.023). Inspecting all 200 evaluation trajectories revealed a striking behavioral regression:

Per-search behavior (mean)After distillationAfter RL (GSPO)
Total tool calls12.025.0
Share of grep calls inspecting line content71%5%
Duplicate calls identical to an earlier call0.88.4
Files cited in final answer2.55.2
Share of cited files actually read67%46%

RL bought recall by casting a wider net, not by reading code. Tool calls more than doubled, duplicate calls surged tenfold, and 92% of grep calls switched to filename-only mode (only 5% inspected matching lines, with the remaining 3% using match counts). Instead of opening files to verify logic, the student policy sprayed filename queries and padded its final citations with broad line ranges.

This is a fundamental lesson for small tool-using agents: the failure isn’t a broken reward function—it’s coarse credit assignment. Reading code and reasoning over context is cognitively expensive for a small model; spraying filename searches is cheap. When a single scalar score is broadcast uniformly across 25 tool calls, the optimizer reinforces whatever low-effort habit correlates with hitting more ground-truth lines. Rather than playing whack-a-mole with reward penalties, we built a learning signal that pinpoints which turn and which token caused the outcome.

5.Stage 3: Credit at decision tokens

5.1Two scales of credit blur

Multi-turn tool RL suffers from credit assignment blur at two distinct scales:

  1. Across turns: A trajectory spans five or six turns and a dozen tool calls before receiving a single terminal reward. Standard group-relative methods (GRPO, GSPO) broadcast identical advantage to every turn—rewarding wasted searches inside winning rollouts and penalizing smart reads inside losing ones.
  2. Within a turn: Even once you isolate a pivotal turn, 100–200 of its tokens are zero-uncertainty protocol scaffolding (<tool_call>, <function=grep>, parameter names, closing tags). Actual search strategy is decided at a tiny fraction of positions: the brief natural-language plan right before a tag (e.g., choosing “Let’s read…” vs. “Let’s search…”), the output_mode flag (content vs. files_with_matches), the query string, or the line range.

The filename-spamming pathology from Stage 2 lives entirely at this second level: out of hundreds of tokens in a turn, a single token after output_mode determines whether the model inspects code or flies blind.

5.2Isolating pivotal turns with rollout trees

TreeOPSD (Zou et al., 2026) solves the first level by organizing rollouts into a trajectory tree. For each task, we sample root trajectories and branch alternate rollouts directly from intermediate turns—replaying shared prefixes verbatim so diverging actions from the exact same state can be compared head-to-head.

Backing terminal rewards up from the leaves gives each turn ii an advantage estimate ViV_i, which maps to a bounded Bernoulli target qiq_i:

qi=12+Viτ,L=τ∑iwi KL(Ber(qi) ∥ Ber(σ(si)))q_i = \tfrac{1}{2} + \frac{V_i}{\tau}, \qquad \mathcal{L} = \tau \sum_i w_i \, \mathrm{KL}\big(\mathrm{Ber}(q_i) \,\|\, \mathrm{Ber}(\sigma(s_i))\big)

Because the gradient vanishes once the turn’s log-probability shift sis_i reaches σ(si)=qi\sigma(s_i) = q_i, repeated updates on the same batch remain stable without runaway drift. However, letting Δj=log⁡πθ(aj)−log⁡πold(aj)\Delta_j = \log \pi_\theta(a_j) - \log \pi_{\text{old}}(a_j) denote the log-probability change at token jj across a turn of length LiL_i, TreeOPSD aggregates tokens uniformly:

si=1Li∑j∈iΔj,wi=Li∑kLks_i = \frac{1}{L_i} \sum_{j \in i} \Delta_j, \qquad w_i = \frac{L_i}{\sum_k L_k}

Turn credit stops at the turn boundary—diluting gradient signal equally across XML tags and genuine search decisions.

5.3Weighting decision tokens by frozen entropy

Why do two branches from the exact same prefix end in radically different rewards? Because at a handful of uncertain positions, sampling forked onto different paths. In single-turn reasoning, Wang et al. (2025) showed that high predictive entropy cleanly identifies these “forking tokens”—and in our own 4B measurements, over half of all generated tokens had entropy below 0.01 nats.

TreeDeCA (Tree-aware Decision-token Credit Assignment) embeds this directly into tree self-distillation: the tree routes credit to the turn, and frozen sampling-time entropy routes credit to the decision tokens inside it. Letting HjH_j denote token jj’s predictive entropy recorded at rollout time (detached and frozen before optimization) and Hi=∑j∈iHjH_i = \sum_{j \in i} H_j denote total turn entropy, we replace uniform token counting with entropy weighting while keeping qiq_i and L\mathcal{L} untouched:

ComponentTreeOPSD (uniform)TreeDeCA (entropy-weighted)
Within-turn shift sis_i(1/Li)∑j∈iΔj(1 / L_i) \sum_{j \in i} \Delta_j(1/Hi)∑j∈iHjΔj(1 / H_i) \sum_{j \in i} H_j \Delta_j
Turn weight wiw_iLi/∑kLkL_i / \sum_k L_kHi/∑kHkH_i / \sum_k H_k

Taking the token-level gradient makes the mechanism transparent:

∂L∂log⁡πθ(aj)=τ(σ(si)−qi)⏟credit of the turn (from the tree)⋅{1∑kLkTreeOPSD: an equal share per tokenHj∑kHkTreeDeCA: a share proportional to entropy\frac{\partial \mathcal{L}}{\partial \log \pi_\theta(a_j)} = \underbrace{\tau\big(\sigma(s_i) - q_i\big)}_{\text{credit of the turn (from the tree)}} \cdot \begin{cases} \dfrac{1}{\sum_k L_k} & \text{TreeOPSD: an equal share per token} \\[10pt] \dfrac{H_j}{\sum_k H_k} & \text{TreeDeCA: a share proportional to entropy} \end{cases}

Boilerplate syntax tokens with Hj≈0H_j \approx 0 receive virtually zero gradient update; optimization concentrates automatically on the exact tokens where the policy hesitated between actions.

Practically, TreeDeCA adds one line of bookkeeping (recording frozen rollout entropies HjH_j) while preserving three clean properties:

  • Exact backward compatibility: Under uniform token entropy, TreeDeCA reduces identically to TreeOPSD.
  • Bounded updates: Per-turn gradients still vanish at σ(si)=qi\sigma(s_i) = q_i and reverse beyond it, preventing multi-epoch overshoot.
  • Zero new hyperparameters: Scaling all entropies by a constant cancels out in both sis_i and wiw_i. Unlike hard top-kk% token clipping—or teacher-entropy reweighting such as UECR-GRPO, which requires an external teacher forward pass—TreeDeCA uses continuous weights derived purely from the student’s own rollout uncertainty.
Turn-level credit (tree)T1T2T3T4T5T6reads the filefour more grepsresampled from T4R = 0.37V = +1.33R = 0.09V = −0.68R = 0.09V = −0.69Same prefix, different second turn.Rewards are backed up along the tree;each turn gets a credit V (filled: abovethe tree average, hollow: below).One of the four root families of a12-trajectory tree.Token-level credit (entropy)The 73 tokens of the “reads the file” turnThe▁`ViTImageProcessor·islikelyin`src/transformers/models/vit/image_processing_vit.py`.Letmereadthatfiletounderstandtheimplementation.\n\n<tool_call>\n<function=read_file>\n<parameter=relative_path>\nsrc/transformers/models/vit/image_processing_vit.py\n</parameter>\n</function>\n</tool_call><|im_end|>51 of 73 tokens have entropy below 0.01: protocol tags andthe already-named file path.TreeOPSDequal share: the same 10 tokens get 14%TreeDeCAentropy share: the 10 highest-entropy tokens get 77%likelyread=read/imageHeld-out ContextBench task · V: standardized reward backed up along the tree · Entropy of the next-token distributionMeasured, one tree; token entropies drawn approximately

Fig. 03One 73-token turn: 10 decision tokens receive 77% of the credit

A real rollout tree on a held-out task. Left: branching from the same first turn, spamming four more greps scores 0.09, whereas reading the target file scores 0.37. Right: across the 73 tokens of the file-read turn, 51 have entropy below 0.01. TreeOPSD gives the top 10 decision tokens just 14% of the turn’s update; TreeDeCA routes 77% of the credit directly to them.

Across 36 sampled trajectories (~23,000 generated tokens), 71% of tokens have entropy below 0.01, while the top 10% hold 68% of total entropy. That uncertainty lands squarely on genuine decisions: the opening token of a search pattern averages 1.48 nats, the output_mode value averages 0.34 nats (versus a median near zero), and another spike appears in the brief pre-tool sentence where the model commits to reading versus searching before emitting a single XML tag.

5.4Results: Doubling the gain in head-to-head runs

We ran a strict apples-to-apples comparison between our implementation of TreeOPSD and TreeDeCA—starting from the exact same post-RL checkpoint (0.294), on the same 461 tasks, with identical learning rates, tree topology (4 root trajectories per task, each spawning 2 branches for 12 trajectories total), 15 rounds / 60 updates, and identical compute (~2 hours 40 minutes on a single H200, with zero objective-specific tuning):

CheckpointSearch quality (95% CI)File precisionFile recallLine precisionLine recall
Post-RL starting point0.294 (0.240–0.346)0.4180.6060.2690.257
+ TreeOPSD (uniform tokens)0.351 (0.292–0.406)0.5520.5370.2800.219
+ TreeDeCA (entropy-weighted)0.411 (0.344–0.474)0.6230.5800.3850.248

TreeDeCA doubles the improvement over TreeOPSD (+11.8 points vs. +5.8 points; paired difference +6.0 points, 95% CI: +2.6 to +9.2, winning on 33 of 50 tasks vs. 13 losses). Just as telling is how each method raises precision: TreeOPSD sacrifices 7 points of file recall by simply reporting fewer files, whereas TreeDeCA boosts file precision by +21 points and line precision by +12 points without any statistically significant drop in recall.

5.5Restoring read-before-cite discipline

Behavioral telemetry across the 200 evaluation rollouts shows why token-level credit makes the difference:

Per-search behavior (mean over 200)Post-DistillPost-RLTreeOPSDTreeDeCA4B Scout-Grep
Tool calls12.025.011.714.610.4
File reads2.22.10.62.92.7
Searches reading zero files17%13%56%3%5%
grep calls inspecting content71%5%8%38%48%
Cited files actually read67%46%28%81%74%
DistilledRLTreeOPSDTreeDeCA4B Scout-GrepShare of grep calls that view content71%5%8%38%48%File reads per search2.22.10.62.92.7Share of cited files actually read67%46%28%81%74%50 held-out tasks × 4 samples · Mean over 200 searches per modelDistilled → RL → TreeOPSD / TreeDeCA are stages of the 2B model; 4B = Scout-Grep (teacher family)

Fig. 04TreeDeCA restores the 4B teacher’s investigative style

Trajectory-level RL wiped out content inspection and file reading. Uniform turn credit (TreeOPSD) merely made the agent quieter; decision-token credit (TreeDeCA) taught it to read code before answering.

Both tree methods prune away RL’s redundant tool spam, cutting call volume by 40–50%. Beyond that, their behaviors diverge sharply:

  • TreeOPSD does less of everything—including reading. Under uniform token credit, the easiest way to avoid bad outcomes is conservatism: in 56% of searches it never opens a file at all, and only 28% of its cited files were ever read.
  • TreeDeCA reads first, then answers. It opens files in 97% of searches, inspects matching line content in 38% of grep calls, and actually reads 81% of the files it cites—exceeding even the deployed 4B model. Concentrating gradient updates on decision tokens directly rewired the choices between “search again vs. read” and “filenames vs. content.”

6.4B search quality in two seconds

To benchmark models on a level playing field, we locked the Quick Search harness—same prompt, read-only tools, and turn budget across 50 held-out tasks (4 rollouts per task, failures scored as zero)—and ran all checkpoints unquantized without speculative decoding under high concurrent load:

ModelParametersSearch quality (95% CI)File precisionFile recallLine precisionLine recallMean time
Base model (Qwen3.5-2B)2 billion0.127 (0.088–0.171)0.2280.1810.1530.0338.0 s
Scout-Grep mini2 billion0.411 (0.344–0.474)0.6230.5800.3850.2489.6 s
Scout-Grep (deployed)4 billion0.411 (0.354–0.465)0.5550.6460.4210.27415.3 s
Scout-Grep (experimental, undeployed)4 billion0.474 (0.401–0.541)0.6450.6300.4580.38627.4 s

(Note: Absolute F0.5F_{0.5} scores differ from our earlier 4B blog post because all models here are evaluated on the updated Quick Search environment.)

  • Exact quality parity with deployed 4B: The paired F0.5F_{0.5} difference between Scout-Grep mini and 4B Scout-Grep is −0.001 (95% CI: ±0.040), with complementary precision-recall profiles (+6.8 points higher file precision on mini; +6.6 points higher file recall on 4B).
  • 37% faster under matched load: Without any serving-layer tricks, swapping the 4B model for mini drops mean search time from 15.3 s to 9.6 s.
  • 2.0-second median in production conditions, with a simpler serving stack: Replicating our previous post’s single-stream B200 deployment benchmark (co-located client, 50 held-out tasks run twice), Scout-Grep mini hits a 2.0-second median end-to-end search latency (p95 under 5 seconds):
Deployed configurationServing stackMedian end-to-end search
Scout-Grep (4 billion)Quantized + speculative-decoding draft model3.4 s
Scout-Grep mini (2 billion)Unquantized, no draft model2.0 s

Eliminating both quantization and draft-model orchestration makes production serving dramatically simpler while cutting median latency by over a second. (The current Quick Search harness also uses five calls per search rather than six, though total generated tokens per search remain roughly unchanged.)

Clear headroom remains at larger compute budgets. Pushing the 4B model further yielded an undeployed experimental checkpoint at 0.474 F0.5F_{0.5} (+6.2 points over mini, driven by +14 points in line recall)—but at 27.4 seconds per search, nearly 3× slower than mini, it crosses the latency ceiling for interactive retrieval. It stands instead as a concrete target for future distillation.

7.Where models stall and next steps

Cutting our search model in half taught us that distillation, outcome RL, and fine-grained credit assignment solve distinct failure modes—and exposed three clear boundaries we are tackling next:

  • Entropy consumption caps training horizon: Because TreeDeCA concentrates updates on uncertain decision tokens, mean output entropy drops from 0.43 to 0.29 over 60 updates (whereas TreeOPSD stays flat around 0.42). Scaling TreeDeCA to much longer runs will require explicit entropy regularization. Theoretically, weighting sis_i by entropy also trades away exact alignment with the initial on-tree policy-gradient direction in exchange for preserving bounded targets.
  • Single-seed pre-registered comparison: Due to rollout cost, TreeOPSD and TreeDeCA were each trained once with pre-committed final-checkpoint evaluation on our 50-task regression suite, where both the +6.0-point paired gain and behavioral shifts are large and statistically significant.
  • Learning when to stop early: Like our 4B models, Scout-Grep mini exhausts its allocated turn budget until prompted to summarize. Teaching the policy to terminate as soon as evidence is sufficient is an immediate lever to push sub-2-second searches even lower.

When code retrieval runs in two seconds on a two-billion-parameter model without losing accuracy, repository search stops competing with reasoning for GPU memory and latency—freeing frontier coding agents to spend their context and compute on the engineering problems that actually require them.

More research

All research
Scout-Grep Mini: Half the Model, None of the Blindness | Corepass Research - Corepass