Field guide · 24 sources

Field guide: Context economics

What agents spend on context and how to cut it: caching, where stable content goes, routing, hand-offs, learned spend controllers, tool and skill catalogs and stop rules.

Bottom line

Every tool result an agent receives is paid for again on every later turn (R118-f5), so the first job is to keep the input cacheable and small. Keep the top of the prompt byte-stable (R118-f3), confirm in the usage data that the cache is actually hit (R156-f7), and load tools and skills only when a turn needs them (R054-f5) (R246-f1). After that, try routing turns to cheaper models, which saved 9.2 to 22.6 percent against GPT-6 Astra alone in NVIDIA's own newer runs (R085-f5), and a plan-then-execute hand-off, which a newsletter advises without measurement (R068-f1) (R068-f6). Stop loops that have stopped making progress (R113-f4) (R128-f4), and move closed-choice decisions off the LLM (R032-f1). Judge every one of these by cost per solved task against a named baseline, because a cheaper model call does not guarantee a cheaper solved task (R085-f6).

The mechanism is simple and comes from vendor descriptions rather than measurements (R118-f7). A prefix cache matches only from the start of the prompt up to the first differing token, so appending is cheap and an early change forces everything after it to be reprocessed, in Together AI and Ollama's description of their own stack (R118-f2). Their 100-turn example of 5,050 units of uncached prompt work against 100 cached is idealized arithmetic with equal-sized turns, and the post itself says real turns vary and a cached session is not free (R118-f1). The post gives no benchmark, hit rate or cost number (R118-f7). A practitioner explainer adds that the uncached suffix still has to be prefilled (R051-f2).

One cost experiment cited here is a learned per-repository controller, tested by its own authors on 277 tasks in five agent-model settings (R113-f5). Their TokenEconomizer lowered mean cost 18.4 to 30.9 percent against a high-effort default across five agent and model settings on 277 SWE-Bench tasks, three seeds each, and Pass@1 rose in four settings and fell 1.0 point in the fifth (R113-f5). Those headline numbers come from the paper's evaluated controller, which redirects a stuck agent once and then terminates the rollout (R113-f4). The authors are from UC Berkeley, Microsoft Research and Microsoft Security, and the result has not been independently replicated (R113-f1) (R113-f5) (R113-f8).

The rest mixes vendors describing their own systems (R118-f7) (R116-f6) (R071-f6) (R032-f6), authors' own papers that are each a single study (R230-f6) (R042-f1) (R044-f1), user-filed GitHub issues (R156-f8), one practitioner's own sessions (R201-f6) and one newsletter (R068-f6). Claims from single-run sources carry less weight below.

Decide first

QuestionIf yesIf noEvidence
Does anything near the top of the prompt change per turn or per session (timestamps, git status, working directory, user name)?Move it into the task message so the system prompt stays byte-identical (vendor advice, no measured saving)Keep the prefix as it is and still check cached tokens in usage data (R156-f7)(R118-f3) (R118-f2)
Did you change the model, SDK or request shape?Check cached tokens in the usage fields before trusting your cost modelKeep monitoring usage fields as routine(R156-f7) (R156-f1) (R156-f5)
Does the agent load more than about 15 tools, or a large MCP install?Defer tool loading or use discovery meta-tools, and check how many loaded tools are ever calledLoad the tools up front(R054-f5) (R113-f2) (R246-f6) (R071-f4)
Do you have many skills?Load only name and description up front and the body when the skill runs, and keep the visible set smallNo source tests small skill sets; staged loading still costs only about 100 tokens per skill (R246-f1)(R246-f1) (R064-f7)
Does the work split into a hard phase and a routine phase?Try routing or a plan-then-execute hand-off, and measure cost per solved taskKeep one model(R085-f6) (R085-f5) (R068-f1)
Does the agent need exact details from far past its context window?Keep a verbatim log it can search, beside any summariesSummaries or masking may be enough(R230-f1) (R230-f2) (R230-f6)
Is the decision a closed choice from a stable catalog at high volume?Consider a small decision model, after a side-by-side on live trafficKeep the LLM(R032-f6) (R032-f4)
Does the agent re-review or retry work that already passed?Add a stop rule tied to a checkWatch instead for stopping too early(R128-f4) (R086-f4)

Do

  1. Keep the prefix byte-stable. Together AI and Ollama recommend keeping the system prompt byte-identical across turns and sessions and putting per-turn and per-session values in the task message, because per-turn values force a full re-read and per-session values stop new sessions reusing a shared cached setup (R118-f3). They also recommend fixing reasoning effort per session, because one model's chat template writes effort into the first system block (R118-f4). Both are vendor recommendations with no measured saving (R118-f3) (R118-f7).

  2. Put changeable and bulky content late, and say what you cut. The same post recommends loading searched tools at the end of the conversation rather than in the tool list near the top, which depends on the chat template, since some templates reject tool definitions mid-conversation (R118-f4). It recommends truncating tool output with a note of what was cut, because every tool result is paid for on every later turn and silent truncation leads the model to edit code it never saw (R118-f5). That advice is illustrated with an invented example, not a measurement (R118-f5).

  3. Confirm the cache in usage data after every model or SDK change. In one user-filed OpenCode issue's two-request test on a dev build, GPT-6.2 Sol cached 0 tokens of a 10.1k-token text sent as top-level instructions and 10,113 when the same text was sent as a leading developer message, while GPT-6.1 Sol cached both shapes (R156-f1). That reporter says their review sessions sent a 12,926-token system prompt on every request, which made their GPT-6.2 Sol reviews 2.85 times the cost of identical GPT-6.1 Sol reviews, a session cost ratio, not a ratio of billed input (R156-f2). A separate reporter on a Codex issue saw a 46.4 percent hit rate across 122 GPT-6.2 Sol requests against 97.4 percent across 13,044 GPT-6.1 Sol requests in one client over two days (R156-f4). The Codex issue author reports that OpenAI's cache diagnostics showed a hit on runs where the usage fields showed zero cached tokens (R156-f5). OpenCode v2.3.2 now sends the system prompt as a leading developer message, and its release notes say uncached input per step on Copilot gpt-6.2-sol fell from about 14,000 tokens to 3, a project statement not independently verified (R156-f6). The recommendation drawn from these reports is to keep a static system prompt first and byte-stable as a developer message for GPT-6.2 and later, and to trust usage fields over diagnostics when they disagree (R156-f7). The claim that OpenAI confirmed the behavior is deliberate is second-hand, from the OpenCode reporter, while the open Codex issue treats it as a possible regression and asks OpenAI to confirm (R156-f8).

  4. Count the tools you load against the tools you call. In the TokenEconomizer authors' profiling of 60 SWE-Bench tasks, the agent was shown 23 tool schemas on every turn, no repository invoked more than 7, 16 were never called and 3 accounted for 98 percent of calls (R113-f2). Uber estimates that a default MCP install with more than 100 tools spent 50,000 to 70,000 tokens on tool definitions before the user typed anything, in one configuration (R246-f6). Uber's gateway answers with four discovery meta-tools, response projection that trims replies to the fields the model names, and a Code Mode that writes results to files agents grep, but the blog gives no token or cost numbers for any of them (R071-f4) (R071-f6). An MCP server's README says one toolset setting cuts the tool definitions the model sees from about 52,000 to about 12,000 characters, an author figure not independently measured (R028-f6). Wavestone's survey recommends deferring tool loading past about 15 tools (R054-f5), and Anthropic expects tool selection to degrade past 30 to 50 definitions, as guidance not measured in its article (R132-f4).

  5. Load skills in stages and keep few of them visible at once. Uber's skills load their name and description at about 100 tokens, the body only when the skill runs and scripts on demand, a vendor design statement (R246-f1). Its marketplace grew past 5,000 skills with more than 1 million invocations in one month, by Uber's own telemetry (R246-f2). In Uber's ablation of one warehouse-query skill, sessions without it made 13 percent more tool calls, had six times as many tool errors and took 31 percent longer (R246-f5). Anthropic reports Claude Code's system prompt was cut by over 80 percent using skills, a vendor figure about its own product (R132-f2). In the ACES authors' 25-variant routing stress test, which sits outside their headline results, wall time rose from 258 s to 451 s as visible skills went from 1 to 20 while lift stayed flat, and at 50 visible skills the with-skill pass rate fell to 0.55 (R064-f7).

  6. Route turns to a cheaper model, and judge it per solved task. NVIDIA's Stage router scores each call from the tool-result history and pushes toward the capable model on errors, spinning and exploring, with hard overrides on repeated failures and compaction (R085-f1). After a switch it holds the capable tier for a default of 2 requests (R085-f2). The docs give no purpose for the hold and never mention a prompt cache, so any cache rationale for it is ours (R085-f2). On NVIDIA's own earlier Terminal-Bench 2.1 runs, with the run count not stated, Stage solved 79.03 percent at 109.81 dollars per run against Opus 4.8 alone at 77.15 percent and 148.83 dollars and GLM 5.2 alone at 74.16 percent and 71.31 dollars (R085-f3). On its newer runs Stage matched GPT-6 Astra alone (72.86 against 72.27 percent) for 22.6 percent savings on DeepSWE, and scored 58.60 against 59.95 percent for 9.2 percent savings on SWE-Atlas-QnA (R085-f5). The README itself warns that a cheaper model call does not guarantee a cheaper solved task (R085-f6). Uber's cheaper-model worker subagent cut one tracing skill's cost per invocation 46 percent, while a deployment skill showed no drop in its first week (R246-f7).

  7. Price models by task, not by token. On Databricks' own private-codebase benchmark, GPT-6 Luna and Claude Opus 5.5 both scored 89.1 percent but averaged 0.05 and 1.62 dollars per task, and Gemini 3.8 Flash averaged 140 turns and 11.97 dollars per task despite a low token price (R116-f2). Those costs are estimated from list prices, and the number of tasks and runs is not stated (R116-f2) (R116-f6). The argument that a model pricier per token can be cheaper per task also appears in a practitioner post, but there its 5x and 6x figures are a hypothetical with no data (R201-f4).

  8. Plan with the strong model, then hand a written brief to a cheaper one. A paid newsletter advises using Fable 5.2 for one big planning job and Opus 5.5 for daily work, handing over through a written brief in a new chat rather than switching models in the same chat (R068-f1). Its nine-part brief covers the goal and done-when checks, the next step, decisions with reasons and rejected options, facts, what is done, what to ask first, open items, a checklist and fixed executor rules (R068-f3). Its reason for not switching in-chat, that each model keeps its own cache, is the author's paraphrase of screenshots that were not checked here (R068-f2). The newsletter offers no measurement of any cache saving or cost difference (R068-f6); the only plan-then-execute figure in these sources is NVIDIA's own run in which Plan/Execute via Stage saved 82.1 percent of cost against GPT-6 Astra alone at 69.32 percent solved (R085-f5). Together AI and Ollama separately advise giving subagents a brief rather than the full parent history when they need little (R118-f5).

  9. Learn spending policies from finished sessions, and know what the controller does. TokenEconomizer learns per-repository micro-skills, prunes tools while always keeping shell, read, write and edit and periodically restoring the full catalog, and guards against failure loops with a turn budget, a rule check and an LLM judge (R113-f4). Its evaluated controller redirects a stuck agent once and then terminates the rollout, so the 18.4 to 30.9 percent savings against the high-effort default include those terminations (R113-f4) (R113-f5). In the authors' ablation on two Claude Code settings, tool pruning saved most on its own (13.2 and 17.7 percent), micro-skills 11.8 and 14.3 percent and the loop guard 7.1 and 5.4 percent, and no single mechanism matched the combined 23.6 and 30.9 percent (R113-f7). Averaged over the two Claude Code settings, most repositories started more expensive than default and cumulative cost fell below default in every repository by the sixth task (R113-f7). Fixed strategies did not generalize the same way: three fixed cost plugins each lowered cost in some repositories and raised it in others (R113-f3).

  10. Keep a verbatim log the agent can grep, beside the summaries. GrepMem keeps summarisation for working context but appends every message, tool call and result verbatim to a plain-text log and gives the agent a regex search tool after the first compaction, with no embeddings, index or second model (R230-f1). In the USC authors' own experiment with one RL-trained 9B model per strategy, it scored 97.4 and 95.3 percent on two exact-recall tests against 13.9 and 6.6 percent for summarisation and 20.7 and 6.6 percent for observation masking, while MemGPT-style memory scored 99.9 and 50.0 percent (R230-f2). Its token use was 19 percent above summarisation and 29 percent of MemGPT's on ContextBench (R230-f4). The authors list one 9B model, controlled benchmarks, lexical search that needs the agent to name a pattern, and a log that may hold sensitive data as limits, and this review adds that one RL run per strategy leaves training variance outside the intervals (R230-f6).

  11. Move closed-choice decisions to a small decision model. Two Amazon engineers replaced Claude Sonnet 4.6 with a Strands Decider build for 20-label ticket classification and cut average time per call from 4,215 to 897 ms and tokens per ticket from 6,724 to 2,010, on their own traffic (R032-f1). At list prices that is about 22,200 dollars against about 500 dollars per million tickets, which is vendor arithmetic with an assumed headroom, not billed cost, and excludes Lambda (R032-f2). They ran both models side by side on live traffic with a 45-second config rollback (R032-f4), and they now sort JSON keys because key order moved output probabilities by up to 0.19 (R032-f5). The case study publishes no accuracy or agreement rate, comes from the vendor's blog about its own model, and fits only closed choices from a stable catalog at high volume (R032-f6).

  12. Write stop rules that end on a check. LangChain added a rule to ship once one review finds no real defect, and a one-page run fell from 18 minutes to 7 after the agent had been re-reviewing fine pages, in a single reported example (R128-f4). A Lean prover's router attempts again only when predicted next-attempt success minus a cost term is positive (R042-f5), and in its authors' evaluation it cut compute 28.9 percent at parity accuracy against a fixed-step baseline on a 43-problem test set (R042-f1). Wavestone also recommends cheap stuck caps (R054-f5).

  13. Measure tokens by kind, and measure each change before and after. A Claude Code profiler reports new, cached and output tokens per context and deliberately shows no single price, because a weighted total would hide that copied parent context is mostly cheap cache reads (R110-f4). In its author's single case, a reuse rule misread uncommitted files as changed and a script crashed, so a final validation reran at 48.0k new tokens against 66.7k for the first run after only Markdown changed (R110-f2). Uber measures per-skill cost as the session-cost difference around each call, which includes following turns and suits before-and-after comparison more than absolute accounting (R246-f8). With that method, a script run at load time cut one search skill's mean cost 32 percent, and notification turns were about a third of spend in the 20 highest-spend sessions, so Uber moved polling to a background agent (R246-f7). Harness choice changes spend too: in the FairyClaw authors' own comparison on 75 tasks with gpt-5.4 and context compression disabled, FairyClaw scored 0.746 on 3.51M tokens and Moltis 0.744 on 6.29M (R044-f1).

  14. On self-hosted serving, protect cache reuse when you scale. In one RL-rollout paper, raising concurrency alone on SWE dropped cache reuse from 98.3 to 87.5 percent, in the authors' runs on H20 GPUs (R115-f5). Together AI describes cache-key or longest-prefix routing with load awareness and CPU offload of idle session caches during tool waits, with no figures published (R118-f6). NVIDIA's Dynamo router balances KV cache reuse against worker load, and the post gives no measurement of its own (R176-f2) (R176-f4).

Avoid

Where the evidence disagrees

DisagreementSide ASide BWhat reconciles itWhat would settle it
Does routing to a cheaper model save money at equal quality?Stage solved 79.03 percent at 109.81 dollars against Opus alone at 77.15 percent and 148.83 dollars (R085-f3); a cheaper worker subagent cut one skill's cost 46 percent (R246-f7)Where Stage saved money it sometimes scored lower: 1.35 points below Astra alone on SWE-Atlas-QnA for a 9.2 percent saving (R085-f5), and 61.36 against 62.8 percent for Sol alone on DeepSWE (R085-f4); a deployment skill showed no drop in cost (R246-f7); the vendor warns a cheaper call does not guarantee a cheaper solved task (R085-f6)Savings differ across model pairs, benchmarks and skills, no source tests why, and all router figures are vendor-run (R085-f3) (R085-f5) (R246-f7)Independent runs of one router over several model pairs, with repeated runs and cost per solved task
Does a verbatim log beat summarisation for long sessions?After RL, GrepMem scored 97.4 and 95.3 percent on exact-recall tests against 13.9 and 6.6 percent for summarisation (R230-f2), and 46.9 against 38.1 percent on BCP-Multi (R230-f3)Before RL, summarisation scored 45.2 against GrepMem's 40.9 percent on BCP-Multi (R230-f3); on AMA-Bench GrepMem used 2.3 times summarisation's tokens for a gain that was not significant (R230-f5)Benefits depend on whether summaries drop exact details, and with one model and one RL run per strategy the intervals do not cover training variance, partly the authors' limits and partly this review's reading (R230-f6)The same comparison on several models with repeated training runs and on real agent sessions
Should agents stop sooner?A ship-after-one-clean-review rule cut a run from 18 to 7 minutes (R128-f4); a cost-aware stop rule cut compute 28.9 percent at parity accuracy (R042-f1)A stop hook against premature completion yielded gains of 24.8, 7.3 and 14.0 percent in three Infrathon runs (R086-f4), and 135 of 150 runs set a new best score in the second half of their budget (R086-f1)LangChain's rule stops on a review verdict about the current output (R128-f4) and the Lean router stops when the predicted value of another attempt no longer covers its cost (R042-f5), while the Infrathon gains came from blocking premature completion on 12 or 24 hour AI-infra tasks (R086-f4) (R086-f1); no source tests both kinds of rule on the same tasksOne task set run with and without each kind of stop rule, reporting cost and score

Numbers

ClaimResultValueConditionsWhere in source
(R113-f1)Same-repo repeated tool calls30% vs 7% from other repos60 SWE-Bench tasks, 6 repos, after five earlier tasks; authors' own profilingSec 2.2
(R113-f2)Loaded tools never called; failed runs' share of spend16 of 23; 32% of spend from 17% of tasksSame 60 tasks, one default configuration; authors' profilingSec 2.2, Fig 3
(R113-f5)Mean cost change vs high-effort default-18.4% to -30.9%; Pass@1 up in 4 of 5, -1.0 on Opus 4.8277 tasks, 5 agent-model settings, 3 seeds, controller overhead included, controller terminates stuck rollouts; authors' own, not replicatedSec 4.2, Table 1
(R113-f6)Lower reasoning effortLow: 31% to 45.5% saved; lower effort (low and medium) cut Pass@1 by 1.8 to 10.3 pointsSame tasks and seeds; authors' Table 1Sec 4.2, Table 1
(R113-f7)Ablation savingsTool pruning 13.2% and 17.7%; micro-skills 11.8% and 14.3%; loop guard 7.1% and 5.4%; combined 23.6% and 30.9%Two Claude Code settings only; authors' ablationSec 4.2, Table 2(a)
(R118-f1)Uncached vs cached prompt work5,050 vs 100 units at 100 turnsIdealized arithmetic with equal turns, not a measurement; vendor blogCache is king
(R156-f1)Cached tokens, instructions vs developer message0 vs 10,113GPT-6.2 Sol, 10.1k-token text, two-request test on the OpenCode dev build of 2026-11-13, one user-filed issue, reporter's own numbersOpenCode issue 64550
(R156-f2)Review session cost ratio2.85xGPT-6.2 Sol vs 6.1 Sol reviews, 12,926-token system prompt; reporter's own figureOpenCode issue 64550
(R156-f4)Input cache hit rate46.4% (122 requests) vs 97.4% (13,044)GPT-6.2 Sol vs 6.1 Sol, one client, two days; one reporter, unverified by OpenAICodex issue 62312
(R156-f6)Uncached input per step after fixAbout 14,000 to 3 tokensCopilot gpt-6.2-sol; project release notes, not independently verifiedv2.3.2 release notes
(R246-f6)Tool definitions before first turn50,000 to 70,000 tokensDefault MCP install over 100 tools, one configuration; Uber's estimateCode Mode, Fig 14
(R028-f6)Tool definition size with one toolsetAbout 52,000 to 12,000 charactersAuthor figure in README, not independently measuredREADME
(R246-f5)Without one skill+13% tool calls, 6x tool errors, +31% time; with-skill answer won 87%One warehouse-query skill, Uber's own replay with a blind judgeAblation
(R246-f7)Skill cost leversCheaper worker -46% (tracing), no drop (deployment); load-time script -32%Uber's before-and-after session-cost snapshots on individual skillsLevers section
(R064-f7)Visible skills vs wall time258 s to 451 s for 1 to 20 skills; pass rate 0.55 at 5025-variant routing stress test; ACES authorsACES Sec 6.5
(R085-f3)Router vs strong model alone79.03% at $109.81 vs 77.15% at $148.83Terminal-Bench 2.1, Opus 4.8 and GLM 5.2; vendor-run, run count not stated, listed as earlier benchmarksBenchmarks
(R085-f4)Router vs strong model alone61.36% at $466.28 vs 62.8% at $720.95DeepSWE v1.1, 113 tasks, GPT-5.6 Luna and Sol; vendor-run, three-run means except LunaBenchmarks
(R085-f5)Router savings vs Astra alone22.6% at 72.86% vs 72.27%; 9.2% at 58.60% vs 59.95%DeepSWE v1.1 and SWE-Atlas-QnA, three runs; vendor-runBenchmarks
(R116-f2)Cost per task at equal success$0.05 vs $1.6289.1% each, GPT-6 Luna vs Opus 5.5; Databricks' private benchmark, list-price estimates, task and run counts not statedToken prices section
(R230-f2)Exact-recall accuracy97.4% and 95.3% vs 13.9% and 6.6% (summarisation), 20.7% and 6.6% (masking), 99.9% and 50.0% (MemGPT-style)After RL, Qwen3.5-9B, 32,768-token window, one trained run per strategy; authors' ownSec 5.1, Table 3
(R230-f3)BCP-Multi accuracyAfter RL 46.9% vs 38.1%; before RL 40.9% vs 45.2% (summarisation ahead)828 questions; authors' ownSec 5.1, Table 3
(R230-f5)Tokens relative to summarisation2.3x, gain not significantAMA-Bench stream, 189 trajectories; authors' ownSec 5.1, 5.4
(R032-f1)LLM replaced by decision model4,215 to 897 ms per call; 6,724 to 2,010 tokens per ticket20-label ticket classification on Amazon engineers' own traffic; vendor case studyWhat we measured
(R032-f2)Cost per million ticketsAbout $22,200 to $500List-price arithmetic with assumed headroom, not billed, excludes Lambda; vendorWhat it costs
(R128-f4)Stop rule on a one-pager18 to 7 minutesOne reported example, no sample size; LangChain's ownBrand as code
(R042-f1)Cost-aware stop router-28.9% compute at parity accuracy43-problem PutnamBench test set, 64 seeds, vs fixed-step baseline; authors' evaluationResults
(R086-f4)Stop hook against premature completion+24.8%, +7.3%, +14.0%Three Infrathon runs; benchmark authors' trajectory analysisInfrathon trajectories
(R070-f6)File access vs search tools2.2x (Opus) and 2.6x (DeepSeek) input tokens per correct answer, no better accuracyRetail-1000 and all-task averages; authors' runsSynthCorp
(R110-f2)Rerun after a reuse-rule bug48.0k new tokens and 60 s vs 66.7k and 69 sOne developer's single case study of his own pipelineBlog case study
(R044-f1)Harness token use at similar score0.746 on 3.51M vs 0.744 on 6.29Mgpt-5.4, 75 tasks, six harnesses, context compression disabled; FairyClaw authors' own comparisonFairyClaw Table 3
(R115-f5)Cache reuse when raising concurrency98.3% to 87.5%SWE workload, H20 GPUs, three runs; authors' ownResults tables
(R201-f1)Visible share of output tokensAbout 6% (50% reasoning, 44% tool calls)One engineer's own sessions, sample not statedWhy caching outputs

How this was made

Twenty-four sources were used.

A Sonnet model extracted the claims, each tied to a location in its source. Opus wrote this guide from those claims and the related claims.

How each source was weighted:

Checking the sources found several of our earlier entries wrong, overstated or unverifiable. For example:

Those entries have been corrected at the source.

Sources in this guide

A field guide synthesizes the Research entries it cites. Each claim id links to the entry it comes from.