codex should sleep/delay upon hitting TPM rate limit, not crash

Resolved 💬 2 comments Opened Apr 22, 2025 by J-a-n-u-s Closed Apr 22, 2025
💡 Likely answer: A maintainer (tibo-openai, collaborator) responded on this thread — see the highlighted reply below.

What version of Codex is running?

0.1.2504211509

Which model were you using?

gpt-4.1-mini

What platform is your computer?

darwin | x64 | 22.6.0

What steps can reproduce the bug?

Hit TPM rate limit.

What is the expected behavior?

Codex should sleep / delay, or return to user input indicating which rate limit was hit, and allow user to retry.

What do you see instead?

It crashes out/exits when rate limit is hit

Additional information

Am not sure if this is a bug or feature request, so please feel free to move to feature request at your discretion.

View original on GitHub ↗

2 Comments

tibo-openai collaborator · 1 year ago

Should be fixed in latest release, please install 0.1.2504221401 and re-open if this is still an issue you encounter.

vadz · 1 year ago

This is not fixed when using 0.1.2505172129 with gpt-4.1, it crashes after several minutes of working with the following message:

[Error]: Rate limit reached for gpt-4.1 in organization org-xxx on tokens per min (TPM): Limit 30000, Used 4828, Requested 25212. Please try again in 80ms. Visit https://platform.openai.com/account/rate-limits to learn more.
    at e.a [as iterator] (file:///.../lib/node_modules/@openai/codex/dist/cli.js:582:1514)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async ky.run (file:///.../lib/node_modules/@openai/codex/dist/cli.js:599:2785) {
  status: undefined,
  headers: undefined,
  request_id: undefined,
  error: {
    type: 'tokens',
    code: 'rate_limit_exceeded',
    message: 'Rate limit reached for gpt-4.1 in organization org-xxx on tokens per min (TPM): Limit 30000, Used 4828, Requested 25212. Please try again in 80ms. Visit https://platform.openai.com/account/rate-limits to learn more.',
    param: null
  },
  code: 'rate_limit_exceeded',   
  param: null,
  type: 'tokens'
}

Node.js v22.17.0