AI Engineering / Field study / Context budgets

Measuring Context Costs in an Orchestrator-and-Subagent Workflow

The subagents got cheap and the orchestrator became the whale. Three months of Anthropic's published context guidance on one repository, every session and every subagent transcript measured. The saving landed where the guidance says it does. The cost moved somewhere it does not name.
389 Sessions in August
Two columns
One instrument
01 / June to August

In June I ran Claude Code the way the tool invites you to. One session, open all day, the best model available, keep going until the work was done. By August the same repository logged 389 sessions, and 94.6% of its agent calls went to Haiku and Sonnet specialists with hard return budgets, and a hook was ending sessions at a token line I had set in advance.

The guidance that got me there is published. Isolate exploration in subagents. Keep the main context small. Restart instead of stretching a session. Put persistent rules in files and hooks. I ran them for three months on one repository and measured every session and every subagent transcript against them, with a script that reads the transcript files Claude Code already keeps on the machine.

The question I wanted answered was where the cost of an agent sits once the fan-out is already cheap.

02 / The measurement was wrong before it was right

My first pass summed every assistant line in the transcript files and produced a table I nearly published. Claude Code writes one assistant message as several lines, one per content block, and every line repeats the same cumulative usage block. In August, 53% of main-session lines and 56% of subagent lines shared a message id and request id with another line. Every sum in that table was inflated by 50 to 70%.

The peak-context rows and the call counts were untouched, which is the tell: sums double-count, maxima cannot. The fix is four lines. Deduplicate on that key and keep the last record, since output tokens grow across blocks. ccusage keys on the same pair, independent confirmation that the measurement was fixed.

Everything below comes from the corrected scan, frozen on the second of September with August closed.

Figure 01 / Sum vs peak
One message, many linesAugust 2026 / deduplicated on message id + request id
REPEATED PAYLOAD ONE ASSISTANT MESSAGE / SEVERAL LINES TEXT BLOCK SAME USAGE BLOCK TOOL BLOCK SAME USAGE BLOCK THINKING BLOCK SAME USAGE BLOCK TEXT BLOCK SAME USAGE BLOCK SUM COUNTS EACH LINE MAXIMUM HOLDS ONE MESSAGE KEY (MESSAGE.ID, REQUESTID) / KEEP LAST LINE AUGUST 2026 / OBSERVED COUNTS LINES WITH USAGE DEDUP MESSAGES MAIN CONVERSATION Main conversation: 32,297 lines carrying a usage block 32,297 LINES Main conversation: 15,014 messages after deduplication 15,014 MESSAGES SUBAGENTS Subagents: 39,726 lines carrying a usage block 39,726 LINES Subagents: 17,544 messages after deduplication 17,544 MESSAGES MAIN / 53% SHARED A KEY SUBAGENTS / 56% SHARED A KEY
Claude Code writes one assistant message as several transcript lines, one per content block, and each line repeats the same cumulative usage block. Summing lines counted the August main conversation as 32,297 records where there were 15,014 messages, and the subagents as 39,726 where there were 17,544. Keying on message id and request id and keeping the last line of each message gives the true count.Source: the frozen scan of 2026-09-02, contextbudget --by month --project brainOS
03 / What a long session costs

An audit I ran at the start of July found my sessions at 660k to 999k tokens of context. The statusline that should have warned me only renders in the terminal CLI. The VS Code extension, where I did most of that work, never shows it. I had a threshold and nowhere for it to appear.

The fix was to take the warning off the screen and put it in the harness. A hook reads the tail of the transcript on every prompt and injects the warning as context the model itself sees, at 100k and 150k absolute tokens rather than a percentage of the window, because a million-token window earns no extra headroom. A rule a human reads is advice. A rule a hook injects is enforced.

The rule that did the most work has nothing to do with context pressure. Finish the task, write the handoff while the session is still sharp, start fresh. A handoff written at a fifth of the window comes from a sharp session; one written at two thirds comes from the most degraded version of it. Tokens billed to the frontier model in the main conversation, input plus output plus cache writes after deduplication, fell from 850,251 per session in June to 185,156 in August, and the share of sessions whose peak context crossed 150k fell from 55% to 33%.

Peaks caught what sums could not. One August session reached 571k tokens because a single pasted image was re-sent on every turn after it. The sum metrics never flagged it. The peak-context column did, the same day.

04 / What a delegate returns

Delegation only paid after the return format became a contract the subagent reads at point of use. Before that my specialists explored cheaply and then returned the transcript of their exploration, which landed in the orchestrator's context as paste. The saving re-entered as a cost one turn later. Delegation does not save context if the delegate returns its working set.

Each of the five specialists I run now carries a line cap, 15 to 20 lines, and an overflow rule: never paste file bodies; if a file matters, say why and where, and the caller opens it. The contract lives in the agent definition, so it is read at the moment the agent answers. A contract in my head is a suggestion.

The failure on the other side is a stalled delegate. One stuck measurement agent pulled roughly forty retrieval calls back into the frontier-priced main thread and pushed that session past 150k in one task. The rule that came out of it: re-spawn once with a tighter prompt before any retrieval falls inline.

05 / Where the cost actually sits

Here is the number that cut against the story. 83.5% of August sessions still crossed 100k tokens of context, up from 70.7% in June, in the same month the 150k share fell by a third. Sessions got shorter and more numerous by design, and the ones that stayed long were long on purpose.

The token split explains it. In August the subagents did 56.4% of all input, output and cache-write tokens, up from 16.5%, while the main conversation held 82.2% of the price at list rates. Both numbers are true at once. Token share and price share had separated, and the second explains the first. Cheap models absorbed the token majority at Haiku and Sonnet prices, which is exactly what leaves the frontier-priced main thread carrying the spend.

The Anthropic guidance I found describes the window saving from delegation. I did not find the next question addressed: once the fan-out is cheap, where does the remaining cost concentrate? For one operator's workflow it sits in the main conversation: tool results, re-reads of files already in the window, and long autonomous turns pulling their own output back into context. The month I audited re-reads, one file was opened about twice a session because opening it felt like diligence. That habit alone was about a million and a half tokens.

Figure 02 / Tokens vs price
Subagent share of tokens vs share of priceJune to August 2026 / all scopes
SUBAGENT SHARE BY MONTH TOKENS / INPUT + OUTPUT + CACHE WRITES LIST-PRICE PROXY 60% 0% June 2026: subagent share of tokens, 16.5% 16.5% June 2026: subagent share of the list-price proxy, 5.6% 5.6% July 2026: subagent share of tokens, 32.6% 32.6% July 2026: subagent share of the list-price proxy, 9.1% 9.1% August 2026: subagent share of tokens, 56.4% 56.4% August 2026: subagent share of the list-price proxy, 17.8% 17.8% JUNE 2026 58 SESSIONS JULY 2026 429 SESSIONS AUGUST 2026 389 SESSIONS
By tokens the subagents did most of the work by August, 56.4% of all input, output and cache-write tokens, up from 16.5% in June. By list price they held 17.8%, up from 5.6%. Haiku and Sonnet took the token majority at their own prices, so the main conversation still held 82.2% of the August price.Source: the frozen scan of 2026-09-02, contextbudget --by month --project brainOS
06 / Someone arrived at the same axis from the inside

In September Anthropic published commerce-agents, a reference blueprint for shopping and merchant agents. Its config carries a maximum of eight tool iterations, and the last iteration sets tool choice to none so the model has to answer in text. History compacts above 100,000 tokens. A clamp helper caps any count the model supplies at a ceiling. The memory tool caps a stored fact at 64 characters of key and 200 of value, in the tool schema and again at runtime.

Those are context budgets enforced in code, with defaults someone had to choose, in a blueprint meant to be copied. I spent three months arriving at the same axis from the outside by measuring my own transcripts. The numbers above are what the budget looks like when nobody has set one for you.

07 / Limits

What this does not show

Three changes landed together in the window, the restart rule, the return contracts and the context hook, so the two columns are a shift in shape rather than a controlled experiment. Per session is a poor unit when sessions shrink by design; the threshold rows are per session by construction and are the cleaner signal.

The dollar figures are a list-price proxy for one developer on a subscription, so the ratios hold and the totals do not. Quote the token figures. Peak context is a definition choice, input plus cache writes plus cache reads; drop the cache reads and the threshold shares move by about a point.

When the records repeat, trust the peak before the sum.
08 / Practice

Measure peaks rather than sums, and deduplicate before you believe either. Give every delegate a return budget it reads at the moment it answers. Put your thresholds in a hook rather than on a statusline. And treat any workflow you have not measured as pending.

The script is MIT, standard library only, and reads the transcripts already on your machine: github.com/jfkconstruct/contextbudget. The full report, with the assumptions and the parts that did not hold, is in the repo.