What Happened to My Tokens?
198 agent spawns ran overnight and half my Codex plan was gone by morning. The culprit was a parent agent that couldn't just wait.
Contents
What Happened to My Tokens?
The Codex $200 plan (20x) was so freeing. For weeks I could barely use half of it. Then one night I moved my full workflow over to Codex, and by morning half the plan was gone.
I’m building meridian-cli, a multi-agent orchestration engine that sits on top of Claude Code, Codex, and OpenCode. Agents spawn agents: a product lead spawns a tech lead, which spawns coders, reviewers, and smoke-testers. Each spawn gets a fresh context window. That night the job was a major architecture refactor, and meridian-cli ran 198 spawns over about eight hours while I slept.
My Codex usage went from about 60% remaining to about 10%.
So I pulled the session data apart. I wrote scripts that read tool-call history from every spawn and estimate its cost at API rates. Three spawns stood out. All three were qa-leads, all ran on Codex, and all cost far more than the work they did.
| Cost | Input tokens | Output | In:Out | Duration | Work item |
|---|---|---|---|---|---|
| $11.10 | 20.9M | 26K | 800:1 | 36 min | test-suite-redesign |
| $4.46 | 7.9M | 20K | ~400:1 | 10 min | windows-compat-audit |
| $3.18 | 5.5M | 25K | 220:1 | 10 min | reaper-escape-fix |
The worst one cost $11.10. It pushed 20.9 million input tokens through GPT 5.4 in 36 minutes and wrote 26,000 tokens of output, an 800:1 ratio. It never delegated to an explorer. It read files itself, spawned 7 coders and 2 reviewers, then spent most of its budget polling for their results: 36 spawn-wait cycles, each one a full round-trip through its context window.
What I Fixed First
I suspected the explorers before I suspected qa-lead.
Explorers are supposed to be the cheap reading layer. Some of mine were compacting over and over, losing their working state, and coming back with reports that looked incomplete. If the reading layer can’t hold on to its own reading, every agent above it pays.
I changed two things. First, explorers now start from synthesized project knowledge instead of raw source: AGENTS.md and .context/CONTEXT.md files colocated with the code, covering architecture, module contracts, and past decisions. I’m not sure the colocated files were essential; a prompt that pointed explorers at my existing knowledge base might have done as well. Second, I tightened the explorer description to one module or one question per spawn. Broad “go understand this area” prompts were exactly how explorers ended up in compaction churn.
The next explorer run cost $0.11, didn’t compact, and wrote a better report. That number flatters it. Keeping the inline context current cost another $0.66 in code-mirror agents, so the fair figure is $0.77. Still cheaper than before.
qa-lead was a suspect too. Codex orchestrators had a habit of spawning a child and then poking around instead of waiting. That’s why the spawn instructions had become blunt: every background spawn must be drained with meridian spawn wait, and when wait yields, call wait again immediately.
Cheaper explorer, tighter scope, explicit wait instructions. I thought that covered it.
The Transcript
The third qa-lead transcript says otherwise. It’s the cheapest of the three outliers, $3.18, and it was already running with the improved explorer. Cleaned up from the raw Codex session log:
┌─ qa-lead (GPT 5.4 on Codex) ─────────────────────────┐
[writes explorer brief to work directory]
[spawns explorer p162 in background]
→ System: "Spawn id: p162. Status: running.
After spawning all subagents, you MUST run:
meridian spawn wait"
[explorer running.]
$ git diff main -- tests/unit/.../test_terminate_scope_sync.py \
tests/unit/.../test_session_scope.py \
tests/unit/.../test_signal_canceller_tree.py \
tests/unit/.../test_process_cleanup_reclaim.py \
tests/unit/.../test_process_cleanup_terminate.py \
tests/integration/.../test_managed_primary_process_scopes.py
$ sed -n '1,220p' src/.../process_scope/__init__.py
sed -n '1,320p' src/.../process_cleanup.py
sed -n '1,260p' src/.../signal_canceller.py
$ sed -n '320,520p' src/.../process_cleanup.py
$ sed -n '1,220p' tests/.../test_session_scope.py
sed -n '1,220p' tests/.../test_terminate_scope_sync.py
sed -n '1,260p' tests/.../test_process_cleanup_reclaim.py
$ sed -n '1,260p' src/.../reaper.py
$ rg "reclaim_session_owned_scopes_for_chat|
cancel_managed_primary|terminate_scope_sync"
tests/ src/
$ sed -n '240,420p' tests/.../test_reaper_cancel.py
$ rg "session_scope|reclaim_session_owned_scopes_for_chat|
terminate_scope_sync" tests/
── 9 commands, all on files the explorer is reading ──
$ meridian spawn wait p162
...
→ p162 succeeded. $0.11, 265 seconds.
$ meridian session log p162 --last 20
── 51,000 tokens of the explorer's session transcript ──
[writes cleanup strategy — closely mirrors explorer]
[spawns reviewer, waits, executes, runs tests]
→ 23 passed, 1022 passed (full suite)
└────────────────────── total: $3.18, 639 seconds ────┘
The system told it to run meridian spawn wait. Instead it ran 9 commands reading the same files the explorer was reading. When it finally waited, it pulled the explorer’s full 51,000-token session transcript instead of the 2,000-token report. Then it wrote a cleanup strategy that closely matched what the explorer had already recommended.
The Explorer Had the Answer
The explorer finished in 265 seconds with a KEEP/DELETE report for all 6 test files. An excerpt:
## tests/unit/platform/test_terminate_scope_sync.py
### Smells
- Wrapper-level dispatch pinning is useful, but most of this file
duplicates tests/platform/test_process_scope_*.
- The null-pgid / windows-job / unknown-containment cases all
collapse into the same fallback behavior.
### Recommendations
- KEEP test_posix_pgid_with_pgid_calls_terminate_pgid
- DELETE test_posix_pgid_with_null_pgid_falls_back_degraded
- DELETE test_windows_job_falls_back_degraded
- KEEP test_pid_tree_fallback_not_degraded
- KEEP test_exception_in_terminator_returns_degraded_result
[... 5 more files, same format ...]
The qa-lead’s 9 commands didn’t change any of these conclusions. For a bounded reading task like this one, GPT 5.4-mini was good enough, and I should be using that lane more.
Explorer
$0.11
265 seconds, no compaction
991K input tokens, read .context/ first
QA-lead
$3.18
639 seconds, 9 redundant reads
5.5M input tokens, 220:1 input-to-output
Fixing the delegate didn’t fix the delegator.
Why Waiting Costs Money on Codex
When a Claude Code agent calls spawn wait, it blocks. One tool call, the agent sleeps, one result comes back when the child finishes.
Codex works request-response. The agent issues a tool call, the harness returns a result, and the model reads its whole context window to decide what to do next. My harness can’t hold that call open, so “wait” is implemented as a loop that yields back to the model every so often, and the model has to choose to wait again. Each yield is a full trip through the context window. Even with 97% cache hits, that adds up: this spawn took 5.5M input tokens to coordinate two children.
Worse, every re-entry is another chance to do something other than wait. Read a file. Check a status. Peek at a transcript. The instruction said “you MUST run: meridian spawn wait,” and the model still had to make that choice fresh each time. Given a big context window and a turn to fill, models find something to do.
This isn’t Codex’s fault. Claude Code’s tool-call model makes blocking waits natural. Codex’s doesn’t, and I hadn’t built the workaround.
The prompt fixes helped enough that I thought the problem was handled. They can’t close it. As long as the harness keeps handing the turn back to the model, the model keeps getting chances not to wait. If waiting matters, the system should do the waiting.
What I Changed
After this audit I moved qa-lead’s default from GPT 5.4 on Codex to Sonnet on Claude Code. I haven’t run the clean A/B yet (same qa-lead task, same inputs, different harness), so this is a bet on the failure mode: if the expensive part was re-entering the model to wait, a harness with a native blocking wait should remove it.
The closest thing I have to evidence is a tech-lead from the same work item:
Tech-lead (Claude harness)
$3.27
10 children coordinated
Native blocking wait, one tool call
QA-lead (Codex harness)
$3.18
2 children coordinated
Polling wait, 5.5M input tokens total
The tech-lead ran on Claude, coordinated 10 child agents across 5 implementation phases, caught findings, ran a corrective phase, and shipped for $3.27. The qa-lead coordinated 2 children for $3.18. They were doing different jobs, so this isn’t a controlled comparison. It does show what coordination costs when waiting actually blocks.
What I’m Building Next
The real fix belongs in the harness. Today meridian spawn wait is a CLI polling loop: it watches spawn state and yields a checkpoint to the parent while children are still running. Each checkpoint re-enters the parent model.
The streaming backends already keep live executions around: Codex through its app-server WebSocket, OpenCode through HTTP/SSE, and Claude Code through stream-json. So Meridian can hold the wait itself. It watches the child spawns and, when they finish, injects the result into the parent as its next user message. No polling loop in the parent’s context, and no turns handed back to the model just so it can decide to keep waiting.
That removes the re-entry that made the Codex qa-lead expensive. Whether the qa-lead actually gets cheaper still needs a clean run.
The Bill a Subscription Hides
With the parser open, I ran it over everything. Across 10,895 sessions in three months, my agent work would have cost about $17,200 at API rates. I didn’t pay that; it ran through a mix of subscriptions with changing limits. But it’s a useful number to know when one night can eat half a plan.
The file-read side of this is in 75% of LLM Reads Are Redundant: 50,319 redundant reads across 4,339 sessions, compaction loops, and the per-model and per-role breakdowns.
198 spawns across Claude Code and Codex, May 10–11, 2026. Analysis scripts are on GitHub. An earlier version of this note double-counted Codex cache-read tokens; the costs above are corrected.