Skip to content

Infinite retry loop on folder read with images; bad image_url payload (400) and ignored interruption #3050

Closed

Description

@InfantLab

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

  1. Prepare a folder with .md files plus *.png/*.jpg.
  2. Ask the agent to “read this folder”.
  3. Observe attempts to open an image → 400 → loop.
  4. Try interrupting; loop persists until quitting.

Actual Behavior

  • Agent tried to process an image during folder read.
  • Built image_url with MIME text/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_url with text/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_error as 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}"

Activity

  1. added
    bug
    on Sep 2, 2025
  2. Difficulty-in-naming commented on Sep 3, 2025

    @Difficulty-in-naming

    我回退了版本到0.25.0绕过了这个错误

  3. Qualzz commented on Sep 3, 2025

    @Qualzz

    Same error.

  4. fsfra commented on Sep 24, 2025

    @fsfra

    Same error

    stream error: unexpected status 400 Bad Request:
    { "error": { "message": "Invalid 'input[...].content[...].image_url'. Expected a base64-encoded data URL …" } }

  5. aemotyka commented on Oct 8, 2025

    @aemotyka

    Same.

    unexpected status 400 Bad Request: { "error": { "message": "Invalid 'input[305].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/html'.", "type": "invalid_request_error", "param": "input[305].content[0].image_url", "code": "invalid_value" } }

    Had been having a normal, lengthy coversation with codex medium. No new major changes in my repo, no new files, just normal edits...

  6. Artein commented on Oct 17, 2025

    @Artein

    Same in the latest v0.46.0:

    ⚠️ stream error: unexpected status 400 Bad Request: {
      "error": {
        "message": "Invalid 'input[45].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/
    plain'.",
        "type": "invalid_request_error",
        "param": "input[45].content[0].image_url",
        "code": "invalid_value"
      }
    };
    
  7. zhao-oai commented on Oct 29, 2025

    @zhao-oai
    Contributor

    this bug is fixed by #5888

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions