Skip to content

Feature Request: Auto-resume CLI session when usage limit resets #21073

Open

Description

@ndycode

What variant of Codex are you using?

CLI

What feature would you like to see?

When Codex hits the usage limit mid-task, the error already tells me exactly when the quota resets (e.g. "try again at 6:34 AM"). If that reset time falls while I'm asleep, the information is wasted — the task just dies and waits for me to wake up, find the session, and re-issue the prompt.

Image

I'd like Codex to automatically continue the session at the reset time, without me being there.

Behavior:

  1. Turn fails with usage limit reached.
  2. Codex reads the reset time it already knows about (resets_at in UsageLimitReachedError).
  3. Instead of erroring out, Codex sleeps until that time and then re-runs the same turn.
  4. I wake up to a finished or in-progress task instead of a frozen one.

Why this is basically free to implement:

The reset timestamp is already structured data in the protocol (codex-rs/protocol/src/error.rs → UsageLimitReachedError.resets_at) and the session already updates rate limits on this error (codex-rs/core/src/session/turn.rs ~line 1075). Today we just throw the timestamp away and crash the turn. The ask is: use it.

Make it opt-in so nothing changes for existing users:

codex --auto-resume-on-limit

or in ~/.codex/config.toml:

[usage_limits]
auto_resume = true

That's it — that's the feature.

Additional information

The screenshot shows the exact message in question: "try again at 6:34 AM". I was asleep at 6:34 AM. The agent could have just kept going.

Related: #15788 covers the App-side queueing of new prompts on usage limit. This is the CLI/session-resume sibling — same idea, different surface.

Activity

  1. changed the title [-]Feature Request: Auto-resume CLI session at usage-limit reset time (so I don't have to wake up at 6:34 AM)[/-] [+]Feature Request: Auto-resume CLI session when usage limit resets[/+] on May 4, 2026
  2. added
    enhancementNew feature or request
    rate-limitsIssues related to rate limits, quotas, and token usage reporting
    enterpriseEnterprise features like OTEL, RBAC, proxy servers, etc.
    on May 4, 2026
  3. RunsenXu commented on May 23, 2026

    @RunsenXu

    Yes. Need this.

  4. ndycode commented on May 25, 2026

    @ndycode
    Author

    @etraut-openai need this though hope you consider.

  5. diogovalada commented on May 26, 2026

    @diogovalada

    It shouldn't just be on quota reset. There should also be automatic recovery from internet connection failures.
    Codex retries to reestablish a connection, but these do nothing if all the retries are done before the connection recovers.

    #22033

  6. ndycode commented on Jun 2, 2026

    @ndycode
    Author

    oh god please add this feature. :(

  7. AaronZLT commented on Jun 5, 2026

    @AaronZLT

    +1

  8. Lodenk commented on Jun 13, 2026

    @Lodenk

    Please enable this!

  9. alqtest commented on Jul 4, 2026

    @alqtest

    We need this please

  10. arikon commented on Jul 12, 2026

    @arikon

    Confirmed the same gap specifically with a durable Codex Goal in the macOS app.

    Observed state after quota exhaustion:

    {
      "status": "usageLimited",
      "tokensUsed": 174563,
      "remainingTokens": null
    }

    The UI reported the reset time, but reaching that time did not generate a continuation turn. The goal only resumed after a new user message. This is particularly surprising for Goal mode because the durable objective and continuation contract are still present, yet usageLimited behaves as a terminal scheduler state rather than a timed waiting state.

    Suggested Goal-specific behavior:

    1. Persist resets_at together with the goal state.
    2. Transition usageLimited -> waiting_for_quota.
    3. At resets_at plus bounded jitter, revalidate quota and enqueue exactly one synthetic continuation.
    4. Preserve the full durable goal objective and audit the resume event.
    5. Use bounded retries/backoff and stop on user-input, authorization, destructive-action, or repeated-blocker states.
    6. Expose an opt-in App/Goal setting and a visible “will resume at …” control with cancel/resume-now actions.

    This complements the CLI proposal here: the same primitive should work for App Goal continuations, not only a foreground CLI process sleeping until reset.

  11. saaranshM commented on Jul 19, 2026

    @saaranshM

    I ended up building this as an external tool while waiting for native support:

    https://github.com/saaranshM/unsnooze

    Codex turned out to be a little fiddly because there's no event when a session stops due to a usage limit. Instead, unsnooze watches the terminal for the exact limit banners used by Codex and handles all of the reset formats it emits:

    • "Try again at 3:51 PM"
    • Absolute dates
    • Relative durations like "in 4 days 20 hours"

    When the limit expires, it resumes the original session with codex resume <session-id>.

    The pleasant surprise was discovering that the rollout files under ~/.codex/sessions contain the actual reset timestamp as a Unix epoch. That means the wait is based on the exact server-provided reset time rather than parsing human-readable text, and it works equally well for the CLI, the IDE extension, and the ChatGPT desktop app because they all write the same rollout data.

    It's MIT licensed, installs with:

    npm i -g unsnooze

    It also supports Claude Code and several other AI coding CLIs.

  12. 201224tlx-sketch commented on Aug 31, 2026

    @201224tlx-sketch

    I built an unofficial external reference implementation while native support is still under discussion:

    https://github.com/201224tlx-sketch/codex-auto-resume-watchdog

    The watchdog reads quota state through Codex app-server (account/rateLimits/read) and waits for primary.resetsAt, then verifies that quota is actually available before resuming the same session once. This avoids using repeated codex exec resume calls as a quota poll, which can append duplicate continuation turns.

    It also restores the original session_meta.cwd, persists session/state/log data across restarts, handles reset propagation delay, and backs off when the thread still has an active writer. It has been tested primarily on Windows and is an external wrapper, not an official OpenAI implementation. Native Codex integration would still be cleaner and more reliable.

  13. leomleao commented on Sep 7, 2026

    @leomleao

    Please we need this! Claude got there first.

  14. farquer commented on Sep 8, 2026

    @farquer

    Please we need this! Claude got there first.

  15. Chang-Jin-Lee commented on Sep 9, 2026

    @Chang-Jin-Lee

    Two things that may help whoever picks this up: the request is fragmented across five open issues, and a competing CLI shipped it since this was filed.

    Five open issues are asking for the same behaviour, split by surface rather than by mechanism:

    issue opened surface
    this one, #21073 2026-05-04 CLI session
    #28931 2026-06-18 /Goal after a 5h limit
    #31386 2026-07-07 paused Goals when quota refreshes
    #34188 2026-07-19 suspend and auto-resume instead of stopping the session
    #43605 2026-09-07 persistent auto-resume for Goals and long-running tasks

    docs/contributing.md asks people to "upvote an existing request that describes the same need", so the split is working against the process rather than against the idea — four months of demand reads as five small asks instead of one. Consolidating onto whichever of these you prefer would make the signal legible, and this one has the most specific proposal.

    The mechanism underneath them is one thing, not five: a turn ends with a known resets_at, and nothing waits for it. Scoping the fix where that timestamp already lands — the session layer, per this issue's own pointer at UsageLimitReachedError.resets_at — covers CLI, Goals and long-running tasks together. Solving it per surface is what produced five issues.

    Claude Code shipped exactly this on 2026-08-17, three months after this issue was opened, so nobody on the thread has seen it. From its changelog for 2.1.234, verbatim:

    Claude Code now continues your session automatically when a claude.ai usage limit resets; turn it off in /config ("Continue automatically at usage limit")

    Two details in that shape are worth borrowing regardless of what gets built here. It defaults to on, with the off switch in config rather than a flag you have to remember at launch — which matters because the case the feature exists for is the one where you are not at the keyboard to pass a flag. And the resumption is a continuation of the existing session rather than a fresh turn; in practice the resumed context is told to continue the interrupted work and not to redo what already completed, which is the difference between resuming and restarting.

    That second point is the part worth specifying before implementing. --auto-resume-on-limit as proposed in the body would re-run the same turn; re-running a turn that had already written files or run commands is not always safe. A continuation prompt that states what was interrupted is cheaper to get right than a replay.

  16. acts-1631 commented on Sep 9, 2026

    @acts-1631

    Seriously needed! Constantly hitting usage limits now that the 5h window is back.

  17. amir1376irani commented on Sep 10, 2026

    @amir1376irani

    +1

  18. p30arena commented on Oct 2, 2026

    @p30arena

    We want this ASAP

  19. quanhuayang commented on Oct 3, 2026

    @quanhuayang

    I would also like this feature in Codex CLI. My installed version is 0.159.3.

    The requested workflow is: when a task is interrupted because the five-hour rolling usage allowance is exhausted, preserve the current session and unfinished task, wait until the applicable allowance becomes available again, and automatically continue without requiring me to type "continue" or manually resume the session.

    This would make long unattended tasks much more useful: reaching the usage limit would pause the work rather than require the user to return at the reset time.

    An opt-in setting or session action, a visible waiting status/reset countdown, and a way to cancel the scheduled continuation would be helpful. Automatic continuation should preserve the existing model and permission settings, respect any other exhausted quota, and continue from the saved task state rather than blindly repeat already completed actions.

    Please consider adding native support for this workflow. This is a feature request, not a claim that I have reproduced a new defect.

  20. songyb111-gachon commented on Oct 5, 2026

    @songyb111-gachon

    For people on the Codex desktop app on Windows, there is now an unofficial external tool for this too: Codex Auto Resume - https://github.com/songyb111-gachon/codex-auto-resume-windows

    When a conversation stops on a usage limit, it waits for the reset time Codex itself reports, checks that usage is really available again and that nothing newer happened in that conversation, and then sends one continuation to that exact conversation (by its thread UUID) through the official codex queue command - no GUI automation, nothing typed into the window. It also recovers failures it can name (429, network, 5xx, dropped streams), waits rather than sends whenever it is unsure, and never resends a message that may already have been delivered.

    To be clear about the scope: Windows 10/11 and the Codex desktop app only, not the CLI yet. A conversation the app has unloaded (after an app restart, for example) is resumed once you open it again.

    It is MIT-licensed and not affiliated with OpenAI. Native support would still be the better answer; this is only meant to bridge the gap until then.

  21. piemvibes-hue commented on Oct 8, 2026

    @piemvibes-hue

    I hit this constantly — overnight tasks dying on stream disconnects / limit resets / WebSocket-reconnect limbo (#30933). Until official auto-resume lands I built a small watchdog: it watches ~/.codex (rollout JSONLs + the sqlite stores), classifies the failure, and resumes the exact thread — codex queue for threads a surface holds open, codex exec resume for dead/exec threads (queued messages to dead threads just sit unread in queue_1.sqlite, verified). Usage limits wait for the actual resets_at time. It then verifies the thread is producing events again and pings you over ntfy.sh/webhook if it gives up. MIT, zero deps: https://github.com/piemvibes-hue/agentwatch

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

    enhancementNew feature or requestenterpriseEnterprise features like OTEL, RBAC, proxy servers, etc.rate-limitsIssues related to rate limits, quotas, and token usage reporting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions