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 |
scripts/tokenspeed.nika, the scripts/self_hosting.py line rule). Measured
so far: long agents 143 k, restarted ones 71 k, a clean slice 37-54 k, an
entangled one 88-164 k. The target is below 50 k. A slice that moves no
Rust (a compiler fix, a plan) is not given a figure; its value shows in the
slices after it..claude/agents/builder.md); the supervisor, who
can see the transcript, checks the context (about 200 k).nikaia run scripts/tokenspeed.nika -- --short AGENTS_DIR prints one Markdown row (the
latest agent, counted only over the commits of its window); the supervisor
appends it to the Runs table in docs/tokenspeed.md. The full tables are drawn only for a dated snapshot.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.
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.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.
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.
docs/selfhosting-plan.md). Never resume an
agent for a second slice: its context is what costs.CLAUDE.md, the plan file, the last commit message), not in the
prompt, and not in issue comments. Do not make every agent read issue
threads (19-30 KB each): the orchestrator summarises them in two lines.scripts/ keeps the
ones worth sharing.git -C, absolute paths),
chain what depends on nothing into one call, no cd x && ... per call
(386 of them in one agent). Independent tool calls go in one message.grep -n first, then sed -n of at most 150 lines; never
a whole 15 k-line file; grep -c or head for counts; cargo with
--message-format short, test output filtered to the failures.supervisor.md, Briefs and reports).target/release/nikaia-scratch after each test run;
keep target/nikaia-project-tests (the compiler prunes it to
NIKAIA_CACHE_LIMIT, set 4G) unless the disk has under 3 GB free; no two full test runs
at once (disk, and the same machine).| 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.
builder; give each one or two steps.Watch each running agent’s transcript (turns, context); past about 150 turns or 200 k tokens tell it to push what is verified and report.
nikaia run scripts/tokenspeed.nika -- --short, one row into
docs/tokenspeed.md.git status and git diff.CHANGELOG.md and badges collide between agents: tell each to
take upstream’s number after the rebase and re-run scripts/badges.py.