fix(translator): don't drop image-only user messages in prepareClaudeRequest

hasValidContent() only treated text/tool_use/tool_result blocks as valid
content, so a user message containing only an image block was filtered
out as empty. When it was the only non-system message, this left an
empty messages array and Anthropic rejected the request.
This commit is contained in:
cardinusantara
2026-08-05 13:19:55 +07:00
committed by decolua
parent 646b3b9ba3
commit a7941ddab4
2 changed files with 24 additions and 1 deletions

View File

@@ -16,7 +16,9 @@ export function hasValidContent(msg) {
return msg.content.some(block =>
(block.type === CLAUDE_BLOCK.TEXT && block.text?.trim()) ||
block.type === CLAUDE_BLOCK.TOOL_USE ||
block.type === CLAUDE_BLOCK.TOOL_RESULT
block.type === CLAUDE_BLOCK.TOOL_RESULT ||
block.type === CLAUDE_BLOCK.IMAGE ||
block.type === CLAUDE_BLOCK.DOCUMENT
);
}
return false;