applyPromptCache
function applyPromptCache( model, sessionId, messages): object;Single wiring point for provider prompt caching, called by the driver
streamText sites. Gated by the conservative detectors so non-matching
providers are untouched:
- Anthropic → applies
cache_controlbreakpoints (caches the system+tools prefix + recent history; ~75% input-cost + TTFT off multi-turn turns). - OpenAI Responses → sets
promptCacheKey(= sessionId, pins same-session turns to one cache slot) +truncation: 'auto'overflow safety net. Returns the (possibly transformed) messages + an optionalproviderOptionsbag ready to spread intostreamText. Default-on: both are no-ops on providers that ignore the fields.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”object
messages
Section titled “messages”messages: ModelMessage[];providerOptions?
Section titled “providerOptions?”optional providerOptions?: Record<string, Record<string, JSONValue>>;