Dev.to AI ๐Ÿค– Ai ๐Ÿ‘ 0 ๐Ÿ“– 11 min read

2026-11-29: You don't need long context, or do you?

These are my notes from Belcak et al., "You don't need long context" (arXiv:2611.05306v1, 3 Nov 2026, from NVIDIA). The paper starts from the observation that later tokens cost more to generate than earlier ones and asks

2026-11-29: You don't need long context, or do you?

These are my notes from Belcak et al., "You don't need long context" (arXiv:2611.05306v1, 3 Nov 2026, from NVIDIA). The paper starts from the observation that later tokens cost more to generate than earlier ones and asks whether long contexts are actually necessary. Its answer is no: frontier models that compact their history often, and read long inputs piece by piece, lose little or no accuracy on its benchmarks. It goes as far as compacting after every single action, and from that it proposes a kind of model it calls a Semantic State Space Model.

A coding agent re-sends its whole history on every turn. By turn 40, most of what it sends is old tool output. Is carrying all of that a requirement, or a habit?

The playground: one HTML file, no install, no API key: short-context-playground. It runs a made-up agent task under three context-management strategies and compares tokens and cost. It is an illustration and shows nothing about accuracy.

Why I care (a plug, with my interest declared): I build TokenOps with Tisha Chawla. It is open-source (MIT) token governance for agents: one budget for a whole run, checked before every model call. What an agent carries in its context is a large part of what that run spends, so I read this paper with that problem in mind.

Words used below

  • Inference step: one call to the model. In an agent this is usually one turn.
  • Input context / output context: everything the model is given on a step (instructions, task, earlier turns, tool results) / everything it generates on that step.
  • Context window size: the most tokens an endpoint can process in one call.
  • Long / short context: the paper's rough rule is about 256K tokens or more for long, and roughly 16K-50K for short.
  • Long-horizon task: needs many actions in sequence, so history piles up.
  • Long-input task: arrives with input big enough to be a long context if pasted in whole.
  • Compaction: replacing a conversation's history with a short written recap.
  • Prefix cache: the server reuses KV cache for a prompt prefix it has already processed. API users see it as cheaper "cached input" tokens.

Long-horizon and long-input: two different problems

The paper splits long context by where it comes from.

Long-horizon task Long-input task
What is long the history the agent builds up as it works the material handed to it with the task
How it grows step by step, with every action and result it is all there from the start
Example benchmarks SWE-bench, Terminal-Bench, FRAMES LongBench v2, LOONG, RULER
What keeps the context short compacting the history reading the input selectively, with compaction as a fallback
Research question RQ1 (and RQ3) RQ2

The two are linked: store a long input as files, give the model a tool to read parts of it, and the long-input task becomes a long-horizon one.

The cost of a long context

On open-weight models served on H100s, generating a token with a 256K context window costs 3.6x (GLM 5.2), 5.6x (Kimi K2.6) and 7x (Qwen 3 Coder Next) what it costs with a 16K window. On a single desktop machine (DGX Spark), inter-token latency roughly doubles across context lengths for several models, and memory use grows too. Retail token prices hide this, because they do not change with context length.

Cost per output token at 256K versus 16K
Redrawn from the ratios reported in Belcak et al., Figure 1.

These numbers are measured under saturated serving load. For each window size, the authors send requests with random lengths up to that size, raise the number of simultaneous requests step by step, and report the best throughput reached without any KV-cache preemption. Preemption is what my PagedAttention post was about: when no KV blocks are free, a running request gets pushed out.

The desk and the filing cabinet

Picture doing a long job at a desk. Every time you take a step, you first re-read everything on the desk, and you pay per page.

  • Keep everything on the desk. Nothing is ever lost. The pile you re-read keeps growing.
  • Clear the desk when it gets full. Write a one-page note on where you are, sweep the rest away, continue from the note.
  • Clear the desk after every action. Only the note survives. You rewrite it each time.

A filing cabinet next to the desk holds every page you swept away. Nothing is lost, you just are not re-reading it all the time.

The three regimes

Both of the paper's agent harnesses (mini-swe-agent and mini-agent) run a minimal loop with one bash action per turn. Three ways of handling history sit on top:

FHA, EoCC and SAC

  • Full-History Accumulation (FHA): append every action and result. Never remove anything.
  • End-of-Conversation Compaction (EoCC): run like FHA until the context crosses a threshold, ask the model for a bounded recap, then start a fresh conversation with the same system prompt, the original task and the recap. Settings are written total limit / compaction threshold, for example 16K / 12K. The gap between them is room to write the recap.
  • Single-Action Compaction (SAC): each conversation gets the task and the current state, does exactly one action, sees the result, rewrites the state, and is thrown away.

Long inputs are not pasted into the prompt. They are saved as files, and the agent reads the parts it wants with grep, sed, head and similar tools. This is how a long-input task turns into a long-horizon one.

What every compaction needs

EoCC and SAC both compact (FHA never does). Compaction is itself a model call, so it has two requirements.

  • Room in the context window. The model has to read the conversation it is compacting and still have enough free space to write the recap. Compact too late and there is nowhere to write it. This is why EoCC has two numbers: at 16K / 12K, compaction starts at 12K and the space up to 16K is reserved for it. The paper ends the conversation if the compaction does not finish in time.
  • Money. The call is billed like any other. The recap is output, the most expensive kind of token, and the next conversation starts with mostly uncached input.

Warning about the numbers below. The paper's token totals show more output tokens when compacting, but they do not separate out what compaction itself cost. For SAC, which compacts after every action, the paper reports no token counts or cost at all. SAC's short context should not be read as a cheaper run necessarily.

On what makes a good compaction summary: it is not a summary of what happened. It is a brief for what happens next, with the task copied nearly word for word, the current plan, and the exact facts and file paths still needed.

One run, worked by hand

A made-up run to see the mechanics. 10 steps. System prompt plus task: 3,000 tokens. Each step the model writes 500 tokens and the tool returns 2,000, so history grows by 2,500 per step. Recap: 1,500 tokens, asked for with a 200-token instruction. Prices are Opus 4.5 list prices per million tokens: $5 new input, $0.50 cached input, $25 output.

FHA. The input on step n is 3,000 + 2,500 x (n - 1): 3,000, then 5,500, up to 25,500.

new input    =  25,500
cached input = 117,000
output       =   5,000
cost         =  $0.311

EoCC at 16K / 12K. After step 4 the context reaches 13,000, past the 12,000 threshold, so there is a recap call. The next call is 3,000 + 1,500 = 4,500 tokens, of which only the first 3,000 can hit the cache. It happens again after step 7.

new input    =  28,900
cached input =  65,500
output       =   8,000
cost         =  $0.377

Two things to notice

  1. The peak context fell from 26,000 to 14,700, but at flat prices the bill went up. Cached input was cheap to begin with, and the recaps are output tokens.
  2. If a short context limit also bought a 5x lower price per token, EoCC would cost $0.0755, about 4.1x cheaper than FHA. The paper's cost estimate works this way (see below).

RQ1: can long-horizon tasks do without long contexts?

Six benchmarks, Claude Opus 4.5 and GPT 5.6 Sol, 22 threshold configurations per model. Compared with FHA, accuracy changes run from -3.7 to +5.6 points for Opus and -3.3 to +4.4 for GPT. For either model, no more than 5 of the 22 configurations lose more than 2 points. Estimated cost savings run from 2.2x to 8.8x (Opus) and 2.4x to 5.0x (GPT).

Each cell is "Opus / GPT" across that benchmark's settings.

Benchmark Accuracy change (points) Estimated saving
SWE-bench Verified -1.2..+4.8 / +0.2..+4.4 3.2-6.7x / 3.0-4.1x
Terminal-Bench 2.1 +1.1..+5.6 / -2.2..+1.2 2.2-4.9x / 2.4-4.0x
SWE-bench Multilingual -2.0..+1.7 / -1.6..+0.7 3.7-8.8x / 3.0-3.5x
FRAMES -3.7..-1.3 / -3.3..-1.5 4.0-7.7x / 2.8-3.8x
BFCLv3 -0.5..+2.0 / -0.5..0.0 4.0-5.1x / 4.1-5.0x
tau2-bench -1.1..0.0 / 0.0..+3.3 4.8-5.4x / 3.7-3.9x

The answer to RQ1 is yes.

When history is needed

Compaction is lossy, and compacting a recap of a recap loses more. The authors give their own counterexample. An agent tosses coins with a tool and each result lands in the history. With a fixed recap budget, enough tosses guarantee that some are forgotten, so a question about toss number i will eventually fail. The fix: the harness keeps every message outside the context, and the agent queries it with a reading tool. Information that must be in context is different from information that can be fetched when needed. That is the filing cabinet.

Coin toss: toss 7 dropped
In the playground, a 600-token budget at 12 tokens per record holds 50 of 200 tosses. Toss 7 is gone.

Coin toss: toss 7 recovered
The same question answered by reading the history file.

RQ2: can long-input tasks do without long contexts?

Seven benchmarks. The baseline gets the whole input in the prompt; the compacting agent reads files selectively. Accuracy changes run from -0.4 to +40.0 points (Opus) and +1.0 to +30.9 (GPT), with estimated savings of 6.5x to 54.6x (Opus) and 4.4x to 233.3x (GPT). I wrote "Wow!" next to this figure.

Benchmark Opus: full โ†’ selective GPT: full โ†’ selective Estimated saving (Opus / GPT)
LongBench v2 68.0 โ†’ 67.6 70.8 โ†’ 72.6 7.4x / 4.4x
LOONG (avg score) 70.1 โ†’ 79.3-80.2 79.3 โ†’ 82.7-84.6 7.6-13.6x / 12.9-17.4x
AA-LCR 65.0 โ†’ 80.0-84.0 82.0 โ†’ 83.0 6.5-9.8x / 13.9-16.2x
Needle in a Haystack 60.0 โ†’ 100.0 80.0 โ†’ 100.0 54.6x / 233.3x
RULER (recall) 62.5 โ†’ 95.7 65.5 โ†’ 96.4 42.8x / 80.5x
Counting-Stars (exact) 65.1 โ†’ 81.2 76.6 โ†’ 81.2 25.9x / 40.7x
BABILong 67.1 โ†’ 92.0 70.7 โ†’ 94.0 31.5x / 88.0x

Compaction is rarely needed here: on several of these benchmarks the median task never compacts, so selective reading does most of the work. The answer to RQ2 is also yes.

RQ3: one action per context

SAC against the full-history baseline, with the best EoCC setting for comparison. Peak context is median / maximum per task.

Model, benchmark FHA Best EoCC SAC Peak, FHA Peak, SAC
Opus, SWE-bench Verified 70.0 74.8 70.2 32K / 200K 8K / 16K
Opus, Terminal-Bench 2.1 47.2 52.8 51.8 27K / 130K 9K / 19K
GPT, SWE-bench Verified 84.4 88.8 82.4 18K / 173K 7K / 15K
GPT, Terminal-Bench 2.1 87.6 88.8 84.3 17K / 133K 8K / 37K

SAC keeps or improves Opus's accuracy, and GPT drops a little. Median peak context is 7-9K, and the maximum falls from 130-200K to 15-37K. I find it surprising that this works at all.

How the cost savings are estimated

The Opus and GPT savings are estimated, not billed (Appendix B). The three open-weight models cost 0.28, 0.18 and 0.14 times as much per output token at 16K as at 256K, and the rounded mean is r = 0.20. For a closed model, the list output price is assigned to its full reference window, the price at 16K is set to r times that, and everything between is a straight line. Input and cached-input prices follow by keeping the same ratios.

The appendix tables show both the list-price and the estimated cost. For Opus 4.5 on SWE-bench Verified:

New input Cached Output List price Estimated
Baseline 20.0M 420.0M 4.4M $420.00 $420.00
16K / 12K 28.3M 127.3M 4.3M $312.65 $62.53

So the same run is 1.34x cheaper at list price and 6.7x cheaper with the estimate.

Open-weight models

Results vary a lot more here. On SWE-bench Verified at 16K / 12K, all five models lose accuracy. Qwen 3 Coder Next falls from 53.0% to 3.6%, which the authors put down to verbose trajectories that leave too little room to make progress between compactions. Qwen 3.6 27B (68.6 โ†’ 65.0) and MiniMax M2.7 (72.6 โ†’ 67.8) hold up much better.

The authors also say their evidence does not rule out tasks that benefit from long context.

Semantic State Space Models

An SSSM would be a model post-trained to (1) read a natural-language description of where a conversation stands, (2) reason about what to do, (3) take an action, (4) register the outcome, and (5) rewrite the description so that a fresh instance can carry on. A classic state-space model keeps a neural state that you cannot read; an SSSM keeps a written one that you can. This is a proposal: no SSSM is trained in the paper. It ends by asking why anyone trains full-history models at all.

How this connects to PagedAttention and KV-cache reuse

In my post on KV reuse in coding agents, the rule was: appending keeps the cache, changing anything early breaks it from that point on. Compaction rewrites history, so it is a deliberate cache break.

What the cache sees at a compaction

The break is partial. The system prompt and task come first and do not change, so they can still hit. Everything after them is new.

EoCC per call
Playground, EoCC view: each bar is one model call. Green is cached input, coral is new input, amber is output. The dots mark compactions.

In PagedAttention terms, a compaction lets the server free the blocks that belonged to the old history, while the blocks for the shared system prompt and task can be kept. A smaller context limit also caps how many blocks one request can hold, so more requests fit before preemption.

Try it yourself

All three regimes
The default run: 40 steps, flat prices.

  1. With the defaults and flat prices, compare the three cost rows. Which regime is cheapest? Which has the smallest peak context?
  2. Switch to the context-discounted price. What changed, and did any token count change?
  3. Keep that price and drag r towards 1. At what value does EoCC's saving over FHA drop below 2x?
  4. Set steps to 10, the limit to 16000 and the threshold to 12000. Check the totals against the worked example above.
  5. With flat prices, set steps to 10, 20, 40 and 60. When does EoCC start to beat FHA, if you keep 32000 / 24000?
  6. Raise the summary size from 1500 to 6000. Which regime is hurt most?
  7. Untick "system + task still cache-hit after a reset", then set the system prompt to 10000. How much does a stable prefix matter to SAC?
  8. Open the coin toss. Find the smallest budget that remembers all 200 tosses.

If the bill is what brought you here, try TokenOps. It wraps your agent's model call and enforces one budget across the whole run. One of its policies, context compaction, acts before a call as the input nears its ceiling: it moves volatile values below the stable prefix so caching still works, drops repeated tool outputs, and summarizes only filler while pinning the system prompt, constraints and live state. Code and quickstart: github.com/theagentplane/tokenops.

๐Ÿ“ฐ Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.