Skip to content

OpenAI websocket disconnects before completion should retry safely #29646

@timrichardson

Description

@timrichardson

Description

OpenAI Responses websocket requests can fail when the websocket closes or idles before response.completed, for example with code 1006.

If no response output has been committed yet, this transient websocket failure should retry over HTTP instead of surfacing to the user. Once output has been emitted, it should not replay because that can duplicate partial responses.

this model for correct behaviour is the SSE workaround, which retries and gives feedback to the user via a transitory message in the terminal.

Observed error:

WebSocket closed before response.completed (code 1006: Connection ended)

and this terminates the response.

Plugins

Not specified in the original report.

OpenCode version

1.15.10

Steps to reproduce

  1. Start an OpenCode request that uses the OpenAI Responses websocket path.
  2. Have the websocket close or idle before a response.completed event is received, for example with close code 1006. This is an intermittent bug and can't be reliably reproduced. In Australia if might be once ever 15 minutes or so.
  3. Response stops.

exepected behaviour:
OpenCode retries and the response continues. User is informed of a timeout and retry.

Screenshot and/or share link

Not available.

Operating System

ubuntu

Terminal

ghostty

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions