GeezerVison is showing github.com — Some transient stream/rate-limit errors bypass retry and terminate sessions · Issue #21893 · anomalyco/opencode
Some transient stream/rate-limit errors bypass retry and terminate sessions #21893DescriptionDescription
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
- Start a long-running agent task that streams model output.
- Hit a transient upstream failure during streaming, especially one shaped like
stream_read_error or a wrapped rate_limit_error / concurrency-limit validation error.
- Observe that the session sometimes stops with an error instead of entering retry state.
- 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
Reacted by Weilu Jia, Jakob Gillich, Georges, Tommy D. Rossi and spark4862 Activityadded coreAnything pertaining to core functionality of the application (opencode server stuff) on Apr 10, 2026github-actions commented on Apr 10, 2026 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. mwroffo commented on Apr 17, 2026 removed coreAnything pertaining to core functionality of the application (opencode server stuff) on May 3, 2026spark4862 commented on Jun 2, 2026 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. github-actions commented on Aug 2, 2026 To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|