{ }Context Bench/Qwen 3.8 27B
Method

How the experiment works

One model, one set of tasks, one prompt template. Only the <context> block changes from level to level.

The question

When a model writes code in an existing project, how much does the way its context is built matter? The harness gives the same model the same change requests and varies one thing: what it gets to see of the repository. It measures whether the change is correct, whether it reuses the project's existing helpers instead of re-implementing them, whether it breaks anything else, and what it costs.

How coding assistants got their context

In about six years the question "what does the model see of the code?" was answered four different ways: the open file, retrieved snippets, the whole repository, and agents that look for themselves. Each level in this experiment reproduces one of these moments (sources in the table below).

  1. 2020 MayRetrieval-augmented generation: a model answers with retrieved documents in its prompt (Lewis et al.). L4, L5
  2. 2021 JunGitHub Copilot technical preview: completions from the file being edited. L1
  3. 2021 JulCodex and HumanEval: writing a function from its docstring alone. L0
  4. 2022 NovChatGPT: developers paste the files they think matter into a chat. L2
  5. 2022 DecHyDE: a drafted answer becomes the search query. L5
  6. 2023 MarRepoCoder: function-level retrieval from the repository, refined with drafts. L5
  7. 2023 MayCopilot's neighboring tabs: other open files join the prompt. L2
  8. 2023 OctAider's repository map: every definition in one compact list. L6
  9. 2024 FebGemini 1.5: a million-token window; whole repositories fit in one prompt. L3
  10. 2024 MaySWE-agent: an agent explores and edits a repository through tools. L7
  11. 2024 OctAnthropic's text editor tool: edits as exact-text replacement. L8
  12. 2025 FebClaude Code: a terminal agent that searches the code itself. L7
  13. 2025 SepContext editing: old tool results are cleared from an agent's context. L7 selective
  14. 2026 Nov"You don't need long context": agents keep accuracy with short, frequently compacted contexts, at a fraction of the cost (Belcak et al.). L7 selective, L8
  15. 2026 NovThis experiment: the same model and tasks under every strategy above. all

editor chat retrieval long context agents

The levels

L0 to L6 build the context once and the model answers in one reply. L7 and L8 are agents: they start from a small context and use tools to look around before answering. Prompt v4 (the current round) never names the file to change: L1 to L6 still show it as their first context block, while the agents find it themselves.

LevelWhat the model sees
L0The task text only (tier-1 control tasks only): what the model does with no repository at all.
L1The target file.
L2The target file, its direct imports and its test file: what a developer would paste by hand.
L3Every source file in the repository, sorted, with paths. On repo L it doesn't fit the window: NO FIT.
L4The target file and the top 3 files by retrieval (BM25 or embeddings).
L5The target file and the top 8 functions by retrieval, with path, imports, signature, docstring and body. The query is the task text, or up to 5 queries the model writes in a planning call.
L6The target file and a one-line signature of every function and class (L6+docs: plus the first docstring line).
L7The repository's file tree (line counts, how many modules import each file) and tools, at most 15 calls. grep: grep, read_file, find_references. hybrid: plus semantic_search. rich: richer versions of those tools plus read_symbol (definitions by name) and line ranges for read_file. selective: rich plus drop, which removes results the model no longer needs from the conversation.
L8Experimental. A list of every file with the names defined in it (no signatures), read_symbol as the only way to read code (by name or line range; a file asked for whole returns its outline), search tools, drop, and edit / create_file tools that change the repository copy directly. The budget is 15 points, with the points left shown after each turn.

When a change creates a file that doesn't exist yet, every level sees its path (L1 to L6 as an empty target block, L7 and L8 as the same two lines), because a new module's name can't be found in the repository. An ablation arm, reuse_hint, adds one line to the system prompt on L1 and L5: "Prefer reusing existing project helpers over writing new ones." The base prompt never mentions reuse.

Why each level

Most levels reproduce a way context is built in a real product or a published method, so the results say something about strategies people actually use. Two are our own: selective dropping in its live-tail form, and L8. Dates are the first public appearance we know of.

LevelPrecedentWhy it's here
L0Function synthesis from a docstring, as in OpenAI's Codex paper and its HumanEval benchmark (Chen et al., 2021).The floor: what the model knows without the project. Only meaningful for tasks that need no project code.
L1Editor completion from the open file, as in GitHub Copilot's technical preview (June 2021).The smallest realistic context. Shows how much a task depends on code outside the file.
L2Hand-picked related files: developers pasting files into chat assistants (from late 2022), and Copilot's "neighboring tabs", which reads the other files open in the editor (GitHub, 2023).A deterministic stand-in for "what a careful developer would add": imports and the test file, no search.
L3Whole-repository prompts with long-context models (1M-token windows from Gemini 1.5, February 2024) and repo-packing tools such as Repomix and gitingest."Give it everything" while it fits. Repo L is too big for it on purpose, which is the common case in real projects.
L4Retrieval-augmented generation (Lewis et al., 2020), applied to code by repository-indexing assistants such as Sourcegraph Cody and Cursor's codebase indexing.Retrieval at file granularity: cheap to build, but brings whole files.
L5Function-level retrieval in repository-level completion research such as RepoCoder (Zhang et al., 2023), whose iterative retrieval uses a first draft as the query (our draft_then_search, related to HyDE, Gao et al., 2022). model_queries follows the multi-query rewriting common in RAG pipelines.Retrieval at function granularity: smaller and more precise than L4, and the place to compare query strategies.
L6Aider's repository map: a compact list of definitions sent with every request, built with tree-sitter since October 2023 (ctags before).A whole-project overview at a fraction of L3's size. Shows whether names and signatures alone are enough to find the helper.
L7 grepAgentic search with shell-style tools: SWE-agent's agent-computer interface (Yang et al., 2024), OpenHands (2024), and Claude Code (February 2025), whose team has said it replaced an early vector index with grep-style search.The agent decides what to read. The baseline agent.
L7 hybridAgents that combine text search with semantic search over an index, as in editor-integrated agents such as Cursor's.Adds meaning-based search, so hybrid versus grep measures what embeddings add to an agent.
L7 richSymbol-aware navigation, as language servers give editors (Language Server Protocol, 2016), exposed to agents as tools.Reading definitions by name instead of whole files. Rich versus hybrid measures the tools.
L7 selectiveClearing old tool results from an agent's context, as in Anthropic's context editing (September 2025). Our form is our own: only the latest results can be dropped, so the cached prefix stays intact, and a sizeable drop gives back part of a call. Recent work argues the same direction from the other side: Belcak et al. (November 2026) find that later tokens cost more to generate (up to 7× on frontier open-weight models) and that frontier models lose little or no accuracy when an agent's context is kept short by frequent compaction. There the harness compacts the conversation into a lossy recap; here the model itself chooses which results to drop, and dropped code can be read again.Whether an agent that curates its own context reads less without losing what it needs. Selective versus rich measures the dropping.
L8Our own combination of established parts: a symbol index (as in ctags or a language server's workspace symbols), reading by name, and edit tools that replace exact text (as in Anthropic's text editor tool, October 2024, and Aider's search/replace edit format).The most selective agent we could build: it never needs a whole file, because it changes code with edit tools instead of returning whole files. It is the one documented exception to "only the context varies": its output format is different, so it is reported apart from L7.

The agent harness (L7, L8)

Rules that keep the comparison fair

The repository

shopkit is a synthetic order and inventory service written for this experiment, in three sizes. S is about 2k tokens. M is about 40k tokens and 110 files, standard library only, with its own passing tests; it has 25 planted helpers, about half named in words a task would use and half not, near-miss decoys that fail the hidden tests if used instead, and dead code named like the canonical place, as in real repositories. L is the same shop about a year later: about 169k tokens and 280 files including SQL migrations and HTML templates, old code that keeps old names, more dead code, and five live functions of 200 to 270 lines with a business rule buried in the middle. It is too big to send whole. See Tasks.

What each run records

Outcome
PASS: a valid answer and every hidden test passes. FAIL: a valid answer, but a hidden test fails. INVALID: no accepted answer (no or malformed <file> blocks, pretend tool calls). OUT OF TOKENS: the answer hit the output-token limit. NO FIT: the prompt didn't fit the context window. Infrastructure errors are never recorded; those runs are redone.
Reuse
Reuse tasks have a hidden test that spies on the needed helper and checks the new code really calls it. Reported apart from correctness, so "correct but re-implemented" stays visible.
Regression check
The repository's own tests after the patch. It catches patches that pass the hidden tests while breaking or deleting code elsewhere.
Visibility
Whether the needed helper was in the context at all: its definition, its full body, or a call site.
Output protocol
ok, bad_format, no_code or tool_request (the model asked to explore instead of answering).
Cost
Input, cached and output tokens, latency and tool calls.
Badges
Exact ones read off the run (no code, retried, syntax error in the patch, dead code used, ...) and automatic ones for what the final answer says (declares completion, claims it verified, notes missing context, ...), matched by embedding similarity with a confidence level. The automatic ones are unverified and only for browsing; they never change outcomes.

Clean runs

In the final round runs go one at a time, and the server's prefix cache is made cold before each one, so nothing cached carries over between tasks that share the same repository and system prompt. The cache is dropped through vLLM's reset endpoint, and the server is fully restarted every 25 runs (every 12 for the agents, whose long conversations make the server grow faster) and whenever free host memory drops below 8 GB. Each run records which method was used. Development sweeps run two requests at a time and restart the server the same way, finishing the runs in flight first.

Blind grading

Tests give the labels. A separate judge adds a view of code quality and never changes them. It never learns how a patch was made (level, prompt, context or tools), and it is limited to read-only tools in a directory outside the project. Up to the v3 round the judge compared every candidate patch for a task side by side and ranked them. From the v4 round the plan is penalty grading: one passing patch at a time, a fixed list of defects, each penalty quoting a line of the patch so the harness can check it.

Scope

One model (Qwen 3.8 27B, FP8 on vLLM), one sample per configuration, server-default temperature. Embeddings come from EmbeddingGemma 2 (the v3 round used Qwen3-Embedding 0.6B). Development runs with thinking off, and the final round reruns everything with thinking on in clean mode. Both rounds keep separate run ids, so both appear in the raw data.