Repository navigation
fix(anthropic): reuse shared system prompt across sessions - #196471
Conversation
Co-authored-by: scoootscooob <[email protected]>
|
🦞👀 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. What this changesThis PR adds an opening-request cache checkpoint before session-specific Runtime facts. Example: Sessions alpha and beta send identical agent instructions within the cache lifetime.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored replacement addresses avoidable Anthropic cache writes still present on main; no concrete correctness or security defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe shared Anthropic payload policy converts prepared system prompts, tools, and conversation history into provider request blocks and allocates their cache checkpoints. flowchart LR
A[Agent system prompt] --> B[Prepared prompt revision]
B --> C[Anthropic system block policy]
D[Tools and conversation history] --> E[Checkpoint allocation]
C --> E
E --> F[Anthropic request]
Technical reviewBest possible solution: Keep the focused checkpoint change in the existing Anthropic policy owner and land this credited replacement when its validation is settled. Do we have a high-confidence way to reproduce the issue? Current main visibly combines shared dynamic instructions with session-specific Runtime facts; the linked source PR supplies released-build observations and a direct-API mechanism check, but this review executed no target code. Is this the best way to solve the issue? The change uses the existing boundary parser, prepared-prompt lifetime, and checkpoint allocator; it avoids moving instructions between roles or adding a competing cache owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 46589542ffb6. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +42, Tests 0. Total +42 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 10, 2026, 1:24 AM ET / 06:24 UTC. |
|
Exact-head proof update for
ClawSweeper's optional rank-up move asks for branch-built agent usage evidence across two fresh sessions and a follow-up. The source PR reports a live Anthropic API trial of the same checkpoint mechanism, while this replacement verifies exact outbound blocks, prompt-text continuity, cross-session shared-prefix identity, and follow-up allocation in its provider test. I am skipping a second authenticated cost experiment for this replacement. Its branch-built cost savings remain unmeasured; the external API cache mechanism and branch-built request shape are separately evidenced. |
|
Merged via squash.
|
…6471) Co-authored-by: scoootscooob <[email protected]>
What Problem This Solves
Fixes: starting a new Anthropic session rewrites agent-shared system instructions to the prompt cache when only the Runtime facts differ.
Related: #196461
User Impact
User impact: short sessions for the same agent can reuse the shared system text within Anthropic's cache lifetime, reducing cache writes. Other providers are unaffected. The opening request uses one history checkpoint; later requests retain two.
Why This Change Was Made
This carries Scott Fan's proposed Anthropic transport checkpoint into an editable maintainer branch. The source PR cannot be edited by maintainers, and its split removed the newline before Runtime facts. This version preserves that newline in the session-owned block and verifies both prompt text and a shared prefix across two sessions. Contributor credit is retained in the commit.
Evidence
git diff --check, oxfmt, pre-commit freshness/line-cap hook, and independent P1 autoreview: passed.