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>
This commit is contained in:
Devin AI 2026-10-12 16:05:50 +00:00
parent 429f6218f5
commit bf421929ea
2 changed files with 18 additions and 1 deletions

View file

@ -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

View file

@ -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 "