codex icon indicating copy to clipboard operation
codex copied to clipboard

Codex hangs at “Initializing agent…” after successful OpenAI response

Open thursdaybw opened this issue 1 year ago • 3 comments

What version of Codex is running?

0.1.2504181820

Which model were you using?

o4-mini

What platform is your computer?

Linux 6.6.84-1-MANJARO x86_64 unknown

What steps can reproduce the bug?

Awesome — here’s a ready-to-go GitHub issue for you to post:

Summary
Codex CLI hangs at the "Initializing agent…" stage, even after receiving a successful 200 OK response from the OpenAI API. This is not the same as hanging on "Thinking…", the backend clearly responds, but Codex never proceeds.


Environment

  • Running in Docker using the official run_in_container.sh sandbox

Steps to reproduce

  1. Launch Codex in a project directory:

    codex "explain generate_cuts.py"
    
  2. Wait until it reaches Thinking…, then:

  3. Observe the CLI output freeze on:

    Initializing agent…
    
  4. Set DEBUG=true and rerun. Observe this key log snippet:

    OpenAI:DEBUG:response 200 https://api.openai.com/v1/responses e [Headers] {
      'openai-processing-ms': [ '1144' ],
      'x-request-id': [ 'req_…' ],
      ...
    }
    

    Yet Codex does not move forward from "Initializing agent…", and never returns a result.

What is the expected behavior?

Codex should proceed with displaying the agent’s reasoning and response after receiving a valid API response.

Let me know if you need more logs — happy to help reproduce.

What do you see instead?

No response

Additional information

Re-running Codex with DEBUG=true shows that OpenAI API responds correctly with 200 OK, and the CLI logs full streamed output. The issue occurs after receiving several valid responses — when it reaches:

Initializing agent…

Codex never recovers from that point.

Key log snippets:

OpenAI:DEBUG:response 200 https://api.openai.com/v1/responses e [Headers] {
  ...
  'x-request-id': [ 'req_e1f39bff9f4066679f1dd99d2a467186' ],
  'openai-processing-ms': [ '1144' ],
  ...
}

command.stdout (code: 0, duration: 0s)
$ grep -R "def assign_labels" -n generate_cuts.py

... hangs here ...

Initializing agent…

thursdaybw avatar Apr 21 '25 07:04 thursdaybw

Same issue here

vinkent420 avatar Apr 21 '25 09:04 vinkent420

I was able to fix the problem by changing the approval mode to full-auto

dev4st3d avatar Apr 21 '25 12:04 dev4st3d

I have the same issue, but I don't trust it enough yet to enable full-auto. My fix has to been to continue using Claude Code while waiting for the next patch.

lewiswil1971 avatar Apr 21 '25 15:04 lewiswil1971