The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(agent): classify Codex patch-budget image 400s as image_too_large
liuhao1024d3515a9d1839
diff --git a/agent/error_classifier.py b/agent/error_classifier.pyindex f7d7f47cf19..e4d1709498e 100644--- a/agent/error_classifier.py+++ b/agent/error_classifier.py@@ -151,9 +151,14 @@ _PAYLOAD_TOO_LARGE_PATTERNS = (# Per-image size/dimension 400s (Anthropic 5 MB / 8000 px; MiniMax "media# exceeds size limit" #76039) — a specific 400 before the request hits 413. A# non-image media hit is harmless: the shrink pass finds no image parts.+# "patches after processing": OpenAI Codex Responses rejects an image whose+# tile-patch budget (ceil(w/32)×ceil(h/32)) exceeds its 30000-patch ceiling+# with wording that names no image-size vocabulary — without this pattern it+# fell to format_error (non-retryable), bypassing the shrink recovery (#106337)._IMAGE_TOO_LARGE_PATTERNS = ("image exceeds", "image too large", "image_too_large", "image size exceeds", "image dimensions exceed","dimensions exceed max allowed size", "max allowed size: 8000", "media exceeds", "media too large",+ "patches after processing",)# Undecodable image bytes → strip-and-retry, never shrink. xAI wordingsdiff --git a/tests/run_agent/test_image_shrink_recovery.py b/tests/run_agent/test_image_shrink_recovery.pyindex de7c68e9204..62df5e28cdc 100644--- a/tests/run_agent/test_image_shrink_recovery.py+++ b/tests/run_agent/test_image_shrink_recovery.py@@ -78,6 +78,25 @@ class TestImageTooLargeClassification:assert result.reason == FailoverReason.image_too_largeassert result.retryable is True+ def test_codex_400_patch_budget_message(self):+ """OpenAI Codex Responses rejects a high-resolution image on its+ 30000-tile-patch ceiling with wording that contains none of the+ image-size vocabulary ("requires N patches after processing,+ exceeding the limit"). It used to fall through to format_error /+ non-retryable, so the shrink recovery was bypassed and the session+ kept failing (or failover re-sent the same invalid image) (#106337).+ """+ err = _FakeApiError(+ status_code=400,+ message=(+ "The image you provided requires 33174 patches after processing, "+ "exceeding the limit of 30000. Please resize the image and try again."+ ),+ )+ result = classify_api_error(err, provider="openai-codex", model="gpt-5.6-sol")+ assert result.reason == FailoverReason.image_too_large+ assert result.retryable is True+def test_unrelated_400_still_not_image_too_large(self):"""The new "media" patterns must not widen into ordinary 400s."""err = _FakeApiError(