mirror of
https://github.com/zed-industries/zed.git
synced 2026-07-09 16:00:35 +00:00
Closes https://github.com/zed-industries/zed/issues/52576 ## Overview Adds prompt caching support for Anthropic Claude models when accessed via OpenRouter. This mirrors Zed's native Anthropic provider by using explicit per-block `cache_control` breakpoints: - A long-lived 1-hour breakpoint on the system message's last text block, covering the tools and system prefix. - A default 5-minute breakpoint on the last `cache: true` conversation message. The implementation intentionally avoids OpenRouter's top-level automatic `cache_control` field so routing remains available across Anthropic-compatible providers including Anthropic, Bedrock, and Vertex AI. It also adds `session_id` sticky routing from the request thread ID and maps OpenRouter cache usage fields into Zed's token usage accounting. Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Fixed Anthropic prompt caching when using OpenRouter. --------- Co-authored-by: Anant Goel <anant@zed.dev> |
||
|---|---|---|
| .. | ||
| src | ||
| Cargo.toml | ||
| LICENSE-GPL | ||