Token saver strategy (agents)

Measured on two long self-hosting agents (2026-10-11, #125): 695 and 768 turns, 219 M and 276 M context tokens read, 6-7 k tokens written. What costs is not the output but the prefix every turn re-reads.

Fact Number
Context at start (system prompt, skills, CLAUDE.md) about 49 k
Growth per turn about 750 tokens
Share of the cost at context > 300 k 71-78 %
Context at the end 566-626 k
Same work, agent restarted every 120 turns (computed) about one third
What fills the context tool results 630-770 KB, thinking 520-555 KB, tool calls (inline scripts) 410-440 KB
Short Opus planning agents 72-159 turns, about 100-130 k, 7-21 M in all

What to measure: tokens per moved line, guarded by turns

Chain: research agent, then builder

The supervisor’s own context is the most expensive one: it lives the whole session. So it does not read the plan, the call graph or the Rust itself.

  1. A research agent (builder type, told not to edit or commit) reads the plan’s section (docs/selfhosting-plan.md), the call graph (scripts/c6/cg.py) and the Rust of the slice, and writes a brief of at most 80 lines to a file in the scratchpad: the functions in order, the callees not yet in Nikaia, the defects it expects. It reports the path and five lines.
  2. The builder gets the path to the brief and the steps, nothing else.
  3. The supervisor reads only the two reports.

Compiler defects first

A lowering or checker defect that a slice meets is fixed in the compiler, in its own commit or by its own agent, before the slice goes on (owner’s direction: no workaround). A builder that meets one stops and reports it with a probe; it does not route around it, which costs more turns than the fix.

No parallelism for now

One builder at a time (owner’s direction, 2026-10-24): first see what the rules above bring in the Runs table, then decide on more agents at once.

Rules

Measured again (2026-10-17, ten build agents)

Fact Number
Context at start 52 k, of it about 35-40 k the descriptions of 41 tools a builder never calls (remote sessions, artifacts, docs)
Growth per turn about 1 k
Growth, by kind about half thinking, a quarter to a third tool results (grep, sed/cat, git), the rest tool calls
Turns 63-357; seven of ten past 200
Share of the cost after turn 120 52-79 % for the long ones
Turns spent polling a build or a test 10-20 % of the cost

So: build agents are the builder type (.claude/agents/builder.md, six tools, the limits above in its prompt); a task names one or two steps of a To build list, not the whole list; waiting is one call.

Orchestrator

This site is open source. Improve this page.