Skip to content

Fix OpenAI Responses chats stuck after SSE error events#559

Open
rschmukler wants to merge 1 commit into
editor-code-assistant:masterfrom
rschmukler:rs/openai-streaming-fixes
Open

Fix OpenAI Responses chats stuck after SSE error events#559
rschmukler wants to merge 1 commit into
editor-code-assistant:masterfrom
rschmukler:rs/openai-streaming-fixes

Conversation

@rschmukler

Copy link
Copy Markdown
Contributor

Summary

Handle terminal SSE error events from the OpenAI Responses API and route them through ECA's existing error and retry handling.

Problem

An OpenAI Responses request can return HTTP 200 but terminate with an SSE error instead of response.completed, for example:

  • Event: error
  • Code: server_is_overloaded

ECA previously handled response.failed, but generic SSE error events were passed to the stream callback and ignored. When the stream then closed normally, ECA emitted neither an error nor a finish event, leaving the chat marked as active indefinitely.

Changes

  • Treat SSE error events as terminal OpenAI Responses errors.
  • Preserve structured error fields, response headers, and request IDs.
  • Close the response stream before invoking error or retry handling.
  • Classify server_is_overloaded as a retryable provider overload.
  • Integrate the handling with the existing stream cancellation and idle-timeout watchdog.
  • Add regression tests covering:
    • HTTP 200 streams ending with an SSE error.
    • Ignoring trailing events after the terminal error.
    • Stream closure before error handling.
    • server_is_overloaded classification.
    • Compatibility with stream cancellation handling.

Verification

  • 35 tests passed.

  • 197 assertions passed.

  • No test failures.

  • No new clj-kondo errors.

  • Editor diagnostics are clean.

  • I added a entry in changelog under unreleased section.

  • This is not an AI slop.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant