Skip to content

Some transient stream/rate-limit errors bypass retry and terminate sessions #21893

Closed as not planned

Description

@nyl199310

Description

When opencode hits certain transient upstream failures during model streaming, some failures are retried, but others terminate the session immediately. This breaks unattended runs.

Two examples I have seen:

{"type":"error","sequence_number":0,"error":{"type":"upstream_error","code":"stream_read_error","message":"stream_read_error"}}
Type validation failed: Value: ("error": ("type":"rate_limit_error","message":"concurrency limit exceeded for account, please retry later"))

From reading the code, the main session retry path only runs after an error has been normalized into a retryable MessageV2.APIError and accepted by SessionRetry.retryable(). These cases appear to fall through as unknown / validation errors instead, so the run stops instead of retrying.

Observed behavior:

  • Known retryable failures such as some APICallErrors, ECONNRESET, and Bun decompression failures can enter session retry.
  • Some stream-layer / wrapped validation failures with transient upstream semantics do not enter retry.
  • The session ends in error/idle, and the task stops.

Expected behavior:

  • Transient upstream stream errors should be normalized into the existing retry path.
  • Wrapped rate-limit / concurrency-limit failures should still be recognized as retryable.
  • Long unattended tasks should continue after these transient failures instead of stopping.

Potential code paths involved:

  • packages/opencode/src/session/processor.ts
  • packages/opencode/src/session/retry.ts
  • packages/opencode/src/session/message-v2.ts
  • packages/opencode/src/provider/error.ts
  • packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-chat-language-model.ts
  • packages/opencode/src/provider/sdk/copilot/responses/openai-responses-language-model.ts

Plugins

None

OpenCode version

1.4.3 from source, current checkout ce19c051b

Steps to reproduce

  1. Start a long-running agent task that streams model output.
  2. Hit a transient upstream failure during streaming, especially one shaped like stream_read_error or a wrapped rate_limit_error / concurrency-limit validation error.
  3. Observe that the session sometimes stops with an error instead of entering retry state.
  4. Compare with already-classified retryable failures, which do enter retry state and continue.

Screenshot and/or share link

No share link. Error samples included above.

Operating System

Linux (WSL2) 6.6.87.2-microsoft-standard-WSL2

Terminal

xterm-256color

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 10, 2026
  2. github-actions commented on Apr 10, 2026

    @github-actions
    Contributor

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

    If your issue adds new cases (e.g. stream_read_error) not covered by those, please note that in the existing issues or reference them here.

  3. mwroffo commented on Apr 17, 2026

    @mwroffo

    Is this related to #22803 ?

  4. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  5. spark4862 commented on Jun 2, 2026

    @spark4862
    Contributor

    Opened #30323 rebased on current dev with broader OpenAI/Codex stream error coverage (stream_read_error, overload, rate limit), including parseStreamError, retryable(), and fromError(Error.message) paths plus regression tests. Would appreciate a 👍/review if this matches what you are seeing — especially for Codex gpt-5.x unattended runs.

  6. github-actions commented on Aug 2, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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