Skip to content

Codex CLI hangs indefinitely when the workspace is out of credits #6512

Closed

Description

@Jarrodsz
  • 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.
    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).
  3. Watch the spinner: the UI prints repeated Processing request (elapsed …) lines forever and never emits a result or an error.

Expected Behavior

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.

Activity

  1. added
    bug
    CLI
    rate-limits
    on Nov 11, 2025
  2. github-actions commented on Nov 11, 2025

    @github-actions
    Contributor

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

    Powered by Codex Action

  3. etraut-openai commented on Nov 11, 2025

    @etraut-openai
    Contributor

    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.

  4. Jarrodsz commented on Nov 11, 2025

    @Jarrodsz
    Author

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

  5. removed
    CLI
    on Dec 23, 2025
  6. etraut-openai commented on Jan 28, 2026

    @etraut-openai
    Contributor

    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.

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

    bugrate-limits

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions