Expand description
Prompt caching control types.
Provider-neutral abstractions for marking message content and tool
definitions as eligible for prompt caching. Adapters translate these
markers to provider-specific wire formats (e.g. Anthropic’s
cache_control blocks) or rely on the provider’s automatic caching
(e.g. OpenAI’s prefix cache).
§Stability model
CacheControlis a per-ContentPartand per-ToolSpecmarker.- A marker on the last content block of a stable region (system prompt, tool definitions, conversation tail) instructs the provider to create a cache entry covering everything from the start of the prompt up to and including that block.
- Markers have no effect on providers that do not support caching; they are silently ignored.
§Example
use behest_core::cache::CacheControl;
use behest_core::message::{ContentPart, Message};
let ctrl = CacheControl::ephemeral();
let part = ContentPart::text("You are a research assistant.").with_cache_control(ctrl);
let message = Message::system_text("You are a research assistant.")
.mark_cache_breakpoint();Structs§
- Cache
Control - Provider-neutral cache control marker.
Enums§
- Cache
Control Kind - Cache strategy kinds.
- Cache
Ttl - Time-to-live for a cache entry.