YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(ai): keep cache markers off media content (#6385)
Ezra Ellette8696fbe7851f
diff --git a/packages/ai-gateway/src/providers/openai.ts b/packages/ai-gateway/src/providers/openai.tsindex 659107043..8b742d8b2 100644--- a/packages/ai-gateway/src/providers/openai.ts+++ b/packages/ai-gateway/src/providers/openai.ts@@ -25,9 +25,6 @@ const GPT56_MAX_READ_BREAKPOINTS = 50;const GPT56_HISTORY_BREAKPOINTS = GPT56_MAX_READ_BREAKPOINTS - 1;const CACHEABLE_CONTENT_TYPES = new Set(['text',- 'image_url',- 'input_audio',- 'file','refusal',]);@@ -50,14 +47,6 @@ function isCacheableContentPart(part: any): boolean {return typeof part.text === 'string' && part.text.length > 0;case 'refusal':return typeof part.refusal === 'string' && part.refusal.length > 0;- case 'image_url':- return typeof part.image_url === 'string'- ? part.image_url.length > 0- : Boolean(part.image_url?.url);- case 'input_audio':- return Boolean(part.input_audio?.data);- case 'file':- return Boolean(part.file?.file_id || part.file?.filename || part.file?.file_data);default:return false;}diff --git a/packages/ai-gateway/src/test/openai-models.unit.test.ts b/packages/ai-gateway/src/test/openai-models.unit.test.tsindex 2dcb62a7c..44d853f71 100644--- a/packages/ai-gateway/src/test/openai-models.unit.test.ts+++ b/packages/ai-gateway/src/test/openai-models.unit.test.ts@@ -412,32 +412,33 @@ describe('OpenAI API accounting and routing', () => {expect(marked).toEqual([true, false, true, false, false, true, false, true, false, false, true]);});- it('marks the last supported multipart image or file block without changing it', async () => {+ it('marks preceding multipart text without adding cache fields to media blocks', async () => {const imagePart = {type: 'image_url',image_url: { url: 'data:image/png;base64,AA', detail: 'high' },};const filePart = { type: 'file', file: { file_id: 'file_123' } };+ const audioPart = { type: 'input_audio', input_audio: { data: 'AA', format: 'wav' } };const params: any = {model: 'gpt-5.6-luna',messages: [{ role: 'system', content: 'stable' },{ role: 'user', content: [{ type: 'text', text: 'look' }, imagePart, { type: 'text', text: '' }] },{ role: 'assistant', content: 'seen' },- { role: 'user', content: [filePart, { type: 'text', text: '' }] },+ { role: 'user', content: [{ type: 'text', text: 'read' }, filePart, { type: 'text', text: '' }] },+ { role: 'assistant', content: 'read' },+ { role: 'user', content: [{ type: 'text', text: 'listen' }, audioPart, { type: 'text', text: '' }] },],};await applyGpt56PromptCaching(params, true);- expect(params.messages[1].content[1]).toEqual({- ...imagePart,- prompt_cache_breakpoint: { mode: 'explicit' },- });- expect(params.messages[3].content[0]).toEqual({- ...filePart,- prompt_cache_breakpoint: { mode: 'explicit' },- });+ expect(params.messages[1].content[0].prompt_cache_breakpoint).toEqual({ mode: 'explicit' });+ expect(params.messages[1].content[1]).toEqual(imagePart);+ expect(params.messages[3].content[0].prompt_cache_breakpoint).toEqual({ mode: 'explicit' });+ expect(params.messages[3].content[1]).toEqual(filePart);+ expect(params.messages[5].content[0].prompt_cache_breakpoint).toEqual({ mode: 'explicit' });+ expect(params.messages[5].content[1]).toEqual(audioPart);});it('recomputes GPT-5.6 breakpoints idempotently after rewritten history', async () => {