Skip to content

fix: record failed Responses streams as errors - #1807

Merged
willkill07 merged 2 commits into
NVIDIA:release/0.11from
mnajafian-nv:fix/responses-failure-status
Nov 23, 2026
Merged

willkill07 merged 2 commits into
NVIDIA:release/0.11from
mnajafian-nv:fix/responses-failure-status

Conversation

@mnajafian-nv

@mnajafian-nv mnajafian-nv commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Overview

A provider can return HTTP 200 and later send response.failed. The standalone gateway forwards that event but can still record the call as OK. This change records ERROR with the provider's error details.

  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

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_next in crates/core/src/codec/openai_responses.rs, then the Responses cases in crates/core/tests/integration/stream_tests.rs.

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

Summary by CodeRabbit

  • Bug Fixes

    • Provider failures during streaming are now reported as errors after the failure event is delivered, including the provider’s error details when available.
    • Calls that fail after producing partial output retain that output and finish with an error status.
  • Documentation

    • Updated streaming observability guidance to describe how provider failures appear in client events and monitoring.

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]>
@mnajafian-nv
mnajafian-nv requested review from a team as code owners November 23, 2026 00:46
@github-actions github-actions Bot added size:S PR is small Bug issue describes bug; PR fixes bug lang:rust PR changes/introduces Rust code labels Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 000b7a0 and a01d715.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The Responses streaming codec now forwards response.failed before returning a provider error on the next poll. It uses provider error details with fallback text. Session tests cover error status and retained output, while the OpenTelemetry documentation describes span and gateway error reporting.

Changes

Provider failure stream handling

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

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: Passed 4

Check name Status Explanation
Title check Passed 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 ER…
Description check Passed 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 t…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
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

@github-actions

Copy link
Copy Markdown

@willkill07
willkill07 merged commit 5a2bda8 into NVIDIA:release/0.11 Nov 23, 2026
96 checks passed
willkill07 pushed a commit that referenced this pull request Nov 24, 2026
#### 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]>

This branch was previously deployed

1 inactive deployment
fern — a01d715d Deployed Nov 23, 2026 by willkill07 via Clean up docs preview #7649
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug issue describes bug; PR fixes bug lang:rust PR changes/introduces Rust code size:S PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants