import { BaseMessage, MessageContentComplex } from '@langchain/core/messages'; import type { AnthropicMessage } from '@/types/messages'; type MessageWithContent = { content?: string | MessageContentComplex[]; }; /** * Anthropic API: Adds cache control to the appropriate user messages in the payload. * Strips ALL existing cache control (both Anthropic and Bedrock formats) from all messages, * then adds fresh cache control to the last 2 user messages in a single backward pass. * This ensures we don't accumulate stale cache points across multiple turns. * Returns a new array - only clones messages that require modification. * @param messages - The array of message objects. * @returns - A new array of message objects with cache control added. */ export declare function addCacheControl(messages: T[]): T[]; /** * Removes all Anthropic cache_control fields from messages * Used when switching from Anthropic to Bedrock provider * Returns a new array - only clones messages that require modification. */ export declare function stripAnthropicCacheControl(messages: T[]): T[]; /** * Removes all Bedrock cachePoint blocks from messages * Used when switching from Bedrock to Anthropic provider * Returns a new array - only clones messages that require modification. */ export declare function stripBedrockCacheControl(messages: T[]): T[]; /** * Adds Bedrock Converse API cache points using "Stable Prefix Caching" strategy. * * STRATEGY: Place cache point after the LAST ASSISTANT message only. * This ensures the prefix (everything before the cache point) remains STABLE * as the conversation grows, maximizing cache hits. * * Why this works: * - System message has its own cachePoint (added in AgentContext) * - Tools have their own cachePoint (added in IllumaBedrockConverse) * - Conversation history grows, but the PREFIX stays the same * - Only the NEW user message is uncached (it's always different) * * Example conversation flow: * Request 1: [System+cachePoint][Tools+cachePoint][User1] → No conversation cache yet * Request 2: [System][Tools][User1][Assistant1+cachePoint][User2] → Cache User1+Assistant1 * Request 3: [System][Tools][User1][Assistant1][User2][Assistant2+cachePoint][User3] * → Cache reads User1+A1+User2+A2, cache writes new portion * * Claude's "Simplified Cache Management" automatically looks back up to 20 content * blocks from the cache checkpoint to find the longest matching prefix. * * @param messages - The array of message objects (excluding system message). * @returns - The updated array with a single cache point after the last assistant message. */ export declare function addBedrockCacheControl & MessageWithContent>(messages: T[]): T[]; export {};