release: Anthropic prompt cache control (#599)
Merged
SW
5mo ago+348+348+012345678901234567890123456789-1-1-0123456789
Summary
- Ports open-agents'
addCacheControlhelper (split intoisAnthropicModel,addCacheControlToTools,addCacheControlToMessagesper SRP) - Wires into
runAgentStep: tools wrapped once +prepareStepcallback wraps messages per step - Anthropic now caches system prompt + tools across turns; subsequent turns re-read most of the prefix at ~10% cost
Test plan
- 19 unit tests; full suite 3138/3138 pass
- E2E on preview verified: turn 2 cost drops from baseline $0.005959 โ $0.00167 (72% cheaper);
cacheReadTokens=5020on turn 2 (was 0) - Cache shape matches open-agents production (4.5ร drop on Haiku vs 12ร on Opus โ ratio reflects model, shape matches)
๐ค Generated with Claude Code
Summary by cubic
Adds Anthropic prompt caching to the chat workflow so the system prompt and tools are reused across turns. Marks the last tool and last message with cacheControl: { type: "ephemeral" }, cutting follow-up turn input cost (~72% in E2E).
- New Features
- Added
isAnthropicModel,addCacheControlToTools, andaddCacheControlToMessages. runAgentStep: wraps tools once and usesprepareStepto tag the final message per step (Anthropic only).- No changes for non-Anthropic models; 19 unit tests cover helpers and wiring.
- Added