Repository navigation
fix: record failed Responses streams as errors - #1807
Conversation
Report provider failures after forwarding response.failed so the managed call records ERROR while preserving the original event, output, and usage. Return the saved failure before another source poll can stall or replace it. Signed-off-by: Maryam Najafian <[email protected]>
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| Layer / File(s) | Summary |
|---|---|
Forward failed response and queue provider error crates/core/src/codec/openai_responses.rs, crates/core/tests/integration/stream_tests.rs |
The codec forwards a failed response and reports its provider error on the next poll. Tests cover error details, fallback text, and source-stream behavior. |
Verify session and observability outcomes crates/core/tests/integration/stream_tests.rs, docs/configure-plugins/observability/opentelemetry.mdx |
Session tests check error status, the provider error description, retained output, and usage. The documentation describes LLM span and gateway error reporting. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Possibly related PRs
- NVIDIA/NeMo-Relay#1808: Applies the same provider-error reporting pattern to the Chat Completions codec.
- NVIDIA/NeMo-Relay#1767: Updates terminal-event tracking and EOF handling in
ResponsesCompletionStream.
Merge Risk: 
Minimal · previous review 000b7
-
Provider failures that arrive after an HTTP 200 Responses stream are now recorded as errors with the provider's error details, while the original failure event is still forwarded. The change is narrow, has targeted tests and documentation, and no merge-blocking risk was found.
Security architecture risk: 
Minimal · up to 000b7
-
The change improves failure reporting without establishing an introduced material security or failure-containment risk. Failed provider events remain intact, subsequent errors terminate the stream, and the gateway’s additional error event uses a generic message.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — The demonstrated behavioral scope is an individual stream using the Responses validator and its downstream session/event/span consumers. Provider diagnostics can reach configured observability consumers; the inspected change does not add another production caller or broaden dispatch authority.
Trust Boundaries and Controls
- observed — The original failed event already carried provider diagnostics to stream consumers. The newly triggered gateway error frame uses fixed text rather than serializing the Internal error. Observability END publication still applies event sanitizers after constructing metadata; response-payload sanitization is a separate earlier step.
Resilience and Maintainability Implications
- observed — Error delivery latches stream termination and preserves lifecycle delegation. Cancellation before the deferred error is polled follows the existing dropped-stream finalization path instead. A normally formed failed response maps to an Unknown finish reason, so it does not qualify for that path’s successful-terminal-outcome override; cancellation may retain the generic interruption description rather than provider details.
Hardening Proposals
- proposed — Where provider diagnostics may contain sensitive content, include status-description metadata in event-sanitizer policy rather than relying solely on response-payload redaction. The new diagnostic path makes this distinction relevant; no actual sensitive-data disclosure was established.
-
Pre-merge checks: 
4
-
Full details: Title check
-
Explanation
The title uses the Conventional Commits type 'fix' with a concise imperative summary ('record failed Responses streams as errors') that matches the main change: recording response.failed streams as ERROR. It is 46 characters, has no trailing period, and uses lowercase type. No scope is used, which is allowed since scope is optional. It does not indicate a breaking change, so no '!' is needed.
Full details: Description check
-
Explanation
The description follows the repository template. It includes the Overview with both checklist items marked, the Details section explaining the forwarding and error reporting behavior, a Where should the reviewer start section pointing to the key function and tests, and a Related Issues section using the allowed keyword 'Relates to' with issue links. It also includes validation notes. The description is complete and specific.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
Fix failing CI checks
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
#### Overview When a Responses stream sends `type: "error"`, the gateway forwards it but keeps waiting. If upstream closes, Relay reports a missing final response instead of the provider's error. Handle these events like `response.failed`: forward them unchanged, then report the provider's error on the next read, even if upstream stalls. - [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license. - [x] I searched existing issues and open pull requests, and this does not duplicate existing work. #### Details Preserve collected output, token usage, and first-final-response precedence. Update the existing observability documentation and regression coverage. **Validation:** Rust tests, Clippy, and formatting passed. #### Where should the reviewer start? `ResponsesCompletionStream::poll_next` in `crates/core/src/codec/openai_responses.rs`, followed by the Responses stream tests and gateway regression. #### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to) - Relates to #1807. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * OpenAI Responses streams now report standalone provider errors promptly, even when the stream would otherwise remain open. Error details are included when provided, and usage and output recorded before an error are retained. * **Documentation** * Updated OpenTelemetry guidance to describe how provider error events appear in client streams and tracing. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: mnajafian-nv <[email protected]>
Overview
A provider can return HTTP 200 and later send
response.failed. The standalone gateway forwards that event but can still record the call asOK. This change recordsERRORwith the provider's error details.Details
Forward the original failure event unchanged, then report the failure on the next read. A stalled connection or later transport error cannot hide it. Keep collected output, token usage, and the first final response.
Clients also receive Relay's existing SSE error event. The existing observability guide documents this behavior.
This applies to the standalone gateway and Rust callers using the built-in Responses 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?
ResponsesCompletionStream::poll_nextincrates/core/src/codec/openai_responses.rs, then the Responses cases 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
Bug Fixes
Documentation