GO TO A SECTION

↑ ↓ to navigate · Enter to openExplore all sections →
FDEInterviews logo
RecentarXiv preprint

Context Language Models

Give the model write access to its own context, as a file it edits with Bash, and let it invent its own compaction. Beats fixed harnesses at lower compute in most tests, with caveats in the setup.

Breakdown by FDE Interviews · 13 min read · Updated

About the original · 2026
AUTHORS
Shao, Shen, Yin, Li, et al.
FROM
University of Washington, Meta Superintelligence Labs, MIT, Trillium Labs
PUBLISHED
Sep 2026 · arXiv preprint
CITED BY
0Semantic Scholar · Oct 2026
IN THIS BREAKDOWN · 10 SECTIONS

You can read 20% of this breakdown.

01

The paper in one minute

A standard language model appends: each turn's output is added to the context, so the next context is the old one plus the new tokens. Agents on long tasks hit the window limit, and the fix so far has been a harness. Codex-style compaction summarizes the history at a fixed threshold; tools such as Self-Compact, ACM and Context Folding give the model a few predefined actions. In each case a human picked the strategy.

Rulin Shao, Pang Wei Koh and colleagues at the University of Washington, Meta Superintelligence Labs, MIT and Trillium Labs propose Context Language Models (CLMs), models that manage their own context. Formally, the next context is any function of the current one the model chooses, rather than the current one plus new tokens. The implementation is simple: the live context is mirrored to a file whose path is in the system prompt, the model edits that file with ordinary Bash, and each edit is synced to the server before the next turn. If the model does not edit, generated tokens are appended as usual. Multiple agents get multiple context files.

The paper reports emergent behaviors: an orchestrator keeping a scoreboard of subagents through 163 in-place edits at 6 to 8K tokens, a new "notes" chat role the model invented, and a compact_turns helper function it defined and called 37 times.

It then adds four pieces: ContextBench, four synthetic tasks that test context management alone (separate from the coding-retrieval benchmark with the same name); prefix-reuse FLOPs, a cost metric that charges for re-prefilling after an edit; in-context steering and skill evolution, plus an RL recipe with a success-gated efficiency advantage; and Suffix Cache Reuse (SCR), an SGLang patch that keeps cached states after an edit. Across coding, deep research, math optimization and day-long repository work, CLMs beat or matched the harnesses at lower compute in most settings.

THE IDEA, VISUALLY
CONTEXT AS A FILE Standard LM c(t+1) = c(t) ⊕ f(c(t)) append only Context LM c(t+1) = f(c(t)) rewrite anything The live context is mirrored to a file. The model edits it with Bash (sed, Python, re.sub); each edit syncs to the server for the next turn. No edit means plain appending. AN EDIT UNDER PREFIX CACHING: [A B C] → [A B′ C] Standard A reused B′ prefill C prefill again Suffix Cache Reuse A reused B′ prefill C reused, re-rotated SCR reuses states computed under the old context, so it approximates re-prefilling; at most K=6 spans move per edit. Of the 7.8% of prompt tokens it reused on BrowseComp-Plus, 5.3 points came from stripped reasoning, not edits. HEADLINE RESULTS, ABSOLUTE NUMBERS benchmark CLM baseline compute BrowseComp-Plus, 27B 59.4 ≈53.3 −21.5% TBLite, 27B 73.7 67.0 91% TerminalBench 2.1, 27B match 70% EdgeBench-10, 32K, 27B 44.6 42.3 179/437 PF EdgeBench-10, 128K, 27B 47.3 47.8 142/222 PF EdgeBench-10, 32K, Sonnet 51.0 42.3 baseline = Codex-style summary; ≈53.3 derived from “11.4% relative” RL ON QWEN3.5-9B, BROWSECOMP-PLUS (TABLE 2) CLM 28.8 42.5 Summary 34.7 42.1 before → after training; 1.34 vs 2.19 PFLOPs per question after SUFFIX CACHE REUSE, BROWSECOMP-PLUS (FIG. 9) Standard SGLang 10.98 PF Suffix Cache Reuse 7.14 PF accuracy 60.2% in both runs
A Context Language Model edits its live context as a file instead of only appending to it. Under prefix caching, every edit forces the text after it to be prefilled again; Suffix Cache Reuse keeps that text's cached states. The headline gains are relative, and in the one setting with a looser budget, plain summarization tied.
Research notes: the problem, approach and results
59.4%

BrowseComp-Plus accuracy, Qwen3.6-27B with a 32K limit, against about 53.3% for summarization (derived from the 11.4% relative gain)

38.3 → 74.2

held-out KV Store accuracy on ContextBench after evolving a context-management skill, the paper's 35.9-point claim

10.98 → 7.14

PFLOPs per BrowseComp-Plus question with Suffix Cache Reuse instead of standard SGLang, both at 60.2% accuracy

THE PROBLEM

Agents on long tasks outgrow their context window. Harnesses compact on a fixed schedule with a fixed summary prompt, or give the model a few predefined tools (compact, offload, retrieve, branch). Either way, a human chose the strategy, and simple tasks expose its blind spots.

THE IDEA

Mirror the live context to a file the model can rewrite with ordinary Bash or Python; edits sync to the server before the next turn. The model decides what to keep, compress, move to disk or restructure. Steer it with instructions or evolved skills, train it with RL that rewards cheaper successful trajectories, and serve it with a cache that survives mid-context edits.

THE RESULT

With Qwen3.6-27B and a 32K limit, CLM scored 59.4% on BrowseComp-Plus, 11.4% higher in relative terms than Codex-style summarization, using 21.5% fewer prefix-reuse FLOPs. It also led on TBLite, EdgeBench-10 and four math optimization problems. RL took Qwen3.5-9B from 28.8% to 42.5%. Suffix Cache Reuse cut compute 35% at equal accuracy.

02

Why it matters to an FDE

Every long-running agent you deploy has a context strategy, usually inherited from a framework default: summarize at 75% full, truncate old tool output, or nothing. This paper argues the model can do better if you let it, and gives evidence on public benchmarks.

Smaller harness, more model. CLM keeps the harness minimal: one file, Bash, a reminder near the limit. The strategy lives in the model and in instructions, which you can change per customer with one sentence. The paper shows one-sentence instructions changing when and how the agent compacts.

Edits have a serving cost. Prefix caching only reuses an unchanged prefix. Rewriting something early in the context forces everything after it to be prefilled again. A context strategy is also a cache strategy, and the paper's metric makes that cost visible.

Editable context is an attack surface. If the model can write its own context, injected text can persist by being copied into notes, and the paper cites a report of a model inserting unauthorized instructions into its own compaction summary. Log context edits like any other privileged write.

It needs a capable model. The 9B model edited less, filled its context more and needed RL to catch up. On small models, a fixed harness may still win.

THE FULL BREAKDOWN

Understand the mechanism. Try it on a real problem.

Unlock this breakdown and 99 more papers.

Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.

6 months · One payment · No auto-renewal

Get Premium · ₹2,000 / $25
  • ◇1 architecture diagram
  • </>1 runnable code experiment
  • ▦1 results table
  • ?5 interview questions with answers
  1. 03Key takeaways

    Mechanism, the four contributions, headline results in absolute numbers, and misreadings to avoid

    Free account
  2. 04How it works

    Context as a file, the cost metric, steering and evolution, RL with an efficiency advantage, and SCR

    Premium
  3. 05The numbers that matter

    Relative and absolute results, the RL comparison, the swarm result and the serving savings

    Premium
  4. 06Try it yourself

    Recompute the paper's FLOPs constants, then cost four context policies over a 60-turn trajectory

    Premium
  5. 07Where it breaks

    Setup asymmetries, relative claims, inconsistencies, model dependence and safety

    Premium
  6. 08Using it on a deployment

    Adopting model-managed context for a customer's long-running agent

    Premium
  7. 09Interview angles

    Five questions this paper prepares you for, with answer hints

    Premium
Back to the paper library →