Repository navigation
fix(anthropic): bind cache carriers to replay policy - #157662
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 25, 2026, 1:48 AM ET / 05:48 UTC (Revision 7). ClawSweeper reviewWhat this changesThe branch records the provider's runtime-context retention decision on messages and uses it to place Anthropic prompt-cache markers, including after image hydration. Merge readiness✅ Ready for maintainer review Current main still chooses Anthropic cache eligibility from the model ID even when a provider plugin chose a different replay policy. This PR addresses that gap, preserves the existing behavior for unannotated direct callers, and has no actionable finding in the introduced diff. Priority: P2 Review scores
Verification
How this fits togetherThe agent session turns user input and runtime context into messages for a model request. Provider replay policy determines whether context remains in later turns; the Anthropic transport then decides where cache markers belong. flowchart LR
A[User turn and runtime context] --> B[Provider replay policy]
B --> C[Agent message boundary]
C --> D[Media projection]
D --> E[Anthropic request builder]
E --> F[Cache markers and model request]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +16, Tests +71. Total +87 across 6 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep provider replay policy as the retention authority at the agent boundary while preserving model-derived cache behavior for direct callers that provide no explicit decision. Do we have a high-confidence way to reproduce the issue? Yes. Current-main source supplies a high-confidence path: a provider can choose transient Anthropic replay for a Claude model while the transport still treats its carrier as cache-eligible. This read-only review did not run that path. Is this the best way to solve the issue? Yes. Recording the provider's decision at the existing LLM boundary and consuming it in the shared Anthropic transport is a narrow repair; the absent-metadata fallback protects direct callers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 155ff367ba98. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
dcd707b to
148e62b
Compare
|
Addressed the accepted compatibility finding at exact head
Validation:
Exact-head CI is running; I will attach its measured changed-test duration when terminal. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
148e62b to
80ecf25
Compare
|
Exact-head repair evidence for
The accepted review finding is fixed: explicit provider retention now disagrees with the model-derived default in both directions, so the parity suite fails if the carrier override is ignored. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
8cc756d to
41fcbbf
Compare
|
Exact-head rebase status:
The failing architecture leaf reproduces locally after the clean rebase with |
41fcbbf to
ba0c301
Compare
|
Rebased conflict-free onto current main at bd3ac5c, including the merged host-broker CI repair. Exact head: ba0c301.\n\nFresh focused proof: 36/36 passed. Fresh mandatory P0–P2 autoreview: scoped-clean, no accepted/actionable findings. Exact-head CI is fully green: https://github.com/openclaw/openclaw/actions/runs/36099602380\n\nLive closeout: non-draft, MERGEABLE/CLEAN, ClawSweeper platinum hermit, ready for maintainer look. |
Preserve authored selections, native thinking display and replay-bound cache carriers. Raise the OAuth identity floor and retain required fallback betas after custom headers and payload hooks without changing excluded transports. Backport #156093: 5e5f9c2 Backport #156062: 2f10ac3 Backport #157662: d29ac12 Backport #158300: 169da00 The initial #155966 support is already inherited from the stable cut. Co-authored-by: fuller-stack-dev <[email protected]> Co-authored-by: Serg <[email protected]> Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vyctorbrzezowski <[email protected]> Co-authored-by: steipete <[email protected]> Co-authored-by: jalehman <[email protected]>
What Problem This Solves
Fixes an issue where Anthropic cache-carrier retention could be recomputed from a model ID after a provider plugin had already selected a different replay policy. A provider-owned transient carrier could therefore be cached, or a retained carrier could lose its cache boundary.
Why This Change Was Made
The LLM session boundary now records the provider-resolved carrier-retention decision on the user message, media projection preserves that fact, and the Anthropic transport consumes it directly. This keeps policy ownership at the replay boundary instead of re-deriving it from model naming.
User Impact
Provider plugins that customize Anthropic replay behavior now get cache markers consistent with their selected policy across tool loops, turns, and image hydration.
Evidence
node scripts/run-vitest.mjs packages/ai/src/anthropic-cache-carrier-parity.test.ts src/agents/embedded-agent-runner/run/attempt-session-boundary.test.ts— 36/36 passed after rebasing onto currentmain.node scripts/check-changed.mjs -- <six touched paths>— passed.mainMadge cycles reproduced locally withpnpm check:madge-import-cycles; no PR-owned failure is known.Production delta is +21/-5 (net +16) across four source files: one closed retention fact at the LLM boundary, propagation through image hydration, and removal of transport-side model inference. Tests are +76/-5 (net +71) across two files.