Skip to content

Session failures: retry-after countdown and usage-limit error types #832

Closed

Description

@ivanfenenko

Why

When a provider refuses a run because of a usage limit, the transcript shows a plain failure line. OpenCode v2 now tells clients how long to wait (retryAfterMs) and which limit was hit (new error types), so the app can say when to try again and offer the right next step.

Upstream (anomalyco/opencode)

Where this lives in the apps

These errors are run failures, not HTTP request errors. They reach the app as a SessionFailure (Android domain/message/MessageModels.kt, iOS Domain/Message/MessageModels.swift), built from the v2 error DTO (Android V2UnknownErrorDto in data/remote/dto/V2MessageDtos.kt, iOS Data/Remote/V2MessageDTOs.swift), and appear as the failure mark in the Session Chat transcript. ServerErrorMessage is not involved.

The live retry countdown card above the composer (SessionRetryCountdown, driven by the session retry status and its next time) already covers the case where the server is still retrying. coversLiveRetry() hides the transcript mark for provider.rate-limit / provider.quota while that card is up. This issue does not change that card.

Scope (Android + iOS, one Feature Slice)

  1. Read retryAfterMs. Add it to the v2 error DTO and to SessionFailure, along with the time the failure was recorded (the failed message's completion time; if that is missing, the time the app received the failure).
  2. "Try again in N s" on the failure mark. When the failure on the last turn (no user message after it) has retryAfterMs, its transcript failure mark shows "Try again in N s" on its own line below the existing caption (HTTP 429 · <message> stays unchanged, so the long server message is not cut off), counting down to recorded time + retryAfterMs. Use minutes once it is over 90 s ("Try again in 4 min"). At zero the line disappears and the mark reads as it does today. If the time has already passed when the session opens, show no line. Failures on earlier turns never show a countdown.
  3. Live retry takes priority. While the session is in retry status, the composer countdown card is the only countdown: no failure mark shows the "Try again" line, whatever its error type. coversLiveRetry() keeps hiding provider.rate-limit / provider.quota marks as it does today.
  4. Actions for the new types (in the existing provider failure sheet / action()):
    • provider.free-limit → "Pick a model" (FailureAction.PickModel).
    • provider.model-budget-limit → "Pick a model".
    • provider.budget-limit → no action; the countdown (if retryAfterMs is present) is the guidance.
    • Add the budget types now: servers that don't send them are unaffected.
  5. No change for v1 or older v2 servers. No retryAfterMs means no hint; unknown types keep today's caption and actions.

Out of scope

  • A Retry / resend button when the countdown ends. The app has no "resend last prompt" action; that needs its own issue.
  • Changes to the composer retry countdown card.
  • ServerErrorMessage (HTTP request error text).

Done when

  • On a v2.1.2+ server, a failure with retryAfterMs on the last turn shows a "Try again in …" countdown line under its transcript failure mark on both platforms, it disappears at zero, and it never shows while the session is in retry status.
  • provider.free-limit shows the server's limit message and a "Pick a model" action on both platforms.
  • provider.budget-limit and provider.model-budget-limit map as above (covered by unit tests with payloads from feat(core): read OpenCode Console usage limits and classify budget refusals anomalyco/opencode#58694, since no release sends them yet).
  • v1 servers and failures without retryAfterMs look exactly as they do today (unit test on each platform).

Activity

  1. changed the title [-]Session errors: retry-in hint and limit/budget error messages[/-] [+]Session failures: retry-after countdown and usage-limit error types[/+] on Oct 25, 2026
  2. added 2 commits that reference this issue on Oct 25, 2026
  3. added a commit that references this issue on Oct 25, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions