{ }Context Bench/Qwen 3.8 27B
Experiment report · prompt v3 round

How context building affects generated code

The same coding tasks, the same model and eight ways of building its context, from no repository at all to an agent that explores with tools. 440 final-round runs: thinking on, a cold prefix cache before every run, one sample per configuration.

Qwen 3.8 27B FP8 on vLLM20 tasks on repos S and Mcompared with a thinking-off round of the same configurations
Thinking beats any context level48% → 73% PASS over the same 440 configurations. Answers with no usable code: 84 → 4.
The agent leads, the whole repo is closeL7 grep 25/27, L3 23/27, on 37% of L3's fresh input per run.
Seeing the helper drives reuseFull source in context: 122/124 reused. Not seen: 3/40.
About one answer in six is silently wrong17% with thinking, 16% without: wrong, yet the repo's own tests pass. Thinking doesn't change that.
Results

Pass rate by context level

Every bar is one configuration over its tasks (27 runs = the 20 tasks, 7 of them on both repos; L0 and L1-L2 run each task once, on its smallest repo). PASS: a valid answer and every hidden test passes. FAIL: a valid answer, a hidden test fails. Grey: no accepted answer, or the output limit was hit. Hatched (n/a): tasks the level doesn't run, so every bar is on the same scale.

L01/2 (25 n/a)
L16/20 (7 n/a)
L1 +hint7/20 (7 n/a)
L210/20 (7 n/a)
L323/27
L4 bm2521/27
L4 embed19/27
L5 bm25 task_vs_code18/27
L5 bm25 model_queries21/27
L5 embed task_vs_code22/27
L5 embed task_vs_code +hint19/27
L5 embed model_queries21/27
L619/27
L6+docs20/27
L7 grep25/27
L7 hybrid25/27
L7 rich21/27
L7 selective24/27
ConfigurationRunsPASSReuseRepo tests kept Judge rankInputOutputSeconds
L021–1/10.271.1k21.2k545
L12060/106/60.631.2k9.9k266
L1 +hint2072/86/70.631.3k8.5k225
L220104/1010/100.472.2k6.1k151
L3272312/1223/230.2641.7k4.9k148
L4 bm25272112/1321/210.252.4k5.6k120
L4 embed27199/1319/190.262.0k7.2k172
L5 bm25 task_vs_code27189/1318/180.382.5k7.7k191
L5 bm25 model_queries272110/1320/210.293.4k6.2k162
L5 embed task_vs_code272210/1221/220.262.2k7.1k160
L5 embed task_vs_code +hint271911/1319/190.282.2k7.0k160
L5 embed model_queries272110/1321/210.333.4k9.3k220
L6271913/1319/190.369.7k6.2k169
L6+docs272013/1320/200.3811.5k4.7k116
L7 grep272512/1225/250.2422.5k3.8k94
L7 hybrid272512/1225/250.2621.6k3.6k93
L7 rich272112/1221/210.3026.9k4.9k127
L7 selective272412/1223/240.2331.4k3.9k116

Reuse: reuse tasks where the hidden spy saw the needed helper called. Repo tests kept: passing runs whose patch also keeps the repository's own test suite green. Judge rank: mean share of the other candidate patches the blind judge ranked above this configuration's patches (0 = always best, lower is better). Input, output, seconds: medians per run.

Reuse

What the model saw of the helper decides whether it reuses it

Needed helper in context asReused, thinking onReused, thinking off
full source122/124 (98%)114/125 (91%)
a call site12/14 (86%)8/11 (73%)
signature only26/26 (100%)5/20 (25%)
not seen3/40 (8%)1/32 (3%)

With the full source in context the helper is almost always used. With thinking on, a bare signature (the L6 repository map) is enough too; with thinking off it mostly wasn't, the model asked to look first instead of answering. When the helper isn't in the context at all, the model writes its own version.

Hypotheses

What we expected and what happened

ExpectationVerdictEvidence (final round)
Reuse depends on whether the helper's code is visible.held Full source 122/124, signature 26/26, not seen 3/40.
An agent with tools matches the whole repo at a fraction of the input.held L7 grep 25/27 vs L3 23/27; median fresh input per run 15k vs 42k.
Model-written search queries beat changing the search engine.partly With BM25, model queries 21/27 vs task text 18/27; with embeddings the task text did as well (22/27).
A repository map of signatures is enough to write the change.with thinking L6 19/27 with thinking, 6/54 without (thinking off, the model asked to see code instead of answering).
Thinking matters most when the context is thin.held Largest gains at L6 (6 → 39) and L1 (6 → 13); smallest at L3 (21 → 23).
Richer agent tools and a self-managed working set help.not on repo M rich 21/27, selective 24/27 vs grep 25/27; M's files are small, so there's little to save (repo L tests this next).
Documentation drift (the trap) is caught only by levels that show and check the helper's body.held Reused and fixed only at L4 and L7; the signature-only levels (L6) trusted the docs.
Reasoning

Thinking on vs thinking off

The same 440 configurations with and without thinking. Thinking costs about 12× the output tokens (665 → 7,701 per run). What it buys is mostly answers that work at all: with thinking off a third of the runs produced no usable code or code that doesn't import. Those failures are exactly the ones a harness that runs tests would catch and could retry. The silently wrong answers, whose repo tests pass, are as common either way. Only tests that cover the behaviour catch those.

OutcomeThinking offThinking on
PASS212 (48%)322 (73%)
No usable answer (any harness notices)84 (19%)4 (1%)
Code doesn't import (any test run catches it)63 (14%)26 (6%)
Wrong; the repo's own tests fail (a test loop would flag it)9 (2%)12 (3%)
Wrong; the repo's own tests pass (silent)72 (16%)76 (17%)
LevelPASS, offPASS, onChange
L00/21/2+1
L16/4013/40+7
L27/2010/20+3
L321/2723/27+2
L430/5440/54+10
L575/135101/135+26
L66/5439/54+33
L767/10895/108+28

No level could run code, so nothing told the model it was wrong. With a test loop, thinking off would likely close part of the gap, at the cost of retries. Latency isn't compared here: the thinking-off round ran 4 requests at a time on a warm cache.

Performance

Latency

Final round only: one request at a time, cold prefix cache, FP8 (vLLM, TP=2, kv auto, MTP speculative decoding: 4 draft tokens).

Level<1 min1-3 min3-10 min>10 minMedian sMinutes per PASS
L0001154518.2
L151017825717.5
L256811517.5
L34131001483.1
L412172231644.6
L529426131694.8
L67242121404.3
L729532421102.6

Minutes per PASS: all time spent at that level divided by its passing runs. Thin-context levels think longest (L1 runs often think for 10k+ tokens); the agent is the fastest per pass.

Performance

Cost

LevelInput / runCached / runOutput / run Tokens per PASS$ per 100 PASS, open-weights host$ per 100 PASS, frontier API
L01.1k0.0k21.2k44.6k$3.44$64.26
L11.3k0.0k12.9k43.5k$3.25$60.60
L21.9k0.0k8.4k20.7k$1.43$26.44
L331.6k0.0k5.4k43.5k$1.25$20.69
L42.1k0.0k7.9k13.5k$0.91$16.80
L52.7k0.0k8.3k14.8k$0.96$17.80
L68.3k0.0k7.2k21.5k$1.03$18.40
L726.8k11.3k5.3k36.6k$1.10$18.27

Illustrative prices, not quotes: open-weights host: $0.20 input / $0.80 output per million tokens; frontier API: $3.00 input / $15.00 output per million tokens. Cached input is counted at the full price here; with prompt caching the agent's repeated prefixes (the "cached" column) would cost less.

Agents

Richer tools and a self-managed working set

L7 variantPASSReuseInputCached Tool callsSeconds
grep25/2712/1222.5k7.2k1394
hybrid25/2712/1221.6k7.2k1293
rich21/2712/1226.9k11.3k11127
selective24/2712/1231.4k14.3k11116

grep and hybrid: grep, file reads, references (hybrid adds semantic search). rich: the same tools, richer (search hits with source, line ranges, read a function by name). selective: rich plus drop, which removes earlier results from the conversation. On repo M the richer tools didn't help: the files are small, so reading whole files is cheap, and the model rarely used read_symbol (14 calls against 246 file reads). With thinking on, 18 of 27 selective runs dropped something, but the context saved was small: 4,734 tokens dropped and 8,670 input tokens avoided in total, about 1.0% of selective's input. Repo L (169k tokens, files and functions hundreds of lines long) is built to give these tools something to do.

Quality

Judged code quality

A blind judge (agy, rubric v2) compared all candidate patches of a task side by side, without knowing how any was made. Its correctness score agrees with the tests almost everywhere: 114 failing runs got a low score and none a high one; 307 passing runs got a high one. The 15 passing runs it scored low are where the hidden tests miss something.

Judge: correctness 4-5Judge: 1-3
Hidden tests pass30715
Hidden tests fail0114

Patch coverage: of 322 passing patches, 6 had less than 80% of their changed statements run by the hidden tests. 4 passing patches broke the repository's own tests (the regression check). No run, at any level, added tests of its own: the prompt never asks for tests (0 runs did).

Examples

How the model fails

Limits

How sure we are