From bf421929eae0d3e2fd0fd8648329970f12918f5c Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Mon, 12 Oct 2026 16:05:50 +0000 Subject: [PATCH] fix(execution): strip images when xAI rejects one it cannot decode Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- strix/core/execution.py | 4 +++- tests/test_execution_transient_retry.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/strix/core/execution.py b/strix/core/execution.py index 87a2bf02..412cf998 100644 --- a/strix/core/execution.py +++ b/strix/core/execution.py @@ -67,7 +67,9 @@ _IMAGE_REJECTION = re.compile( r"|does not support image input" # LiteLLM's Fireworks check r"|doesn't support the image field" # Bedrock Converse r"|unknown variant `image_url`" # DeepSeek, e.g. via Vercel AI Gateway - r"|'[^']*image[^']*' functionality not supported", # Vercel AI Gateway (AI SDK), unverified + r"|'[^']*image[^']*' functionality not supported" # Vercel AI Gateway (AI SDK), unverified + r"|does not contain a valid JPG, PNG, WebP, or ICO image" # xAI: URL fetched, not an image + r"|unsupported content-type encountered when downloading image", # xAI re.IGNORECASE, ) _MAX_COMPACTIONS_PER_CYCLE = 2 diff --git a/tests/test_execution_transient_retry.py b/tests/test_execution_transient_retry.py index f0276932..93cd4d16 100644 --- a/tests/test_execution_transient_retry.py +++ b/tests/test_execution_transient_retry.py @@ -188,6 +188,21 @@ async def test_run_cycle_does_not_retry_permanent_error( (400, "This model doesn't support the image field for user messages.", True), (422, "messages[3]: unknown variant `image_url`, expected `text`", True), (400, "'Image URLs in user messages' functionality not supported.", True), + ( + 400, + "litellm.BadRequestError: OpenrouterException - " + '{"error":{"message":"Provider returned error","code":400,"metadata":{"raw":' + '"{\\"code\\":\\"invalid_image\\",\\"error\\":\\"code: \'Client specified an ' + "invalid argument', message: Downloaded response does not contain a valid JPG, " + 'PNG, WebP, or ICO image.\\"}","provider_name":"xAI"}}}', + True, + ), + ( + 400, + "Unsupported content-type encountered when downloading image. The only " + "supported content types are [image/jpeg, image/png, image/webp].", + True, + ), ( 400, "OpenRouterException: Message: This model's maximum context length is 1048576 "