Skip to content

Propagate known provider SSE error events - #379

Open
jihtsan wants to merge 1 commit into
huggingface:mainfrom
jihtsan:codex/378-propagate-provider-sse-errors
Open

jihtsan wants to merge 1 commit into
huggingface:mainfrom
jihtsan:codex/378-propagate-provider-sse-errors

Conversation

@jihtsan

@jihtsan jihtsan commented Oct 31, 2026

Copy link
Copy Markdown

Closes #378.

An HTTP 200 SSE response could contain a provider error while the session still finished successfully with its partial answer. An error-only stream instead lost the provider diagnostic behind noSnapshots. This affects Anthropic, OpenAI Chat Completions, OpenAI Responses, OpenResponses and Gemini.

Recognize their known error envelopes in the shared SSE reader before normal chunk decoding can ignore them. Throw the existing HTTPTransportError using a new static value on its extensible Kind struct, .providerError, retaining the actual HTTP response/headers and the failed event's JSON payload. No public enum cases or public provider-specific error types are added. Unknown informational/ping events, invalid unrecognized chunks, [DONE], existing response.failed, HTTP errors and cancellation retain their behavior. README documents the new diagnostic surface.

Validation (Apple Swift 6.4, macOS arm64, committed resolved versions):

  • Complete original package/public URLSession fixture probe reproduces all five partial-then-error and five error-only failures without provider requests.
  • Regression on base: 10 provider error cases fail, five normal/unknown-event controls pass. Fixed: all 15 parameterized cases pass, including split transport chunks and retained raw payload/headers.
  • Targeted provider/transport/timeout suites pass, including existing response.failed, non-2xx and cancellation coverage.
  • Broader offline run reports 838 tests in 90 suites passed. Used CI mode and removed provider credentials. Native SystemLanguageModel/FoundationModels compatibility groups were explicitly excluded; live provider suites are disabled without credentials.
  • swift build, repository-wide swift format lint --strict --recursive . and git diff --check pass.
  • Build/tests use --build-system native --disable-default-traits --force-resolved-versions --jobs 2 to avoid downloading or running local inference stacks. No lockfile change.
  • Independent Standards and Spec reviews: 0 findings for the submitted head.

No live/paid provider calls, native Foundation Models inference, MLX/Llama/CoreML, AsyncHTTPClient trait or other OS/Swift versions were tested. The native-build-system deprecation and existing test deprecation/Sendable warnings remain visible in the logs.

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.

Known provider SSE errors are ignored and partial responses finish successfully

1 participant