Codex CLI hangs indefinitely when the workspace is out of credits

Resolved 💬 4 comments Opened Nov 11, 2025 by Jarrodsz Closed Jan 28, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.
  • severity/high

---

Summary

When a Codex CLI session is started after the account has exhausted its credits, the TUI never surfaces the insufficient_quota error the service returns. The UI keeps showing “Processing request…” forever and the codex process never exits, so every automation that shells out to the CLI hangs until the user manually kills the job. Because this looks like a job that is still running, operators routinely wait 10–15 minutes before realizing nothing will ever complete.

Environment

  • Codex CLI 0.57.0 (codex --version)
  • macOS 26.0.1 (arm64, Apple Silicon)
  • Invoked via non-interactive automation that shells out to codex for every /codex … invocation

Steps to Reproduce

  1. Sign into Codex CLI with an organization/workspace that has zero credits remaining (easy to do after the free trial expires).
  2. From any repo, run a command that spends credits, e.g.

``bash
CODex_CONFIG_ROOT=~/.codex codex run --repo . "git status"
``
(the exact subcommand does not matter; any job that reaches the Codex backend will behave the same way).

  1. Watch the spinner: the UI prints repeated Processing request (elapsed …) lines forever and never emits a result or an error.

Expected Behavior

  • The CLI should detect that the backend returned insufficient_quota/HTTP 402 immediately.
  • Show a clear, actionable error such as “This workspace is out of credits. Visit https://github.com/settings/billing/codex to top up or switch to a funded workspace.”
  • Exit with a non-zero status so scripts can detect the failure in under a second.

Actual Behavior

  • The CLI keeps polling and emitting “Processing request (elapsed …)” indefinitely (I let it sit for ~12 minutes).
  • No error is printed, the spinner never resolves, and the process has to be terminated manually with Ctrl+C.
  • Because the dashboard captures the subprocess stream synchronously, the entire automation loop freezes; no other /codex … commands can run, and longer-running flows never finish.
  • There is no final log entry because we never reach the Codex exited with code … line unless we abort by hand.

Impact

  • Frontline users think Codex is still “working” and end up waiting indefinitely even though the backend rejected the run instantly.
  • Every Codex-backed automation in this repo is single-threaded, so one exhausted account stalls the whole set of agents until an operator notices the lack of progress.
  • CI and tmux helpers expect Codex to fail fast; with the current behavior they block tmux panes forever and the quality gate can never finish.
  • The only workaround today is “remember to keep watching your billing dashboard”, which is extremely brittle for a tool that is supposed to run unattended.

Proposed Fix / Ideas

  1. Treat insufficient_quota, requires_payment_method, and HTTP 402 responses as terminal states in the poller. Break out of the spinner loop and surface the backend error verbatim.
  2. Exit with a unique non-zero code (for example 74) so wrappers can handle “out-of-credits” differently from other API errors (e.g., auto-swap to a backup workspace).
  3. Consider issuing a pre-flight billing check before queueing work so the user sees the error instantly rather than waiting until after the job is submitted.
  4. Bonus: expose a lightweight codex billing status command that prints the remaining credits so automations can gate on it before launching a burst of jobs.

Workaround

Only manual intervention: press Ctrl+C, open the Codex billing page, add credits, and re-run the command. Until the CLI itself exits with a clear error, every higher-level workflow will continue to hang whenever an agent lands on an empty account.

View original on GitHub ↗

4 Comments

github-actions[bot] contributor · 9 months ago

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

  • #6513
  • #4840

Powered by Codex Action

etraut-openai contributor · 9 months ago

Thanks for the bug report and the analysis. Are you pretty sure you're receiving an insufficient_quota result? I recently added logic in the CLI core to do what you suggest here — to detect this error and break out of the agent loop. I think this change was in 0.55.0, so you should definitely have it if you're using 0.57.0. I didn't add code for requires_payment_method. I agree with your suggestion that this should be handled in the same manner.

I don't know that we'd want to exit the CLI entirely when these errors are detected — at least not in interactive mode. For codex exec, it could make sense to exit with a unique exit code.

Jarrodsz · 9 months ago

Yes im definitely on >_ OpenAI Codex (v0.57.0)

etraut-openai contributor · 7 months ago

This bug is pretty old at this point. We've made many changes since then, so I suspect it's no longer relevant. If you're still seeing this problem, let us know and I'll reopen.