Skip to content

fix(model): propagate in-stream provider errors - #5066

Merged
asim merged 1 commit into
micro:masterfrom
shuaiyafei:codex/stream-error-events
Nov 19, 2026
Merged

asim merged 1 commit into
micro:masterfrom
shuaiyafei:codex/stream-error-events

Conversation

@shuaiyafei

Copy link
Copy Markdown
Contributor

Summary

Model.Stream() currently drops OpenAI-compatible SSE error objects. An error before any content becomes a normal EOF; an error after partial text can become a successful response with StopReason: "error". Callers can therefore mistake a failed, incomplete reply for normal completion.

Return the provider error message from all three OpenAI-compatible readers: the shared reader, OpenAI, and Atlas Cloud. This matches the existing incremental Generate() error handling. The protocol case is documented under OpenRouter streaming errors.

Verification

  • Added public-API HTTP/SSE regression tests for 8 providers, before and after partial content. All 16 cases fail on unchanged bc4185b and pass with this change.
  • go test -race ./model/... passed.
  • go build ./... passed.
  • golangci-lint run ./... passed (v2.14.0, matching CI).
  • TERM=dumb go test -timeout 120s ./... passed: 106 packages; the existing suite skips 36 test nodes. Go 1.26.10 was used.

With an unset TERM, four TestStreamedReferenceLinks subtests fail because their URL substring counts include OSC 8 hyperlink escape sequences. They fail identically on unchanged bc4185b. The supported plain-terminal mode (TERM=dumb) strips those escapes and passes the full suite. This PR does not edit the renderer or its tests.

The new regression cases use httptest fixtures. No authenticated live-model inference was validated.

AI assistance

Prepared, tested, and self-reviewed with OpenAI Codex (GPT-6, autonomous) for @shuaiyafei. Maintainer edits are enabled.

@asim
asim merged commit 0d91566 into micro:master Nov 19, 2026
3 of 5 checks passed
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.

2 participants