Skip to content

Commit 02548c4

Browse files
[codex] apply Anthropic cache control to tools (0xPlaygrounds#1815)
* feat(anthropic): add cache_control field to ToolDefinition Anthropic's prompt-caching API supports up to 4 cache breakpoints per request. One of the three cacheable layers is the tools array: setting cache_control on the last ToolDefinition tells Anthropic to cache all tools up to that point independently of the system prompt. ToolDefinition currently has no cache_control field, so callers have no way to cache the tools layer. This adds the field following the same pattern already used by SystemContent and the message Content variants. - Add `pub cache_control: Option<CacheControl>` to `ToolDefinition` with `#[serde(skip_serializing_if = "Option::is_none")]` so it is absent from requests that do not use caching. - Initialize `cache_control: None` at the two ToolDefinition construction sites (completion.rs and streaming.rs TryFrom impls). * feat(anthropic): apply cache control to tools * fix(anthropic): skip deferred tool cache markers * fix(anthropic): avoid tool cache indexing * fix(anthropic): preserve explicit tool cache markers * fix(anthropic): budget prompt cache markers * fix(anthropic): enforce cache marker budget * fix(anthropic): validate cache control markers * test(anthropic): record prompt caching cassettes * fix(anthropic): normalize top-level cache control * test(anthropic): cover raw cache control ttl planning * test(anthropic): tolerate prompt cache hits on record * docs(anthropic): refresh cache ttl docs * test(anthropic): canonicalize streaming cache cassette --------- Co-authored-by: Jimmie Fulton <jimmie.fulton@gmail.com>
1 parent 82d1e87 commit 02548c4

7 files changed

Lines changed: 2062 additions & 89 deletions

File tree

0 commit comments

Comments
 (0)