Infinite retry loop on folder read with images; bad image_url payload (400) and ignored interruption
Resolved 💬 6 comments Opened Sep 2, 2025 by InfantLab Closed Oct 29, 2025
Title: Infinite retry loop when “read folder” hits an image; sends text/markdown as image_url (400), ignores user interruption
Description
Requesting the agent to read a folder with mixed content caused it to attempt processing an image. The run entered an unescapable retry loop after a 400 error. Interrupting and changing instructions had no effect; the session had to be quit. The API error indicates the agent constructed an image content payload with MIME text/markdown instead of a proper image data URL.
Environment
- CWD:
D:\\brain-dev - OS: Microsoft Windows NT 10.0.26220.0
- Shell: PowerShell
7.5.2 - Git:
2.49.0.windows.1 - Codex CLI:
0.27.0 - Sandbox:
workspace-write - Approvals:
on-request - Network:
restricted
Steps to Reproduce
- Prepare a folder with
.mdfiles plus*.png/*.jpg. - Ask the agent to “read this folder”.
- Observe attempts to open an image → 400 → loop.
- Try interrupting; loop persists until quitting.
Actual Behavior
- Agent tried to process an image during folder read.
- Built
image_urlwith MIMEtext/markdown. - Entered retry loop; ignored interruption.
- Required quitting the session.
Expected Behavior
- Reads only text by default; images opened only if requested.
- Images sent as
data:image/*;base64,...when needed. - 4xx validation errors are non-retryable; agent adapts or asks.
- User interruptions halt retries immediately.
Error Log
unexpected status 400 Bad Request: {
"error": {
"message": "Invalid 'input[28].content[0].image_url'. Expected a base64-encoded data URL with an image MIME type
(e.g. 'data:image/png;base64,aW1nIGJ5dGVzIGhlcmU='), but got unsupported MIME type 'text/markdown'.",
"type": "invalid_request_error",
"param": "input[28].content[0].image_url",
"code": "invalid_value"
}
}
Impact
- Blocks mixed-folder reads; high workflow disruption.
Suspected Root Cause
- Misclassification of file type leading to building an
image_urlwithtext/markdown. - Missing MIME detection and data-URL encoding for images.
- Retry policy treats 4xx validation errors as retryable and doesn’t respect user override.
Proposed Fixes
- Robust MIME/type detection; only send images as
data:image/*;base64,.... - Default skip binary files for “read folder”; prompt to open images.
- Treat 4xx
invalid_request_erroras non-retryable; stop and ask. - Ensure user interruption cancels queued retries/steps.
- Provide “list-only” and “read-only .md/.txt” modes.
Workarounds
- “List filenames only; skip images/binaries.”
- “Read only .md files in FOLDER; do not open images.”
- Manually list:
rg --files -g "!**/*.{png,jpg,jpeg,gif,webp}"
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗