Repository navigation
fix: record Chat Completions in-stream errors as failed calls - #1808
Conversation
Recognize provider error objects inside successful HTTP streams instead of letting the managed call finish as OK. Preserve the original chunk and report its failure before polling the source again. Signed-off-by: Maryam Najafian <[email protected]>
|
No actionable comments were generated in the recent review. WalkthroughThe OpenAI Chat streaming codec now forwards provider error events before returning a derived stream error on the next poll. Integration tests cover error details, termination, partial output, usage, and end-event metadata. OpenTelemetry documentation describes the behavior. ChangesChat stream error handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Possibly related issues
Merge Risk:
|
Signed-off-by: Will Killian <[email protected]>
Overview
An OpenAI-compatible provider can return HTTP 200 and later send an
errorobject inside a Chat Completions stream. The standalone gateway forwards it but can still record the call asOK. This change recordsERRORwith the provider's error details.Details
Forward the original error chunk unchanged, then report the failure on the next read. A stalled connection or later transport error cannot hide it. Keep collected text and token usage, and handle missing error details.
Clients also receive Relay's existing SSE error payload instead of
[DONE]. The existing observability guide documents this behavior.This applies to the standalone gateway and Rust callers using the built-in Chat Completions validator. Daemon observation is unchanged.
Validation: Regression tests failed before the fix and passed afterward. The Rust suite, Clippy, formatting, and docs checks passed. Dependency-audit hooks still report findings in unchanged release dependencies.
Where should the reviewer start?
ChatCompletionStream::poll_nextincrates/core/src/codec/openai_chat.rs, then the two Chat stream regressions incrates/core/tests/integration/stream_tests.rs.Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
errorevents are recorded as successful (OK) LLM calls #1781 and fix(codecs): record Anthropic in-stream error events as failed calls #1782.Summary by CodeRabbit