This commit is contained in:
devin-ai-integration[bot] 2026-10-14 10:49:13 -05:00 • committed by GitHub
commit 008ab28f78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 56 additions and 4 deletions

View file

@ -57,9 +57,10 @@ logger = logging.getLogger(__name__)
StreamEventSink = Callable[[str, Any], None]
_INPUT_REJECTION_CODES = frozenset({400, 404, 422})
# Replies meaning "this model takes no images", not image errors in general: a
# context overflow that counts "image/vision expansion" must not match.
_INPUT_REJECTION_CODES = frozenset({400, 404, 415, 422})
# Replies meaning "this model takes no images" or "this image is not a decodable
# image"; stripping images and retrying fixes both. Not image errors in general:
# a context overflow that counts "image/vision expansion" must not match.
_IMAGE_REJECTION = re.compile(
r"no endpoints found that support image input" # OpenRouter
r"|image_url is only supported by certain models" # OpenAI
@ -67,7 +68,16 @@ _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"|\binvalid_image\b" # xAI error code
r"|does not contain a valid JPG, PNG, WebP, or ICO image" # xAI
r"|unsupported content-type encountered when downloading image" # xAI
r"|does not represent a valid image" # OpenAI
r"|could not process image" # Anthropic, Bedrock
r"|provided image is not valid" # Gemini
r"|could not be loaded as a valid image" # Mistral
r"|url did not return an image" # OpenRouter
r"|not an allowed image type|cannot identify image file", # vLLM/PIL-based hosts
re.IGNORECASE,
)
_MAX_COMPACTIONS_PER_CYCLE = 2

View file

@ -188,6 +188,48 @@ 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,
"The image data you provided does not represent a valid image. Please check "
"your input and try again with one of the supported image formats.",
True,
),
(400, '{"type":"invalid_request_error","message":"Could not process image"}', True),
(
400,
'{"code":400,"message":"Provided image is not valid.","status":"INVALID_ARGUMENT"}',
True,
),
(
400,
"Image, 'https://example.com/', could not be loaded as a valid image. "
"Allowed formats are JPEG, PNG, WEBP, GIF",
True,
),
(
415,
'{"error":{"message":"URL did not return an image (received text/error content): '
'https://example.com/","code":415}}',
True,
),
(400, "image_url content type is not an allowed image type: text/html", True),
(400, "cannot identify image file <_io.BytesIO object>", True),
(400, '{"error":{"code":"invalid_image_detail"}}', False),
(
400,
"OpenRouterException: Message: This model's maximum context length is 1048576 "