Skip to content

fix(core): retry transient response stream errors - #34010

Closed
opencode-agent[bot] wants to merge 1 commit into
devfrom
responses-stream-retry
Closed

fix(core): retry transient response stream errors#34010
opencode-agent[bot] wants to merge 1 commit into
devfrom
responses-stream-retry

Conversation

@opencode-agent

Copy link
Copy Markdown
Contributor

Summary

  • decode the nested error envelope emitted by production OpenAI Responses streams
  • classify known transient stream failures as retryable and stop parsing after terminal error events
  • retry provider turns at most twice, and only before any assistant output is durably published
  • preserve the terminal provider failure after retry exhaustion

This adapts the intent of #30323 to the current native LLM + V2 Session runner architecture.

Fixes#16214

Why

OpenAI Responses can emit transient SSE errors as:

{"type":"error","error":{"type":"server_error","code":"server_error","message":"..."}}

The parser only read top-level fields and response.error, so this became the generic OpenAI Responses stream error. The current Session runner then treated that transient stream failure as terminal, stopping agent work after completed tool calls.

Safety

Retries are bounded to two retries with exponential delay. A retry is admitted only before the Session runner has started durable assistant output, so partial text, reasoning, and tool activity are never replayed.

Verification

  • packages/llm: 283 passed, 30 skipped
  • packages/core: test/session-runner.test.ts — 82 passed
  • bun typecheck in packages/llm
  • bun typecheck in packages/core
  • repository push hook: 29 package typechecks passed
  • formatting, lint (0 errors), and git diff --check

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Intermittent OpenAI streamed server_error (sequence_number:2) with gpt-5.3-codex; retries degrade session

0 participants