Repository navigation
fix(agents): scope append-only runtime context to prefix-binding Claude models - #136990
Conversation
…de models Append-only runtime-context replay (persisted carriers, retained inline inbound metadata, no consecutive-user merge on the Messages API) exists because Claude Fable 5.1 binds thinking to the exact request prefix. It was enabled for every Anthropic-family route, so Opus 5, Sonnet 5, Opus 4.8, Sonnet 4.6 and Haiku 4.5 sessions paid for persisted carriers on every later request (cache-read billing plus context) without any prefix to protect. - Add `bindsClaudeThinkingPrefix` to the llm-core Claude contracts (Fable 5.1 and Mythos 5.1 identities, including cloud ids and canonical deployment metadata) and derive `appendOnlyRuntimeContext` from it in the core fallback and the shared Anthropic replay helpers; GitHub Copilot stays transient. Non-binding Claude models return to transient carriers and normal user-turn merging. - Next-turn carriers now carry only the delimited context body. The shared instruction (runtime context for the user request it follows, not user-authored, keep internal details private, continue without waiting) moves once into the stable system prompt prefix for every provider, so it is cached instead of re-sent per turn. Runtime-event prefaces are unchanged; historical prefaced carriers are still stripped from user-visible surfaces. - Docs: anthropic provider page, transcript hygiene, system prompt. Live proof on a recording proxy with drop_block binding controls: an Opus 5 session merged consecutive user turns and kept its model-switch carrier transient; a Fable 5.1 session switched to Opus 5 and back, then ran three more turns with tool loops while the persisted compact carrier stayed in place, thinking blocks accumulated (1 -> 3) and every response reported input_transformations: [].
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 3, 2026, 2:10 AM ET / 06:10 UTC. ClawSweeper reviewWhat this changesThe PR limits persistent runtime-context carriers to prefix-binding Claude Fable 5.1 models and makes other Anthropic-family replays transient again, with the carrier guidance moved into the stable system prompt. Regression provenancePossible regression — probable (reviewed change; known regression link). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 1 item remains No blocking correctness findings. This active member PR is still necessary: current main retains append-only runtime context for all Anthropic-family models, while this branch scopes it to the proven Fable 5.1 identity. Priority: P2 Review scores
Verification
How this fits togetherThe embedded agent runner assembles transcript history and a provider replay policy before every model request. The policy determines whether hidden runtime metadata remains in subsequent requests, affecting signed-thinking validity, context size, and prompt-cache use. flowchart LR
A[User turn or runtime event] --> B[Embedded agent runner]
B --> C[Transcript replay policy]
C --> D{Claude thinking prefix-bound?}
D -->|Fable 5.1| E[Keep carrier in place]
D -->|Other models| F[Use transient carrier]
E --> G[Provider request]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +29, Tests +228, Docs +12, Other +1. Total +270 across 29 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one Fable-only identity predicate as the replay-policy source of truth, retaining append-only history only where signed thinking requires it and transient carriers everywhere else. Do we have a high-confidence way to reproduce the issue? Yes: current main’s unconditional append-only policy and this branch’s Fable-only predicate make the affected replay selection directly traceable in source. This read-only review did not rerun the live provider scenario. Is this the best way to solve the issue? Yes: the change centralizes the decision in one normalized model predicate and routes both core fallback and provider families through it, avoiding divergent per-provider rules. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 53066564532e. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
…ct carriers in e2e `bindsClaudeThinkingPrefix` now covers only the Fable 5.1 identity. Mythos 5.1 is not registered in the bundled Anthropic catalog and has no live replay proof, so it keeps transient carriers and normal user-turn merging like every other non-Fable model; extending the predicate requires live proof for the new model. Predicate, transcript-policy, replay-helper and provider plugin tests assert the narrowed set. The qa-lab gateway RPC chat e2e test still imported the removed next-turn carrier preface; its carrier filter now matches the delimiter-only shape.
|
Rank-up move applied: Also fixed the |
|
On the compatibility note: the transition for existing non-Fable Claude sessions is intended, and it is the safe direction. Since #136782 landed (hours ago) those sessions have been persisting |
|
Merged via squash.
|
…de models (openclaw#136990) * fix(agents): scope append-only runtime context to prefix-binding Claude models Append-only runtime-context replay (persisted carriers, retained inline inbound metadata, no consecutive-user merge on the Messages API) exists because Claude Fable 5.1 binds thinking to the exact request prefix. It was enabled for every Anthropic-family route, so Opus 5, Sonnet 5, Opus 4.8, Sonnet 4.6 and Haiku 4.5 sessions paid for persisted carriers on every later request (cache-read billing plus context) without any prefix to protect. - Add `bindsClaudeThinkingPrefix` to the llm-core Claude contracts (Fable 5.1 and Mythos 5.1 identities, including cloud ids and canonical deployment metadata) and derive `appendOnlyRuntimeContext` from it in the core fallback and the shared Anthropic replay helpers; GitHub Copilot stays transient. Non-binding Claude models return to transient carriers and normal user-turn merging. - Next-turn carriers now carry only the delimited context body. The shared instruction (runtime context for the user request it follows, not user-authored, keep internal details private, continue without waiting) moves once into the stable system prompt prefix for every provider, so it is cached instead of re-sent per turn. Runtime-event prefaces are unchanged; historical prefaced carriers are still stripped from user-visible surfaces. - Docs: anthropic provider page, transcript hygiene, system prompt. Live proof on a recording proxy with drop_block binding controls: an Opus 5 session merged consecutive user turns and kept its model-switch carrier transient; a Fable 5.1 session switched to Opus 5 and back, then ran three more turns with tool loops while the persisted compact carrier stayed in place, thinking blocks accumulated (1 -> 3) and every response reported input_transformations: []. * fix(agents): limit prefix-binding replay to Fable 5.1 and match compact carriers in e2e `bindsClaudeThinkingPrefix` now covers only the Fable 5.1 identity. Mythos 5.1 is not registered in the bundled Anthropic catalog and has no live replay proof, so it keeps transient carriers and normal user-turn merging like every other non-Fable model; extending the predicate requires live proof for the new model. Predicate, transcript-policy, replay-helper and provider plugin tests assert the narrowed set. The qa-lab gateway RPC chat e2e test still imported the removed next-turn carrier preface; its carrier filter now matches the delimiter-only shape. * test(agents): expect merged user turns for non-binding Claude replay
…de models (#136990) * fix(agents): scope append-only runtime context to prefix-binding Claude models Append-only runtime-context replay (persisted carriers, retained inline inbound metadata, no consecutive-user merge on the Messages API) exists because Claude Fable 5.1 binds thinking to the exact request prefix. It was enabled for every Anthropic-family route, so Opus 5, Sonnet 5, Opus 4.8, Sonnet 4.6 and Haiku 4.5 sessions paid for persisted carriers on every later request (cache-read billing plus context) without any prefix to protect. - Add `bindsClaudeThinkingPrefix` to the llm-core Claude contracts (Fable 5.1 and Mythos 5.1 identities, including cloud ids and canonical deployment metadata) and derive `appendOnlyRuntimeContext` from it in the core fallback and the shared Anthropic replay helpers; GitHub Copilot stays transient. Non-binding Claude models return to transient carriers and normal user-turn merging. - Next-turn carriers now carry only the delimited context body. The shared instruction (runtime context for the user request it follows, not user-authored, keep internal details private, continue without waiting) moves once into the stable system prompt prefix for every provider, so it is cached instead of re-sent per turn. Runtime-event prefaces are unchanged; historical prefaced carriers are still stripped from user-visible surfaces. - Docs: anthropic provider page, transcript hygiene, system prompt. Live proof on a recording proxy with drop_block binding controls: an Opus 5 session merged consecutive user turns and kept its model-switch carrier transient; a Fable 5.1 session switched to Opus 5 and back, then ran three more turns with tool loops while the persisted compact carrier stayed in place, thinking blocks accumulated (1 -> 3) and every response reported input_transformations: []. * fix(agents): limit prefix-binding replay to Fable 5.1 and match compact carriers in e2e `bindsClaudeThinkingPrefix` now covers only the Fable 5.1 identity. Mythos 5.1 is not registered in the bundled Anthropic catalog and has no live replay proof, so it keeps transient carriers and normal user-turn merging like every other non-Fable model; extending the predicate requires live proof for the new model. Predicate, transcript-policy, replay-helper and provider plugin tests assert the narrowed set. The qa-lab gateway RPC chat e2e test still imported the removed next-turn carrier preface; its carrier filter now matches the delimiter-only shape. * test(agents): expect merged user turns for non-binding Claude replay (cherry picked from commit de7518b)
* fix(agents): scope append-only runtime context to prefix-binding Claude models (#136990) * fix(agents): scope append-only runtime context to prefix-binding Claude models Append-only runtime-context replay (persisted carriers, retained inline inbound metadata, no consecutive-user merge on the Messages API) exists because Claude Fable 5.1 binds thinking to the exact request prefix. It was enabled for every Anthropic-family route, so Opus 5, Sonnet 5, Opus 4.8, Sonnet 4.6 and Haiku 4.5 sessions paid for persisted carriers on every later request (cache-read billing plus context) without any prefix to protect. - Add `bindsClaudeThinkingPrefix` to the llm-core Claude contracts (Fable 5.1 and Mythos 5.1 identities, including cloud ids and canonical deployment metadata) and derive `appendOnlyRuntimeContext` from it in the core fallback and the shared Anthropic replay helpers; GitHub Copilot stays transient. Non-binding Claude models return to transient carriers and normal user-turn merging. - Next-turn carriers now carry only the delimited context body. The shared instruction (runtime context for the user request it follows, not user-authored, keep internal details private, continue without waiting) moves once into the stable system prompt prefix for every provider, so it is cached instead of re-sent per turn. Runtime-event prefaces are unchanged; historical prefaced carriers are still stripped from user-visible surfaces. - Docs: anthropic provider page, transcript hygiene, system prompt. Live proof on a recording proxy with drop_block binding controls: an Opus 5 session merged consecutive user turns and kept its model-switch carrier transient; a Fable 5.1 session switched to Opus 5 and back, then ran three more turns with tool loops while the persisted compact carrier stayed in place, thinking blocks accumulated (1 -> 3) and every response reported input_transformations: []. * fix(agents): limit prefix-binding replay to Fable 5.1 and match compact carriers in e2e `bindsClaudeThinkingPrefix` now covers only the Fable 5.1 identity. Mythos 5.1 is not registered in the bundled Anthropic catalog and has no live replay proof, so it keeps transient carriers and normal user-turn merging like every other non-Fable model; extending the predicate requires live proof for the new model. Predicate, transcript-policy, replay-helper and provider plugin tests assert the narrowed set. The qa-lab gateway RPC chat e2e test still imported the removed next-turn carrier preface; its carrier filter now matches the delimiter-only shape. * test(agents): expect merged user turns for non-binding Claude replay (cherry picked from commit de7518b) * fix(anthropic): preserve cache reuse across transient runtime context (#140621) Anthropic tool loops could repeatedly write growing conversation history to the prompt cache because a moving runtime-context carrier owned the checkpoint. Use the existing replay lifecycle contract to exclude transient carriers from both request builders while preserving retained anchors. Also omit empty beta headers that caused direct API requests with thinking disabled to fail. Add deterministic regression coverage and a packaged Docker test that verifies real cache reads and incremental writes across two tool continuations and a new user turn in both builders. Require that lane in stable/full release validation, with explicit API-key preflight, no request retries, and a declared runtime entry for dependency analysis. Validation includes focused package/model/session and workflow tests, build and package integrity checks, static checks, independent review, mock Docker, and eight successful live Anthropic Docker requests. Hosted CI run 34379052492 passed on the final PR head at attempt 2, after one unchanged browser-animation rerun. Closes #140607 Thanks to @LightningWareLLC for reporting the regression and contributing the lifecycle-aware cache repair. Co-authored-by: LightningWareLLC <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> (cherry picked from commit faaf4b0) * fix(anthropic): bind cache carriers to replay policy * fix(release): qualify prefix-bound anthropic replay * fix(github-copilot): keep replay context transient --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: LightningWare LLC <[email protected]> Co-authored-by: LightningWareLLC <[email protected]>
What Problem This Solves
#136782 made Anthropic-family routes replay runtime context append-only: the hidden per-turn carrier is persisted right after its user turn, earlier carriers and inline inbound metadata stay in place, and consecutive user turns are no longer merged on the Messages API. That is required for Claude Fable 5.1, whose thinking blocks are bound to the exact request prefix. It was enabled for every Claude model, so Opus 5, Sonnet 5, Opus 4.8, Sonnet 4.6 and Haiku 4.5 sessions kept every historical carrier in context and paid the prompt-cache read rate for it on every later request, with nothing to protect (their thinking survives prefix changes, verified live in #136782). Each carrier also repeated a ~60-token preface explaining the markers, on every turn, for every provider.
Why This Change Was Made
bindsClaudeThinkingPrefix(the Fable 5.1 identity, including Bedrock/Vertex ids andcanonicalModelIddeployment metadata; Mythos 5.1 stays out until it is registered and its binding is proven, as agreed in fix(anthropic): Fable 5.1 sessions lose reasoning after model switches and runtime events #136782) drivesappendOnlyRuntimeContextin the core transport fallback and the shared Anthropic replay helpers.buildStrictAnthropicReplayPolicytakes an explicit option (default off) so GitHub Copilot, which strips thinking anyway, stays transient. Non-binding Claude models return to transient carriers and normal user-turn merging; Bedrock Converse keeps merging for every model as before.OPENCLAW_*name budget ratchets down by one.Production delta: +50/-21 (predicate, option plumbing, the prompt section); tests +323/-90; docs +27/-15.
User Impact
Docs:
docs/providers/anthropic.md,docs/reference/transcript-hygiene.md,docs/concepts/system-prompt.md.Evidence
Unit and contract coverage (all failing before the change for the intended reason): llm-core predicate table; transcript-policy scoping across
anthropic-messagesandbedrock-converse-streamfor anthropic, amazon-bedrock and custom-proxy providers plus Foundry canonical deployment identity; replay-helper scoping for the by-model, native and hybrid helpers; provider plugin replay policies (anthropic, amazon-bedrock, anthropic-vertex, minimax, github-copilot); carrier rendering, detection and leak stripping; transient replay of a transcript that already holds persisted carriers; the system-prompt instruction present once, byte-identical across builds and above the cache boundary. Prompt snapshots regenerated with no committed diff.node scripts/check-changed.mjsgreen (typecheck, lint, assertion ratchet, dead-export scan, SDK surface, import cycles).Live, on a recording proxy in front of
api.anthropic.comwithprefix_mismatch_behavior: drop_blockinjected so server-side drops would be visible:/model … -s,/think max, two tool turns): the two command turns were merged into one user message, the model-switch carrier was sent only in its own turn (compact body, no preface) and was not persisted; the next turn's history had no carrier.input_transformations: []on all three requests./think max, tool turn, switch to Opus 5, tool turn, switch back, three more turns incl. tool loops): the switch-back carrier was persisted immediately after its user turn as the delimited body only and stayed in place across all later requests; consecutive user turns stayed separate; thinking blocks accumulated 1 → 3; every response reportedinput_transformations: []and no[anthropic] replayed thinking droppedline was logged. Transcript check: exactly one persistedopenclaw.runtime-contextentry in the Fable session, none in the Opus session.Follow-ups: none required; the Fable-specific retention behaviour and the binding-controls telemetry are unchanged from #136782.