Skip to content

fix: handle top-level Responses API error events - #1835

Merged
willkill07 merged 1 commit into
NVIDIA:release/0.11from
mnajafian-nv:fix/responses-stream-error-events
Nov 24, 2026
Merged

willkill07 merged 1 commit into
NVIDIA:release/0.11from
mnajafian-nv:fix/responses-stream-error-events

Conversation

@mnajafian-nv

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

Copy link
Copy Markdown
Contributor

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.

  • 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

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)

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.

@mnajafian-nv
mnajafian-nv requested review from a team as code owners November 24, 2026 22:53
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The OpenAI Responses stream codec now handles standalone error events as provider failures. It forwards the event before reporting the error on the next poll. Tests and documentation cover stream validation, session outcomes, and stalled sources.

Changes

Responses Stream Error Handling

Layer / File(s) Summary
Recognize and report provider error events
crates/core/src/codec/openai_responses.rs, crates/core/tests/integration/stream_tests.rs, docs/configure-plugins/observability/opentelemetry.mdx
The codec extracts details from standalone error events and reports the saved error on the next poll. Integration tests cover completion validation and provider error details. The documentation describes the corresponding stream and observability behavior.
Verify session and stalled-stream outcomes
crates/core/tests/integration/stream_tests.rs, crates/cli/tests/coverage/shared/gateway_tests.rs
Session tests check error outcomes while retaining usage and output evidence. A gateway test checks that response collection completes when the source remains pending after yielding an error event.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: Minimal · up to 73a0e

This change makes standalone provider error events in Responses streams surface as stream errors instead of being missed. No merge-blocking risk was found in the supplied changes, and tests cover the new behavior.

Security architecture risk: Low · up to 73a0e

A provider error now ends the affected stream without waiting for upstream to close. The main risk is that provider error text can also appear in configured traces, where it may be visible to a different audience than the original response.

Retained concerns

  • Low · security · inferred: A standalone provider error before the first final response can now place its free-form message and code in LLM span status. If those fields contain sensitive details and event sanitization does not remove them, configured trace recipients can see text previously forwarded to the caller but not copied into span status through this path.
Security review details

Security Blast Radius

  • inferred — The termination change is scoped to the affected Responses stream. The additional data exposure is to subscribers and configured trace destinations for that stream, if the provider text survives sanitization; the evidence does not establish who can read those traces in production.

Trust Boundaries and Controls

  • observed — Provider-controlled code and message become END-event status metadata. The runtime passes the event through its existing sanitizer dispatch, and the trace integration maps the resulting status description to the span.

Resilience and Maintainability Implications

  • observed — The managed stream terminalizes the source on error or cancellation. If the client disconnects before reading the saved error, the gateway guard cancels the stream and retains responsibility for session cleanup.

Hardening Proposals

  • proposed — Keep the provider event intact for the caller, but use a stable classification or redacted description in exported trace status by default. Apply the same policy to both standalone errors and response.failed.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title uses the allowed type "fix", a lowercase imperative summary, no trailing period, and is 48 characters long. It states the main change: the gateway now handles top-level Responses API error e…
Description check Passed The description follows the repository template. It has an Overview with both checklist items checked, a Details section describing preserved output, usage, and precedence plus validation results, a r…
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 allowed type "fix", a lowercase imperative summary, no trailing period, and is 48 characters long. It states the main change: the gateway now handles top-level Responses API error events. The title matches the raw summary and the PR objectives.

Full details: Description check

Explanation

The description follows the repository template. It has an Overview with both checklist items checked, a Details section describing preserved output, usage, and precedence plus validation results, a reviewer starting point naming ResponsesCompletionStream::poll_next, and a Related Issues section that uses the 'Relates to' keyword with #1807. The template's 'Closes' line is replaced by 'Relates to', which the template allows. Overall the description is complete.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2f1dc8e and 73a0e18.

Files selected for processing: 4

  • crates/cli/tests/coverage/shared/gateway_tests.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/core/tests/integration/stream_tests.rs
  • docs/configure-plugins/observability/opentelemetry.mdx

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Recent review details

Context from checks skipped due to timeout: 4

  • GitHub Check: Prepare
  • GitHub Check: Detect docs changes
  • GitHub Check: Apply PR labels
  • GitHub Check: request / require-nvskills-ci / require-nvskills-ci
Additional context used

Code guidelines: 4

.agents/skills/contribute-docs/SKILL.md — configured
.agents/skills/maintain-observability/SKILL.md — configured
AGENTS.md — configured
.agents/skills/review-doc-style/SKILL.md — configured
Path-based instructions: 7

Review documentation for technical accuracy against the current API, command correctness, and consistency across language bindings.

CodeRabbit configuration file

Files:

  • docs/configure-plugins/observability/opentelemetry.mdx
Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.

CodeRabbit configuration file

Files:

  • crates/cli/tests/coverage/shared/gateway_tests.rs
  • crates/core/tests/integration/stream_tests.rs
Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.

CodeRabbit configuration file

Files:

  • crates/core/src/codec/openai_responses.rs
  • crates/core/tests/integration/stream_tests.rs
Source excerpt: In MDX files, top-of-file comments must use JSX comment delimiters: `{/*` to open and `*/}` to close.

CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Files:

  • docs/configure-plugins/observability/opentelemetry.mdx
Source excerpt: Core event model and emitted fields `crates/core/src/observability/atif.rs` `crates/core/src/observability/otel.rs` `crates/core/src/observability/openinference.rs` FFI and binding-native wrappers where the config or lifecyc...

CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)

Files:

  • docs/configure-plugins/observability/opentelemetry.mdx
Source excerpt: Update public documentation and examples when public behavior, package names, supported bindings, or documented workflows change.

CodeRabbit inference engine (AGENTS.md)

Files:

  • docs/configure-plugins/observability/opentelemetry.mdx
Source excerpt: Verify MDX files use JSX delimiters for top-of-file SPDX comments.

CodeRabbit inference engine (.agents/skills/review-doc-style/SKILL.md)

Files:

  • docs/configure-plugins/observability/opentelemetry.mdx
Additional comments: 4

crates/core/src/codec/openai_responses.rs: 1

1630-1630: LGTM!

Also applies to: 1703-1710, 1745-1753

crates/core/tests/integration/stream_tests.rs: 1

1057-1070: LGTM!

Also [REDACTED]pplies to: 1164-1185, 1228-1228, 1250-1257, 1306-1311, 1327-1328

docs/configure-plugins/observability/opentelemetry.mdx: 1

1290-1294: LGTM!

crates/cli/tests/coverage/shared/gateway_tests.rs: 1

4361-4399: LGTM!

@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 24, 2026
@github-actions

Copy link
Copy Markdown

@mnajafian-nv mnajafian-nv self-assigned this Nov 24, 2026
@willkill07 willkill07 added this to the 0.11 milestone Nov 24, 2026
@willkill07
willkill07 enabled auto-merge (squash) November 24, 2026 23:18
@willkill07
willkill07 merged commit fd1689c into NVIDIA:release/0.11 Nov 24, 2026
97 checks passed

This branch was previously deployed

1 inactive deployment
fern — 73a0e187 Deployed Nov 24, 2026 by willkill07 via Clean up docs preview #7776
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