/** * OpenAICacheStrategy — metrics-only strategy for OpenAI providers. * * OpenAI auto-caches request prefixes ≥1024 tokens at 50% off. * No client-side opt-in markers needed (and no way to influence * cache behavior from the client). The strategy: * * - **prepareRequest**: pass-through. We can't tell OpenAI what * to cache; they decide automatically. Markers are silently * dropped (the 80% case for OpenAI consumers is "I declared * cache: 'always' for my injections" — that's still meaningful * because (a) it's portable across providers, (b) for OpenAI * the auto-cache may still hit on stable prefixes regardless). * - **extractMetrics**: reads `prompt_tokens_details.cached_tokens` * from OpenAI's usage response so cacheRecorder can surface * hit rates / dollar savings. * * Auto-registers on module import for: 'openai', 'browser-openai'. * * Documentation note for consumers (Phase 12 docs): the `cache:` * directive on injection definitions is portable but has NO LOCAL * EFFECT on OpenAI runs — the provider auto-caches based on prefix * length. The directive still ships correctly with the agent and * lights up automatically when you swap to Anthropic / Bedrock. */ import type { CacheCapabilities, CacheMarker, CacheMetrics, CacheStrategy, CacheStrategyContext } from '../types.js'; import type { LLMRequest } from '../../adapters/types.js'; export declare class OpenAICacheStrategy implements CacheStrategy { readonly providerName = "openai"; readonly capabilities: CacheCapabilities; prepareRequest(req: LLMRequest, _candidates: readonly CacheMarker[], _ctx: CacheStrategyContext): Promise<{ readonly request: LLMRequest; readonly markersApplied: readonly CacheMarker[]; }>; extractMetrics(usage: unknown): CacheMetrics | undefined; }