Cache Engineering: give an agent control over what its model attends to

A long-running agent repeatedly reads observations that it no longer needs. Summarizing the conversation can reduce that burden, but changing an early message invalidates the cached computation of later messages. Cache Engineering for Agents proposes a different interface: retain the text history, selectively remove its key-value (KV) states from future attention, and reuse the states that remain. Across three models and four agent benchmarks, the authors report a 1.7-point average score improvement and a 27.7% average reduction in estimated inference cost versus their higher-threshold summarization baseline. These are averages under a particular policy and evaluation setup, not universal gains. §§1,5, pp.1–3,8–10.

The expensive consequence of editing yesterday's messages

A model normally processes a sequence of tokens and caches intermediate keys and values so that the next request can reuse prior computation. Removing an old tool response changes the prefix on which later tokens were computed. A conventional server must recompute the retained suffix, a process called re-prefill. Frequent trimming can therefore cost more than retaining everything. In a motivational experiment on 100 BrowseComp-Plus (BCP) tasks with GPT-OSS-120B, keeping only the latest 12 tool-response rounds through text trimming costs 1.85 times the full-context baseline. Summarizing at 48k tokens saves about 7% but loses five percentage points of accuracy.

Cache engineering changes which cached entries participate in future attention without rewriting the logical conversation. The distinction matters: a retained state was originally computed using earlier context, so it can still encode information from entries that have since been dropped. This is not equivalent to running the model on a freshly shortened transcript, and it is not a mechanism for erasing information from all derived states. §§3.1–3.2, pp.3–4.

Scroll horizontally to view the full figure/table.

Three ways to handle an accumulated conversation.
Original Figure 1, p.2. Full context retains all KV; text editing requires recomputing the remaining suffix; cache engineering removes selected entries while retaining downstream states computed with the earlier history.

Three operations, two independent notions of position

The interface exposes append, drop, and repos. Append computes and adds a new token's KV using the currently active cache. Drop removes selected logical token indices from subsequent attention while leaving retained states and the text history unchanged. Repos compacts the position encodings of retained keys and resets the position index for subsequent tokens. A short cache can otherwise retain large position indices and reach the model's positional limit.

For a cached key K moved from position p to q, the paper uses K ← R(q)R(p)−1K, where R is the rotary positional-embedding transformation. Values remain unchanged. The active-cache length, logical transcript length, and positional index are therefore separate quantities. Dropping entries alone does not reset positions. Repositioning rotates stored keys; it does not recompute their hidden states as if the removed text had never existed. §§3.3–3.4, p.5.

Why token-prefix matching is no longer enough

Consider three executions that all retain messages B and C. One computes B and C with A present, then drops A. Another computes B with A, drops A, and only then computes C. The third starts from B without ever seeing A. All end with the same visible token selection, yet their cached states differ. Even the same final position indices cannot erase differences in how a state was originally computed.

AKV, the accompanying serving engine, therefore indexes both tokens and cache-operation history. Its extended radix tree records drop and reposition nodes, preserving ordinary prefix sharing until computations diverge. Reusing a cache based only on the final message list would be incorrect. §4.2 and Appendix A.1.2, pp.6–7,15–17.

Scroll horizontally to view the full figure/table.

Different operation orders produce different cached states.
Original Figure 5, p.5. The three histories retain B and C but differ in their dependence on A. The branching tree distinguishes these computations rather than merging them on token identity alone.

A stateless request with stateful work behind it

A request supplies its full messages plus a cache field describing operations after specified message boundaries. Indices are zero-based; drop executes before repos if both occur at the same boundary. The client does not have to know whether a particular physical cache entry remains resident on the server.

The server must preserve request isolation: dropping an entry for one request must not change another request that shares the prefix. An entry becomes physically evictable only when no ongoing computation or restoration needs it. Positional versions can be evicted independently, and repositioning creates copies when another request still uses the original.

If required states have been evicted, segment-batch attention reconstructs them in one model forward pass. Queries are divided at operation boundaries, and each segment attends to the historical KV and position versions that were valid at its original computation. The feed-forward network processes the batch together, avoiding repeated weight reads across separately replayed segments. The correctness argument assumes a fixed model and position configuration with exact arithmetic; finite-precision rotations need not be bitwise identical to recomputation. §4, Appendix A.1, pp.6–7,15–17.

What was compared

The main policy retains all reasoning KV and the latest 12 tool responses, incrementally dropping older tool-response KV. Standard summarizes at 96k tokens for GPT-OSS-120B and MiniMax-M2.7, or 192k for MiroThinker-1.7-Mini. Text Engineering uses a 48k threshold. AKV repositions at the corresponding Standard threshold.

The four benchmarks are BCP, the 103-task text-only GAIA validation subset, SWE-bench Verified, and xbench-DeepSearch-2510. Their step limits are 100, 200, 250, and 100 respectively. QA is judged with GLM-5.2 using benchmark-specific prompts; SWE patches use official executable tests. Baseline summaries follow Pi's prompts and serialization, retain recent material, and preserve system/developer instructions. Thus this comparison includes concrete summarization choices, not every possible context-management strategy. §5.1, Appendix A.2, pp.8,18–19.

Average gains hide meaningful exceptions

Scroll horizontally to view the full figure/table.

Main benchmark scores and estimated costs.
Original Table 1, p.9. Score is pass rate in percent; cost is US cents per task. A bold best result within a row group is not a guarantee that one method wins every task.

For GPT-OSS-120B, the average score rises from Standard's 51.0 to 53.1, while estimated mean cost falls from 11.2 to 7.3 cents. MiniMax-M2.7 moves from 52.4 to 53.7 and 5.0 to 4.4 cents; MiroThinker moves from 44.1 to 45.8 and 20.4 to 14.8 cents. The authors report a 27.7% cost reduction across the main evaluation. The displayed per-model averages are rounded, so they do not specify the exact underlying cost totals or establish a saving for every individual setting.

Exceptions matter. MiniMax's SWE score falls from 75.2 to 74.4, GPT-OSS's xbench score from 38.5 to 37.5, and MiroThinker's SWE score from 7.8 to 7.4. AKV also costs slightly more on some GAIA comparisons. The appendix's smaller GPT-OSS-20B experiment reports a 45.2 average score versus 44.0 for Standard, with smaller or negative gains on some individual metrics. Attention visualizations over ten selected BCP trajectories motivate retaining reasoning and recent observations; they do not prove that old tool responses are always dispensable. Table 1, Appendix A.4, pp.9,19–21.

Estimated token cost and measured serving speed are different evidence

Cost uses fixed published rates for cache-miss input, cache-hit input, and output tokens, including summary calls. Repositioned tokens are conservatively charged at the cache-hit rate. These are API-equivalent estimates, not measurements of a deployed provider's bill or total infrastructure cost.

Serving tests use GPT-OSS-120B expanded to BF16 on eight A800-80GB GPUs, split into four prefill and four decode GPUs, on SGLang v0.5.20. At each method's peak-throughput setting, AKV at concurrency 14 yields 369 output tokens/s versus Standard's 313 at concurrency 12: 1.18 times. P95 request latency is 28.49 versus 43.16 seconds, a 1.51-fold speedup. Input throughput counts logical input, including dropped tokens, so it is not the number of tokens actually attended to.

The replay selects 80 long-context SWE trajectories. Each method replays tool observations from trajectories collected under its own policy while generating new assistant outputs; turns and output budgets can differ. High-concurrency windows also differ, including one-hour cutoffs with unfinished Standard requests. A separate online first-100-task SWE experiment measures task progress against GPU hours. These protocols support the reported workload comparison, not a hardware-independent speed guarantee. At equal batch size, the appendix reports 59.8% less full-attention time but only 16.0% less total decode-step time, illustrating the limits of accelerating one component. §5.3, Appendix A.1.3–A.4.1, pp.9–10,16–20.

Policies can improve, but cheaper is not automatic

In a 100-task ablation, adding repos to tool-response drop raises GPT-OSS's BCP pass rate from 55% to 62%; dropping reasoning instead weakens results. Recursive policy improvement uses MiniMax-M2.7 on 20 development tasks and evaluates on 100 held-out BCP tasks. Selected iterations save 15.6% and 17.8% relative to Standard while preserving baseline accuracy; the abstract reports a further 7.1% cost reduction over the expert policy. This is bounded policy search, not unrestricted self-improvement.

When cache reduction is exposed as a tool, GPT-OSS reaches 61% versus Standard's 52.1% and costs less, but MiniMax's higher 64% pass rate costs 5.9 rather than 5.4 cents. More successful exploration can increase expenditure. §5.4, p.10.

What an agent developer can take from it

Our interpretation is that memory policy and serving correctness should be designed together. A retained transcript is an audit trail, while active attention is a resource policy; conflating them makes both costs and semantics harder to reason about. Evaluating such a policy should record operation order, retained evidence, task outcomes, and serving pressure, rather than reporting only context length.

Adoption requires a server that implements these semantics. Adding the paper's cache field to an arbitrary API does not establish support. The authors leave broader policy exploration, training under cache engineering, and linear-attention serving to future work. The practical contribution is a programmable boundary between an agent's memory decisions and a server's reuse/isolation responsibilities, with measured benefits and visible exceptions.

Source: Tianyu Fu et al., Cache Engineering for Agents, arXiv:2610.28577v1, 21 pages. The final development interpretation is ours; numerical results and limitations are attributed to the paper.

B2B Content

Any content, beautifully transformed for your organization

PDFs, videos, web pages — we turn any source material into production-quality content. Rich HTML · Custom slides · Animated video.