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

Open 💬 3 comments Opened May 16, 2026 by okamototomoyuki
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

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

View original on GitHub ↗

3 Comments

github-actions[bot] contributor · 3 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #22089
  • #22394
  • #22116

Powered by Codex Action

okamototomoyuki · 3 months ago

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}
okamototomoyuki · 3 months ago

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.

https://github.com/openai/codex/issues/18960