Skip to main content

apply_cache_control

Function apply_cache_control 

Source
pub fn apply_cache_control(
    messages: &[Message],
    settings: &CacheSettings,
) -> Vec<Message>
Expand description

Apply cache control to strategic message positions.

Strategy (Anthropic/OpenAI best practices):

  1. System message (if present) - first message if role is System
  2. Last user message - enables caching of conversation context

Returns a new Vec with cache_control applied where appropriate.