Skip to content

fix(session): retry schedule has no upper bound on attempts #26354

Closed as not planned

Description

@truenorth-lj

Problem

policy() in packages/opencode/src/session/retry.ts has no numeric cap on the retry schedule. It continues as long as retryable() returns a truthy value, which means a misclassified-retryable error (or an upstream that's permanently unhealthy but keeps emitting retryable signals) can cause the schedule to spin without bound.

Reproduction

  1. Construct an error that retryable() always classifies as retryable (e.g. an APIError with isRetryable: true and a 5xx status).
  2. Drive policy() with that error repeatedly.
  3. Observe: the schedule never terminates from the policy side. The only termination is whatever caller-side timeout exists.

Proposal

Add a numeric cap alongside the other RETRY_* constants and check it in the policy step function:

export const RETRY_MAX_ATTEMPTS = 3

// inside policy() schedule step:
if (meta.attempt > RETRY_MAX_ATTEMPTS) return Cause.done(meta.attempt)

With the existing 2-4-8 s backoff this gives a wall-clock retry budget of ~14 s for a worst-case run, which feels appropriate for a TUI-attached LLM call.

Out of scope

Custom error-classification headers / non-standard retry vocabulary. Proxies wanting to short-circuit retries can do so through standard HTTP semantics already handled by retryable():

  • 429 + Retry-After for rate limits
  • 503 + Retry-After for provider unavailable
  • 402 for budget (4xx → no retry)
  • 400 for context overflow (4xx → no retry)

Activity

  1. github-actions commented on May 8, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • Feature requests must use the Feature Request issue template: the title should start with [FEATURE]: and the template's verification checkbox must be included.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


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

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. changed the title [-]feat(session): bounded retry policy + honor X-Llm-Error-* response headers[/-] [+]fix(session): retry schedule has no upper bound on attempts[/+] on May 8, 2026
  3. github-actions commented on May 8, 2026

    @github-actions
    Contributor

    Thanks for updating the issue! It now clearly describes the bug with a specific file reference, reproduction steps, and a concrete proposal. The needs:compliance label has been removed.

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