[BUG] v2.1.290: --resume on opus-5-5/sonnet-5-5 re-writes the whole history to the prompt cache every time (haiku unaffected)
Summary
On Claude Code v2.1.290, every --resume of a headless (-p) session on claude-opus-5-5 and claude-sonnet-5-5 reads only the system+tools prefix from the prompt cache and re-writes the entire conversation history as cache_creation_input_tokens. This happens on every resume, with or without a gap, and with both the 5-minute and the 1-hour TTL. On claude-haiku-4-5, the same resumes read the whole prior context from cache as expected.
This looks like the system-block scatter behaviour reported in #43657 and refiled as #67497. Both were closed as not-planned by inactivity sweeps. It is still present, so here are fresh numbers.
Measurements (per-call usage, not total_cost_usd, which is session-cumulative on resume)
| Model | Resume | cache_read | cache_creation |
|---|---|---|---|
| haiku-4-5 | turn 30, no gap | 153,194 | 4,855 (only the new turn) |
| opus-5-5 | turn 6, no gap, 5m TTL | 988 | 39,126 (whole history) |
| opus-5-5 | turn 6, no gap, 1h TTL | 988 | 39,188 |
| sonnet-5-5 | each resume | ~950 | whole history |
Positive control: an identical fresh dispatch of the same first prompt reads it all from cache on the same models (opus: 21,972 of 21,974; sonnet: 21,621 of 21,623). Inside one process, a tool-use loop also reads the earlier call's prompt. So caching works on these models, and the miss is specific to the resumed history.
Ruled out
--agent/--agents: also reproduces on a bareclaude -p.- MCP: reproduces with
--strict-mcp-configand no servers. - Extended thinking: reproduces with
MAX_THINKING_TOKENS=0. - Effort mismatch (#66005): passing
--effort highon the first turn and on every resume still gives the same miss (opus, each resume[read 12,196, create ~22k]). Dropping user settings via--setting-sources project,localalso does not help.
Repro
claude -p --model claude-opus-5-5 --output-format stream-json --verbose "<~20k-token prompt>" # note session_id
claude -p --model claude-opus-5-5 --output-format stream-json --verbose --resume <session_id> "next message"
# compare the resume's result usage: cache_read_input_tokens ≈ system+tools only
The same two commands with --model claude-haiku-4-5 read the full prior context on resume.
Impact
A process-per-turn orchestrator that resumes an opus session 30 times, with the context growing to about 158k, pays a full history write on every resume. We estimate about $12.50–$20, against about $1.50 if resume caching worked (derived from the measured per-resume rows). Recall across resumes was perfect (60 checks up to 158k), so correctness is fine; only cost is affected.
Linux, Claude Code 2.1.290.