Repository navigation
fix(bedrock): keep prompt cache checkpoints on conversation history - #140797
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 7, 2026, 12:58 AM ET / 04:58 UTC. ClawSweeper reviewWhat this changesRestore Bedrock conversation cache checkpoints and let Bedrock and Mantle cache stable system instructions separately from changing runtime context. Merge readiness✅ Ready for maintainer review This remains a useful, focused repair: inspected main still has the reported checkpoint behavior, and no introduced correctness defect was found. The earlier unmeasured AWS billing observation does not establish an additional merge blocker. Priority: P2 Review scores
Verification
How this fits togetherThe agent runner supplies system instructions and conversation history to provider plugins. Bedrock and Mantle convert that context into provider requests, placing checkpoints that determine which prompt prefixes can be reused. flowchart TD
A[System instructions] --> C[Provider stream registration]
B[Conversation history] --> C
C --> D{Boundary support enabled}
D -->|No| E[Strip internal marker]
D -->|Yes| F[Separate stable and dynamic context]
F --> G[Place eligible cache checkpoints]
E --> H[Provider request]
G --> H
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +34, Tests +370, Docs +9. Total +413 across 16 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep checkpoint placement in the provider transport, reuse the existing replay classification, and preserve default marker stripping for custom plugins. Do we have a high-confidence way to reproduce the issue? Yes, from source: retained runtime-context carriers trigger main's volatile cutoff and prevent later conversation checkpoints. The regression fixtures exercise that path; this read-only review did not execute them. Is this the best way to solve the issue? Yes. The patch repairs the existing transport and registration boundaries, reuses shared cache helpers, and preserves the compatibility default instead of adding a competing caching mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against abc35e08c1a2. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…penclaw#140797) * fix(bedrock): keep prompt cache checkpoints on conversation history * test(bedrock): satisfy checkpoint fixture brace lint
…penclaw#140797) * fix(bedrock): keep prompt cache checkpoints on conversation history * test(bedrock): satisfy checkpoint fixture brace lint (cherry picked from commit 331d6b7)
Additional instructions
Maintainers can update this branch in the repository.
What Problem This Solves
Fixes an issue where users running Claude through Amazon Bedrock Converse would lose conversation prompt caching after retained runtime context was merged into the first user message. Conversation history, including subsequent tool loops, received no cache checkpoint.
Bedrock and Bedrock Mantle also cached the entire system prompt as one block, so a date rollover or other dynamic runtime change invalidated the stable workspace prefix.
Why This Change Was Made
Retained, append-only runtime-context carriers now remain stable conversation anchors; only transient carriers impose the checkpoint cutoff, and checkpoints advance through tool results. Provider registrations can opt into
supportsSystemPromptCacheBoundary, allowing Bedrock and Mantle to consume the existing system boundary and checkpoint the stable prefix separately from dynamic additions. Other custom transports retain boundary stripping by default.Application-profile fallback injection respects the split and preserves runtime-owned checkpoints. Opaque profiles with transient carriers conservatively retain only the system checkpoint. No operator configuration, schema, persistent-store, or dependency changes are introduced.
User Impact
Bedrock Claude conversations can reuse retained history across turns and tool loops. Bedrock and Mantle can preserve the stable system prefix when dynamic runtime facts change. Disabled caching, transient-context exclusion, thinking signatures, and role merging retain their existing behavior.
The SDK opt-in is documented in
docs/plugins/sdk-provider-plugins.md; provider behavior is documented indocs/reference/prompt-caching.md.Evidence
node scripts/run-vitest.mjs extensions/amazon-bedrock extensions/amazon-bedrock-mantle src/agents/embedded-agent-runner/stream-resolution.test.ts src/agents/embedded-agent-runner/run/attempt.test.ts src/plugins/provider-runtime.test.ts— 18 files, 590 tests passed across four shards in the implementation run. The fresh publication sanity run also passed all 590 tests in 18 files across four shards (148.22 seconds).stream-resolution.test.tspassed all 47 tests; all four typecheck lanes subsequently passed. Production code did not change after the successful build.pnpm buildpassed, including runtime, package/SDK declarations, export checks, and UI build.check:changedpassed every gate through core lint: formatting, ratchets, imports and SDK guards, declaration checks, all four typecheck lanes, and three dead-export scans (zero findings). It stopped at extension-lint artifact preparation withDeclaration input escapes checkout ... qrcode, caused by this nested worktree's ancestor installation. The declaration-boundary guard is unchanged. Fresh-checkout CI's extension lint lane is the authoritative remaining proof; later local gates were not reached.git diff --cached --checkpassed.CI follow-up: the first ready-state run reached extension lint and found two missing-brace errors in the changed checkpoint test. A follow-up commit adds those braces; targeted lint, formatting, all 20 tests in that file, and fresh Codex autoreview (0 actionable P0/P1 findings) passed. The same run's
check-guardsfailed independently during Matrix native dependency installation (ECONNRESET, followed by an installerReferenceError), before guards executed. No dependency or guard changes were made. The follow-up exact-head CI result is recorded below.Final CI: run 34084194236 completed successfully for
9f51c58878faf022d81cd497f62109240a52f924: 108 successful jobs, 16 intentional skips, zero failed jobs.check-lint(including extension lint) andcheck-guardsboth passed. The bounded exact-head watcher terminatedGREEN(exit 0), reconciling superseded checks, including the stale cancelled Labeler status. The earlier watcher terminatedFAILING checks=check-guards(exit 15); its source-related lint findings were fixed as described above.