Repository navigation
perf(anthropic): preserve conversation cache checkpoints - #168042
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. What this changesThis PR preserves two recent conversation cache checkpoints and selects cache lifetimes supported by Bedrock models and resolved application profiles. Example: A Claude conversation appends a user message containing 21 document blocks after a tool-result checkpoint.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR: current main still lacks its large-append checkpoint repair, and the reviewed patch has no actionable correctness or security findings. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherAnthropic request builders and the Bedrock plugin convert conversation history, model metadata, and retention settings into provider payloads containing cache checkpoints. flowchart TD
A[Conversation and retention settings] --> B[Provider request builder]
B --> C[Anthropic checkpoint allocator]
B --> D[Bedrock cache policy]
E[Resolved profile targets] --> D
C --> F[Serialized provider request]
D --> F
Technical reviewBest possible solution: Retain the focused checkpoint and TTL repair, preserving existing retention settings and provider-owned policy. Do we have a high-confidence way to reproduce the issue? Current-main source removes the previous tool-result checkpoint after a 21-block user append, and the added request-builder regression captures that exact shape; no target code was executed during this review. Is this the best way to solve the issue? The repair uses existing request owners, preserves the four-marker budget and Nova opt-in, and carries model-specific TTL policy into profile injection without adding configuration or persistent state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 999b5df91076. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -12, Tests +83, Docs +8, Other 0. Total +79 across 12 files. Added test files: 0. View PR surface stats
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 HistoryReview history (4 earlier review cycles)
Reviewed October 10, 2026, 3:49 PM ET / 19:49 UTC (Revision 5). |
986548c to
d0ad75e
Compare
…8042) Preserve a prior Anthropic conversation checkpoint when a new turn exceeds the provider lookup window. Resolve Bedrock model and application-profile cache eligibility and supported TTL through one policy owner, retaining five-minute defaults and avoiding unsupported one-hour requests. Synthetic ten-turn conversation reuse improves from 5/10 to 8/10, with modeled Bedrock writes falling 39.7%. Production code is 12 lines smaller. Focused provider tests and required CI pass; actual provider cache-token counters remain unmeasured.
Keep up to two Anthropic conversation checkpoints so a prior write stays reachable when a new turn exceeds the provider's 20-block lookback, and place every conversation checkpoint before transient runtime context (steering and tool loops after an unretained carrier). Backport of 4895fbb (#168042) adapted for 2026.10.2: Anthropic Messages payload policy only; the Bedrock cache-policy consolidation from that PR is not included. Also includes the Anthropic checkpoint part of d13db41 (#168392) ("keep cache checkpoints before transient context").
…8392) Share live and persisted tool-result preparation so the text first sent to the model is capped and redacted once and replayed byte-identically after persistence, replay, and reopen (including oversized results and late listener redaction changes). Preserve canonical tool-result projection identity through replay normalization, keep the browser conversation cache key for internal child completions, and disambiguate repeated native OpenAI Chat Completions tool-call IDs deterministically. Backport of d13db41 (#168392) adapted for 2026.10.2: - the Anthropic checkpoint part ships in the #168042 port commit - live-cache release-gate, workflow, and release-docs changes are not included; the offline prefix-stability helper is kept for the new regression tests - the attempt auth-selection extraction (no behavior change) is not included - the admitted-turn regression test declares this line's image retention (rolling three-turn window), its trailing transient Chat Completions carrier, and keeps one instruction revision because in-history instruction updates for those routes are not on 2026.10.2
What Problem This Solves
Anthropic conversation caching could fall back to the system prefix when a new user turn added at least 20 content blocks. Bedrock also omitted supported Haiku 5.5 checkpoints and could request an unsupported one-hour TTL on older Claude models or opaque application profiles.
User Impact
Large document/image turns retain a preceding conversation checkpoint. Bedrock uses the supported retention window of the selected model and resolved profile targets. The five-minute default and existing configuration remain unchanged; no migration is required.
Change
Messages, including Vertex's shared builder, retain recent conversation checkpoints within the four-marker budget. Bedrock carries one resolved cache policy through request construction and profile injection. The rebase preserves main's one-hour model allowlist; forced cache eligibility alone uses five-minute checkpoints. Consolidated overlapping TTL tests without dropping distinct model cases or payload-boundary assertions.
Production LOC delta: -12 (120 additions, 132 deletions, excluding tests and docs). No new dependency, configuration option, schema, or persistent cache.
Evidence and Measurement
tbx_01m4h90vpj5nx96psdfhrzx21tproved the original Messages and Bedrock regressions fail before the fix. During conflict repair,tbx_01m4ka56xrvv7yaeqszw2hcbf5reproduced the forced-TTL defect, then passed all 34 accounting/replay tests after correction (6.05s Vitest).c72b109fcf8808e356174642ee9b6fb96aa5fa14passed 338 focused tests on the isolated Linux rig: 12 core payload, 41 cache parity, and 285 Bedrock/Vertex siblings (59.69s wrapper). This includes every touched test file and the cloud-provider sibling suites.node scripts/check-changed.mjs --staged --timedcompleted all typechecks and early guards, then reported one inherited unused export:ui/src/test-helpers/solid-application-context.tsx:hiddenScopeUpgradeCapability. Unchanged basec7a0bc9a9713reproduces that same finding. The remaining planned lint and boundary commands were run separately and passed; export-collision and both import-closure guards passed (20 tests). A concurrent lint/test setup initially tripped the compiler snapshot guard; serialized reruns passed without source changes. No guard was skipped or weakened.git range-diff).Live gap: no live cache-probe request executed. Actual
cache_creation_input_tokens,cache_read_input_tokens, and cloud hit rates remain unmeasured: 0 provider requests, 0 probe tokens, $0 probe inference cost.Lane 720's transient-context cache-marker follow-up remains separate.
Provider contracts: Anthropic prefix lookup, AWS cache model/TTL limits.
Current published candidate:
d0ad75eb36f96d8403c9d6a175b906f7b40b1b7f. CI run 38080723680 completed successfully on this exact head; required CI gates pass.