From 32ac2afd0152b0fd693b42b32e0a54238092c895 Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Mon, 29 Sep 2025 12:15:25 -0700 Subject: [PATCH] Fix: Ensure Claude messages and content are non-empty --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index e35ce6f..2341506 100644 --- a/index.js +++ b/index.js @@ -228,13 +228,13 @@ export class MyDurableObject { messages: body.messages.filter(m => m.role !== 'system').map(m => ({ role: m.role, content: typeof m.content === 'string' ? m.content : (m.content || []).map(p => { - if (p.type === 'text') return { type: 'text', text: p.text }; + if (p.type === 'text' && p.text) return { type: 'text', text: p.text }; if (p.type === 'image_url') { const match = String(p.image_url?.url || p.image_url || '').match(/^data:(image\/\w+);base64,(.*)$/); if (match) return { type: 'image', source: { type: 'base64', media_type: match[1], data: match[2] } }; } }).filter(Boolean) - })), + })).filter(m => m.content.length), max_tokens: body.max_tokens || 64000, stream: true, };