Repository navigation
fix: stabilize Anthropic cache marker through tool loops - #89488
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 4, 2026, 5:55 AM ET / 09:55 UTC. Summary PR surface: Source +120, Tests +158. Total +278 across 3 files. Reproducibility: yes. from source inspection: current main marks the last user/tool_result block in both shared and native Anthropic paths, so trailing tool results move the conversation-history breakpoint during tool loops. I did not execute a live provider repro in this read-only review, but the linked issue and PR body include captured real-payload evidence. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: The end state should be one shared/native Anthropic payload policy that keeps conversation cache markers stable through tool-result loops while staying within Anthropic's four-breakpoint contract. Do we have a high-confidence way to reproduce the issue? Yes from source inspection: current main marks the last user/tool_result block in both shared and native Anthropic paths, so trailing tool results move the conversation-history breakpoint during tool loops. I did not execute a live provider repro in this read-only review, but the linked issue and PR body include captured real-payload evidence. Is this the best way to solve the issue? Yes, this is an acceptable best current fix: it changes the existing Anthropic payload-shaping owners, preserves tool-result fallback behavior, and bounds message markers by the Anthropic breakpoint limit. The remaining question is maintainers accepting the compatibility impact, not a concrete patch defect. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 474d6e520aaf. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +120, Tests +158. Total +278 across 3 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Landed via rebase onto Thanks @Marvinthebored. Verification:
Merged commit: |
Summary
tool_resultcarriers.Fixes part of #86063.
Why
In tool-heavy sessions, OpenClaw currently attaches the conversation cache marker to the newest user-role
tool_result. That marker moves on every tool call, so the historical prefix changes even when the actual conversation content is stable. This causes repeated large cache writes instead of cache reads.A live current-version evidence comment with sanitized payload/cost data is here:
#86063 (comment)
Real behavior proof
tool_resultduring tool loops.2026.6.1-beta.1 (13dd4e3), installed OpenClaw dist hotpatched from this PR, gateway restarted and running locally against a real Anthropic-compatible/Pioneer session payload captured from the affected setup.openclaw gateway status, syntax-checked the patched provider bundles withnode --check, then replayed the captured 102-message real provider payload through the installed patched Anthropic cache policy to compare marker placement before and after the fix.pnpm tsgo:test:srccommand hung with no output after several minutes and was stopped.Tests
Also run:
pnpm tsgo:test:srcwas attempted locally but hung with no output after several minutes and was stopped, so I am not claiming that check passed.AI assistance
This PR was prepared with AI assistance on a human-operated OpenClaw instance, using sanitized payload-location/counter evidence only. No user message contents, account identifiers, API keys, or private session transcript text are included.