You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A fork's change of effort rewrites the prompt cache on backends without per-message effort, such as Vertex #5904
The turn-end check and the thread-reply fork ask $.model.fork for effort: "low" whatever the session's effort (clerk.EFFORT, forks.EFFORT).
A fork at another effort than its session's reads the session's prompt cache
only where Claude Code sends per-message effort, and it doesn't on every
backend. On Vertex (CLAUDE_CODE_USE_VERTEX), Claude Code 2.1.321 sends none,
so there the fork's change of effort writes the conversation to the cache
again, on every model.
Since #5891, once a turn-end check writes more than it reads, the hooks module
makes the session's later forks at the session's effort (runFork). On a
backend that never carries a change of effort, that leaves two costs:
The first check after each start or resume of a session rewrites the
conversation: at 300k tokens, $1.50 on Opus 5.5 and $3.00 on Fable 5.2, where
the read costs $0.06.
Every later fork thinks at the session's effort, so no fork there gets low's shorter output and time.
Without Leaf, in headless sessions on Vertex at xhigh, a resumed turn at low read 28k tokens of an 80k prompt and wrote the rest in 6 runs of 6 (three
each on Opus 5.5 and Fable 5.2). At xhigh it read the whole prompt in 6 of 6.
No turn-end check has run on Vertex here yet, so the two costs above are read
from the code rather than from a page's records.
What I expected
On a backend where a change of effort can't keep the cache, Leaf asks for none:
every fork runs at the session's effort from the first, without one rewritten
conversation per session to find that out.
Smallest repro
export CLAUDE_CODE_USE_VERTEX=1 # plus the Vertex project and region
claude -p '<a question that takes some thought>' --model claude-opus-5-5 --effort xhigh --output-format json
claude -p --resume <session id> --model claude-opus-5-5 --effort xhigh --output-format json < filler.txt # about 25k tokens
claude -p 'Reply with the single word: ok' --resume <session id> --model claude-opus-5-5 --effort low --output-format json
The third call's cache_read_input_tokens covers the system prompt and tools,
and its cache_creation_input_tokens is the rest of the conversation. With --effort xhigh on the third call it reads all of it.
Fix proposed in #5905, not merged yet. The hooks module already reads Claude Code's environment, so it now checks CLAUDE_CODE_USE_VERTEX and CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS when it first learns the session's process. Where either is set, every fork in that session runs at the session's effort from the start, so it never rewrites the conversation to find that out. A proxy doesn't show up in any variable, so the usage check from #5892 stays as the fallback for that case. Bedrock isn't on the list, because nothing here shows whether it carries per-message effort.
A new test sets each variable in the stand-in Claude Code and checks that the first turn-end fork goes at xhigh. It fails before the change and passes after it. CI can't reach Vertex, so the cache saving still rests on your measurements. CI and landing for #5905 are left to tend-land.
Activity
leaf-agent commentedon Nov 12, 2026
Fix proposed in #5905, not merged yet. The hooks module already reads Claude Code's environment, so it now checks
CLAUDE_CODE_USE_VERTEXandCLAUDE_CODE_DISABLE_EXPERIMENTAL_BETASwhen it first learns the session's process. Where either is set, every fork in that session runs at the session's effort from the start, so it never rewrites the conversation to find that out. A proxy doesn't show up in any variable, so the usage check from #5892 stays as the fallback for that case. Bedrock isn't on the list, because nothing here shows whether it carries per-message effort.A new test sets each variable in the stand-in Claude Code and checks that the first turn-end fork goes at
xhigh. It fails before the change and passes after it. CI can't reach Vertex, so the cache saving still rests on your measurements. CI and landing for #5905 are left to tend-land.feat: remember per backend whether a fork's change of effort keeps th…
Load the Claude Code module again, and learn a fork's cache rewrite f…