Skip to content

Codex CLI waits ~30 minutes with ERROR: Reconnecting... before reporting image generation rejection #23015

Open

Description

@okamototomoyuki

What version of Codex CLI is running?

codex-cli 0.130.0

What subscription do you have?

ChatGPT Plus

Which model were you using?

gpt-5.5 medium

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What terminal emulator and version are you using (if applicable)?

VS Code

Codex doctor report

What issue are you seeing?

When image generation is rejected by the image generation tool, Codex CLI does not fail immediately.

Instead, it repeatedly shows reconnect messages such as:

ERROR: Reconnecting... 2/5
ERROR: Reconnecting... 3/5
ERROR: Reconnecting... 4/5
ERROR: Reconnecting... 5/5

This reconnect loop continues for around 30 minutes before Codex finally responds that the image generation failed or was rejected.

Example of the final response:

The initial image generation tool call failed. The detailed reason was not returned, so I adjusted the prompt and retried.

Interestingly, this long reconnect wait seems to happen mainly on the first image generation attempt in a request.

After the first attempt, if later image generations are rejected in the same request/session, Codex usually returns the rejection immediately without the long reconnect delay.

What steps can reproduce the bug?

  1. Run Codex CLI using codex exec
  2. Request image generation
  3. Trigger a case where the image generation tool rejects or fails
  4. Observe the reconnect loop

Example:

codex exec "Generate an anime-style female warrior character"

Observed behavior:

ERROR: Reconnecting... 2/5
ERROR: Reconnecting... 3/5
ERROR: Reconnecting... 4/5
ERROR: Reconnecting... 5/5

Codex then waits for around 30 minutes before finally reporting the image generation rejection/failure.

What is the expected behavior?

If image generation is rejected or fails, Codex CLI should fail fast and report the error immediately.

The CLI should not spend around 30 minutes retrying reconnects before returning the rejection result.

Ideally there should also be:

  • a configurable reconnect timeout
  • a fail-fast mode for codex exec
  • an option to disable long reconnect retries for non-interactive batch usage

Additional information

  • ChatGPT web UI image generation returns rejection/failure much faster in the same environment
  • The issue appears related to reconnect handling after image generation tool failure
  • The first failure in a request/session is much slower than subsequent failures

Activity

  1. added
    CLIIssues related to the Codex CLI
    windows-osIssues related to Codex on Windows systems
    execIssues related to the `codex exec` subcommand
    connectivityIssues involving networking or endpoint connectivity problems (disconnections)
    on May 16, 2026
  2. github-actions commented on May 16, 2026

    @github-actions
    Contributor
  3. changed the title [-]Codex CLI image generation stuck on ERROR: Reconnecting... X/5 for ~30 minutes before generation starts[/-] [+]Codex CLI waits ~30 minutes on ERROR: Reconnecting... after first image generation rejection[/+] on May 16, 2026
  4. changed the title [-]Codex CLI waits ~30 minutes on ERROR: Reconnecting... after first image generation rejection[/-] [+]Codex CLI waits ~30 minutes with ERROR: Reconnecting... before reporting image generation rejection[/+] on May 16, 2026
  5. okamototomoyuki commented on May 16, 2026

    @okamototomoyuki
    Author

    I don't know Rust, so I used Codex itself to modify the Codex Rust source and add logging for received responses.

    After doing that, I noticed that when an image generation request is rejected due to policy restrictions, receiving the following response causes Codex to repeatedly attempt reconnection for tens of minutes:

    [codex server response] responses websocket event: {"type":"response.image_generation_call.generating","item_id":"ig_04466fa19493f013016a08f4b5e7ac8191a542a01d5c32fac9","output_index":3,"sequence_number":65}
    
  6. okamototomoyuki commented on May 23, 2026

    @okamototomoyuki
    Author

    As mentioned in the following issue, I also tried sending prompts directly to the Responses API, but the behavior did not improve. This suggests that the issue is likely on the server side of the Responses API itself.

    #18960

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

    CLIIssues related to the Codex CLIbugSomething isn't workingconnectivityIssues involving networking or endpoint connectivity problems (disconnections)execIssues related to the `codex exec` subcommandimagenwindows-osIssues related to Codex on Windows systems

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions