Skip to content

Session retries fixed-window usage quota errors until reset #39790

Closed as not planned

Description

@vinlee19

Description

When a provider returns a retryable HTTP 429 such as:

You have exceeded the 5-hour usage quota. It will reset at 2026-07-30 16:11:46 +0800 CST.

OpenCode keeps retrying through SessionRetry.policy() even though another attempt cannot succeed before the fixed quota window resets. This generates repeated requests for hours and leaves the session in retry state.

Known long-window quota errors (5-hour, weekly, or monthly) should stop immediately. Short-lived rate limits should continue using the existing retry behavior.

Related to #21960. #38958 proposes a general retry cap; this issue covers early classification of a known terminal quota response.

Plugins

None required.

OpenCode version

1.18.9

Steps to reproduce

  1. Configure an OpenAI-compatible provider that enforces a fixed usage quota.
  2. Exhaust its 5-hour usage quota.
  3. Submit another prompt.
  4. Observe OpenCode repeatedly retry the same 429 response instead of ending the request.

Operating System

macOS

Activity

  1. github-actions commented on Jul 31, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. vinlee19 commented on Jul 31, 2026

    @vinlee19
    Author

    Confirmed that #24011 describes the same class of bug. It was automatically closed after inactivity with instructions to open a new issue if the problem remained relevant, and its PR #24013 was closed by automated cleanup without merging.

    This report is a current reproduction on 1.18.9 with a 5-hour quota response. PR #39791 uses narrower long-window matching, checks the retained response body, and includes regression coverage for transient per-minute quotas.

  3. ApexMene commented on Sep 6, 2026

    @ApexMene

    Opened #47641 for this.

    One concrete source is zen itself: an exhausted free tier returns 429 with retry-after set to the seconds left until the next daily reset (getRetryAfterDay in packages/console/app/src/routes/zen/util/ipRateLimiter.ts), and SessionRetry.delay() honors that header up to RETRY_MAX_DELAY, so the session parks on a single attempt that can be up to 24h out. Nothing is logged after the first stream error, and inside a subagent even the retry status is invisible because it is published on the child session ID.

    The PR stops the schedule when the requested wait is longer than 5 minutes, after publishing the retry status so the free tier and Go limit dialogs still fire. Short rate limits keep the current behavior.

  4. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions