Skip to content

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

Closed

Description

@J-a-n-u-s

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.

Activity

  1. tibo-openai commented on Apr 22, 2025

    @tibo-openai
    Collaborator

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

  2. vadz commented on Jul 1, 2025

    @vadz

    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
    
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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions