Skip to content

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

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

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

Sign up for free to 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