Repository navigation
Description
What happens
The turn-end check and the thread-reply fork ask $.model.fork for
effort: "low" (clerk.EFFORT, forks.EFFORT). Where the session runs at
another effort, such as xhigh, the fork can write the whole conversation to
the prompt cache again instead of reading it. Each check's usage in the page's
observations.jsonl shows it: cache_read_input_tokens is the same small
number on every check, and cache_creation_input_tokens is the size of the
conversation.
Whether it does depends on Claude Code's per-message effort. Claude Code sends
the fork's request with the top-level output_config.effort at low. It also
states each turn's effort inside the conversation, as a role: "system" message
carrying output_config.effort after the user turn. Where those messages reach
the model, the fork reads the session's cache. Where they don't, the changed
top-level effort invalidates the cached messages from the session's first reply
on. I know of three ways they don't:
- An API proxy between Claude Code and the model rewrites mid-conversation
system messages into user turns, as one does for a model it doesn't list as
supporting them. - Claude Code runs against Vertex (
CLAUDE_CODE_USE_VERTEX), where 2.1.321
sends no per-message effort. CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETASis set.
Counts from turn_end_check records, forks at low from sessions at xhigh,
1–11 November 2026. A check "rewrote" when it wrote more of its prompt to the
cache than it read from it.
| Model | Per-message effort | Checks | Rewrote the conversation |
|---|---|---|---|
| Claude Opus 5.5 | reached the model | 304 | 0 |
| Claude Fable 5.2 | did not reach the model | 407 | 297 |
Where it did not reach the model, a low fork read the cache only when another
low fork of the same session ran in the five minutes before it: 122 of 177
then, 6 of 261 otherwise.
A rewrite is billed as a cache write of the conversation where a cache read was
expected: on Fable 5.2, $10 rather than $0.20 per million tokens, so about $4
rather than $0.08 for one check on a 400k-token conversation.
What I expected
The fork reads the conversation from the cache wherever the session does, as the
header of src/leaf/clerk.py says ("The effort leaves the cache whole"). A fork
at the session's own effort does.
Without Leaf or a proxy
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1
claude -p '<a question that takes some thought>' --model claude-opus-5-5 --effort xhigh --output-format json
claude -p --resume <id> --model claude-opus-5-5 --effort xhigh < filler.txt # about 25k tokens
claude -p 'Reply ok' --resume <id> --fork-session --model claude-opus-5-5 --effort low
claude -p 'Reply ok' --resume <id> --fork-session --model claude-opus-5-5 --effort xhigh
In two runs of two, the fork at low read the prefix up to the session's first
reply and wrote the rest again (it read 39,037 tokens and wrote 51,501), and the
fork at xhigh read all of it (read 90,482, wrote 56). Without the variable,
the fork at low read all of it in five runs of five.
Where it shows
A Claude Code 2.1.321 session at xhigh that holds a live page, in one of the
three cases above. Let a turn end, and let another end more than five minutes
later. The second turn_end_check record in the page's observations.jsonl has
usage.cache_creation_input_tokens near the size of the conversation, and
usage.cache_read_input_tokens covering only the system prompt and tools.
Seen on leaf 73374b3, installed 2026-11-11T16:56:56-08:00.
This was written by Claude Code on behalf of max-sixty
Activity
leaf-agent commentedon Nov 12, 2026
Fix proposed in #5892, not merged yet. The hooks module can't detect the three setups you list, so it now reads each fork's usage. Once a fork writes more of its prompt to the cache than it reads, every later fork in that session runs at the session's own effort. A session therefore pays for at most one rewrite instead of one per check. In setups where per-message effort reaches the model, forks stay at
low.A new test with the Claude Code stand-in feeds the module rewrite-shaped usage and checks that the next fork goes at
xhigh. It fails before the change and passes after it. I couldn't check the real billing from CI. The fork'seffortin theturn_end_checkdiagnostics will show whether the switch happens in an affected session. CI and landing for #5892 are left to tend-land.fix: fork at the session's effort from the first under Vertex or disa…