`codex exec` hangs indefinitely — `codex_models_manager` logs "timeout waiting for child process to exit", no error surfaced, no recovery

Open
#34,397 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
rust
Domain
cli, networking

Research direction

Start with the codex_models_manager::manager refresh path and reproduce the related failure using codex doctor --json, then compare it with the non-interactive codex exec invocation described here. Done means a failed model refresh cannot stall the main exec loop indefinitely and that an unrecoverable failure produces a clear error or bounded exit.

Written by the indexing model from the issue text.

Description

bug CLI exec tool-calls

What version of Codex CLI is running?

0.144.1 (installed via Homebrew cask codex; 0.144.3 is available upstream as of 2026-07-20, not yet tried — unknown whether it addresses this)

What subscription do you have?

ChatGPT Pro (auth.credentials.stored auth mode: "chatgpt", not an API key)

Which model were you using?

gpt-5.6-sol, invoked via codex exec directly (not through gpt-5.6-luna/-terra, so this doesn't look model-specific)

What platform is your computer?

Darwin 25.4.0 arm64 arm (macOS, Apple Silicon)

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

Not applicable — codex exec was launched non-interactively from an automation wrapper (nohup bash -c 'codex exec ...' > log 2>&1 &), no interactive terminal/TTY attached, stdin redirected from /dev/null.

Codex doctor report

codex doctor --json currently and reproducibly reports overallStatus: "fail", with one failing check:

{
  "id": "network.provider_reachability",
  "category": "network",
  "status": "fail",
  "summary": "one or more required provider endpoints are unreachable over HTTP",
  "details": {
    "ChatGPT base URL": "https://chatgpt.com/backend-api/ request timed out (required)",
    "reachability mode": "ChatGPT auth"
  },
  "remediation": "Check proxy, VPN, firewall, DNS, and custom CA configuration."
}

This is reproducible on demand (ran twice, ~1 hour apart, same result both times). For context, on the same machine at the same time:

  • No proxy env vars are set (HTTP_PROXY/HTTPS_PROXY/etc. all unset).
  • DNS resolves chatgpt.com fine (104.18.32.47, 172.64.155.209 — Cloudflare).
  • A plain curl -sS --max-time 15 https://chatgpt.com/backend-api/ returns HTTP 403 in 5.6s — a real (if unauthenticated-appropriate) response, not a timeout.

So whatever codex doctor's reachability probe is doing to that URL behaves differently from a bare HTTPS GET, and consistently times out where curl succeeds.

What issue are you seeing?

A non-interactive codex exec dispatch (long-running planning/spec-review task, several tool calls executed successfully first) stalled permanently partway through. Its stderr showed:

2026-07-20T17:40:18.405988Z ERROR codex_models_manager::manager: failed to refresh available models: timeout waiting for child process to exit
2026-07-20T17:43:23.407528Z ERROR codex_models_manager::manager: failed to refresh available models: timeout waiting for child process to exit
2026-07-20T17:46:28.409987Z ERROR codex_models_manager::manager: failed to refresh available models: timeout waiting for child process to exit

Three occurrences, ~185s apart (looks like a periodic internal refresh timer). After the first occurrence, no further activity appeared in the log at all — no more tool calls, no more agent turns, nothing — for as long as we let it run. The process consumed ~0% CPU (confirmed via ps), i.e. genuinely idle/blocked, not churning. It only stopped because our own wrapper had an external 15-minute wall-clock timeout that force-killed it (pkill -f "codex exec"); codex exec itself never exited, errored, or recovered on its own, and nothing was surfaced to the calling process to indicate anything was wrong beyond those three stderr lines.

Given the concurrent codex doctor finding above, our working theory is: the codex_models_manager's periodic model-list refresh depends on reaching https://chatgpt.com/backend-api/ (consistent with reachability mode: "ChatGPT auth"), that network call (or a child process performing it) is hanging rather than timing out cleanly, and — critically — that internal background task's hang appears to block or otherwise permanently stall the main codex exec turn loop, rather than failing independently in the background the way a "refresh available models" task probably should.

What steps can reproduce the bug?

We don't yet have a minimal, fully isolated repro for the main-loop stall itself (it's occurred during long, multi-hour sessions with many concurrent codex exec dispatches against the same ChatGPT-plan account, so we can't rule out some concurrency/rate factor). However, the related codex doctor symptom is reproducible on demand right now:

  1. Ensure codex is authenticated via ChatGPT plan login (not API key).
  2. Run codex doctor --json.
  3. Observe network.provider_reachability fail with "request timed out" for https://chatgpt.com/backend-api/, while a plain curl to the same URL from the same machine at the same time succeeds.

For the main-loop stall itself, the invocation shape that triggered it was:

codex exec --cd . --sandbox read-only -m gpt-5.6-sol --output-last-message /tmp/out.md "<long planning/spec-review prompt>" < /dev/null > /tmp/out.log 2>&1 &

run under nohup from a non-interactive automation wrapper, no TTY.

What is the expected behavior?

codex exec should not hang indefinitely with zero CPU usage and zero surfaced error when its internal model-refresh mechanism can't complete. At minimum: the background refresh failing should not be able to stall the main task turn loop; and/or codex exec should itself time out and exit with a clear, actionable error (e.g. "could not reach ChatGPT backend, retrying" / "giving up after N attempts") rather than running forever with no indication anything is wrong beyond intermittent stderr lines an automated caller has no reliable way to watch for.

Additional information

We've worked around this on our side with an external wall-clock timeout + process-group kill around every non-interactive codex exec dispatch, since codex exec itself provides no way to detect or recover from this state. That's a caller-side mitigation, not a fix — happy to share the wrapper script or more detail if useful for triage.

Dominant language
Rust
Stars
125k
Forks
19.5k
Avg merge
1m
Merged PRs (30d)
1k

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openai/codex

All issues in openai/codex

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.