Skip to content

Proactive quota-aware task planning to avoid mid-task interruption #42182

Open

Description

@FezTorres

What variant of Codex are you using?

App (macOS), CLI, IDE Extension

What feature would you like to see?

Codex should be aware of the user's remaining 5-hour and weekly usage quotas and actively use them as constraints when planning and executing long-running tasks.

Currently, Codex can begin a large multi-step task without considering whether the remaining quota is sufficient to complete it. This can result in quota exhaustion in the middle of implementation, testing, validation, cleanup, or other important completion steps.

Simply displaying the remaining quota to the user does not fully solve this problem. In an agentic workflow, Codex itself should be able to reason about the finite execution budget available to it.

Ideally, Codex should:

  • Check the remaining 5-hour and weekly quota before starting a substantial task.
  • Re-check the remaining quota periodically during long-running work.
  • Estimate, even approximately, whether the remaining work is likely to fit within the available quota.
  • Adjust the scope, order, or depth of work when quota becomes constrained.
  • Prioritize completing coherent units of work instead of starting additional unfinished work.
  • Reserve sufficient quota for validation, tests, cleanup, and checkpointing.
  • Create safe checkpoints before the remaining quota becomes critically low.
  • Split large tasks into independently completable stages when necessary.
  • Warn the user before starting if the requested task is unlikely to finish within the available quota.
  • Where appropriate, choose a lower-cost model or execution strategy in order to preserve enough quota to complete the task.

Perfect prediction of quota consumption is not required. Approximate, risk-aware planning would already be a significant improvement.

For example, if only a small amount of weekly quota remains and the user requests a repository-wide refactor, Codex should avoid starting every part of the refactor at once. It could instead:

  1. Complete the highest-priority implementation.
  2. Run the most important tests.
  3. Create a checkpoint or commit.
  4. Re-evaluate the remaining quota.
  5. Continue with secondary cleanup only if sufficient quota remains.

The key request is:

Treat the remaining usage quota as an explicit planning constraint, and actively manage the work so that the probability of an incomplete task due to quota exhaustion is minimized.

This is particularly important for an autonomous coding agent. In a normal chat interface, reaching a usage limit mainly interrupts a conversation. In an agentic coding workflow, it can interrupt an engineering process after files have already been modified but before the task has been safely completed or validated.

Additional information

No response

Activity

  1. added
    enhancement
    on Sep 2, 2026
  2. added
    CLI
    extension
    app
    rate-limits
    plan
    on Sep 2, 2026
  3. github-actions commented on Sep 2, 2026

    @github-actions
    Contributor

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

    Powered by Codex Action

  4. FezTorres commented on Sep 2, 2026

    @FezTorres
    Author

    Thanks for flagging #40905. I reviewed it before opening this issue.

    I believe this request is related but not a duplicate.

    #40905 primarily addresses what should happen when long-running work approaches or encounters a quota boundary, including checkpointing and continuation.

    This request focuses on an earlier stage: Codex should proactively use its remaining 5-hour and weekly quota as an input to task planning itself.

    The goal is for Codex to adjust scope, ordering, validation, checkpoint timing, and potentially model/execution strategy before quota exhaustion becomes imminent, so that it minimizes the probability of leaving work incomplete.

    In short:

  5. LUMOSSES commented on Sep 4, 2026

    @LUMOSSES

    I implemented a local PoC for the behavior proposed here and wanted to share the results.

    Project: https://github.com/LUMOSSES/QuotaGuard
    Release: https://github.com/LUMOSSES/QuotaGuard/releases/tag/v0.1.0

    It reads the real Codex five-hour and weekly quota through account/rateLimits/read, then treats the remaining quota as an execution constraint rather than only displaying it. The current PoC implements NORMAL, CAUTION, and SAFE_LANDING, together with task-stage admission, burn-rate replanning, durable checkpoints, and exact resume actions.

    At low quota it refuses to start unsafe new stages, verifies the current work, records repository/test state, writes a checkpoint, and stops with a concrete next action. The scripted demo shows 32% remaining → CAUTION → Stages 1–2 complete → 18% → SAFE_LANDING → Stage 3 denied → checkpoint → successful resume: https://github.com/LUMOSSES/QuotaGuard#safe-landing-demo

    The project also dogfooded this behavior: during development the real five-hour quota dropped to about 14%, so QuotaGuard entered SAFE_LANDING, deferred its own remaining demo work, and resumed from the checkpoint in the next window.

    QuotaGuard does not bypass or extend Codex usage limits. It treats them as a scheduling constraint.

  6. FezTorres commented on Sep 4, 2026

    @FezTorres
    Author

    Thank you very much for taking the time to build and test this PoC.

    This is very close to the behavior I had in mind when opening this issue. In particular, treating the remaining quota as an execution constraint — rather than merely exposing it as information — is exactly the distinction I was trying to highlight.

    The NORMAL / CAUTION / SAFE_LANDING approach, together with stage admission, replanning, checkpointing, and explicit resume actions, is a very useful demonstration of how this could work in practice.

    I also find it particularly interesting that this can already be implemented using the existing account/rateLimits/read interface. That suggests that at least part of the necessary infrastructure is already available.

    Your dogfooding example is especially compelling: the fact that QuotaGuard itself detected the declining quota, deferred additional work, created a safe checkpoint, and resumed in the next window is a concrete example of the reliability benefit I was hoping this feature could provide.

    Ideally, I would still like to see this kind of quota-aware planning integrated directly into Codex itself, so that users do not need an additional local tool or custom skill to obtain this behavior. But as a PoC, QuotaGuard provides a very helpful and practical demonstration that the concept is feasible.

    Thank you again for sharing the project and the results here.

  7. LUMOSSES commented on Sep 4, 2026

    @LUMOSSES

    Thanks — that was exactly the distinction I wanted to test as well: whether quota can become part of the execution policy rather than just telemetry.

    The existing account/rateLimits/read surface made the PoC surprisingly straightforward on the sensing side; most of the work ended up being around policy, stage admission, and recoverable state.

    I agree that the ideal end state would be native Codex behavior rather than requiring a separate Skill. I’ll keep dogfooding the PoC and share any useful observations here, especially around burn-rate estimation and when safe landing should trigger.

  8. FezTorres commented on Sep 7, 2026

    @FezTorres
    Author

    Thank you — I really appreciate you continuing to test this in practice.

    I’m particularly interested in what you learn about burn-rate estimation and SAFE_LANDING thresholds, since those seem to be the key pieces for making quota-aware planning reliable rather than merely reactive.

    I’ll be following your updates here with interest.

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

    CLIappenhancementextensionplanrate-limits

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions