Skip to content

fix: keep real stream metadata after an empty Azure filter chunk - #1508

Merged
willkill07 merged 1 commit into
NVIDIA:mainfrom
Somay-kousis:fix/openai-stream-empty-metadata
Oct 26, 2026
Merged

willkill07 merged 1 commit into
NVIDIA:mainfrom
Somay-kousis:fix/openai-stream-empty-metadata

Conversation

@Somay-kousis

@Somay-kousis Somay-kousis commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Streaming chat completions from Azure OpenAI now keep the real id, object, created and model instead of the empty values from Azure's leading prompt-filter chunk.

  • 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

OpenAIChatStreamingState::observe keeps the first value it sees for each top-level field. It now skips "" and created: 0, so the first real values win. Nothing changes for streams that never send empty values.

Validation:

  • New openai_chat_streaming_codec_skips_empty_metadata_from_azure_filter_chunk fails on main (id is "") and passes here.
  • cargo nextest run -p nemo-relay --lib -E 'test(codec::)': 655 passed. cargo nextest run -p nemo-relay-adaptive -E 'test(openai) | test(anthropic)': 103 passed.
  • cargo fmt --check and cargo clippy -p nemo-relay --all-targets -- -D warnings: clean.

Not run: uv run pre-commit run, binding suites (no binding surface changes).

Where should the reviewer start?

crates/core/src/codec/openai_chat.rs, OpenAIChatStreamingState::observe.

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

Summary by CodeRabbit

  • Bug Fixes
    • Streaming responses now retain valid response details when an earlier chunk contains empty metadata. This prevents blank identifiers, model names, or timestamps from replacing meaningful values in the assembled response, while preserving response content and model information from subsequent chunks.

Azure OpenAI streams a prompt-filter chunk first with id, object and model
set to "" and created set to 0. The chat streaming collector kept the first
value it saw, so the assembled response had an empty model and id. Skip empty
values so the first real ones are kept.

Signed-off-by: Somay-kousis <[email protected]>
@Somay-kousis
Somay-kousis requested a review from a team as a code owner October 25, 2026 21:08
@copy-pr-bot

copy-pr-bot Bot commented Oct 25, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@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 Oct 25, 2026
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 4246dab and 076f16f.

Files selected for processing: 2
  • crates/core/src/codec/openai_chat.rs
  • crates/core/tests/unit/codec/openai_chat_tests.rs

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
Additional context used
Path-based instructions: 2
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/core/tests/unit/codec/openai_chat_tests.rs
Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.

CodeRabbit configuration file

Files:

  • crates/core/tests/unit/codec/openai_chat_tests.rs
  • crates/core/src/codec/openai_chat.rs
Additional comments: 2
crates/core/src/codec/openai_chat.rs: 1

1558-1559: LGTM!

Also applies to: 1562-1562, 1568-1568, 1574-1574, 1580-1580

crates/core/tests/unit/codec/openai_chat_tests.rs: 1

1727-1772: LGTM!

Walkthrough

The streaming codec now skips empty id, object, and model values, and created: 0, when capturing response metadata. A test covers an Azure prompt-filter chunk followed by chunks with valid metadata and content.

Changes

Azure OpenAI stream metadata

Layer / File(s) Summary
Capture valid stream metadata
crates/core/src/codec/openai_chat.rs, crates/core/tests/unit/codec/openai_chat_tests.rs
observe ignores empty metadata strings and created: 0 when capturing values. The test checks that later chunks provide the assembled response metadata and content.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 076f1

The change appears ready to merge after normal checks; no outstanding issue is identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title follows Conventional Commits with the allowed type 'fix', lowercase type, no scope, imperative summary, no trailing period, and is 64 characters, under the 72-character limit. It accurately …
Description check Passed The description follows the repository template. It includes the Overview with both checklist items checked, Details explaining the change to OpenAIChatStreamingState::observe and the validation run, …
Linked Issues check Passed Issue #1506 requires the streaming OpenAI chat codec to retain the first non-empty id, object, model, and non-zero created value. OpenAIChatStreamingState::observe now skips empty strings an…
Out of Scope Changes check Passed The reported changes are limited to OpenAIChatStreamingState::observe and a focused codec regression test. Both changes support issue #1506. No unrelated production behavior or binding surface chang…
Full details: Title check

Explanation

The title follows Conventional Commits with the allowed type 'fix', lowercase type, no scope, imperative summary, no trailing period, and is 64 characters, under the 72-character limit. It accurately describes the change: skipping empty Azure prompt-filter metadata so real stream metadata is kept.

Full details: Description check

Explanation

The description follows the repository template. It includes the Overview with both checklist items checked, Details explaining the change to OpenAIChatStreamingState::observe and the validation run, Where should the reviewer start pointing to the file and function, and Related Issues with 'Closes #1506'. The 'Not run' note on pre-commit and binding suites adds useful context.

Full details: Linked Issues check

Explanation

Issue #1506 requires the streaming OpenAI chat codec to retain the first non-empty id, object, model, and non-zero created value. OpenAIChatStreamingState::observe now skips empty strings and created: 0. The added Azure prompt-filter test verifies later metadata, gpt-4o-mini, and message "hi". The reported codec tests pass.

Full details: Out of Scope Changes check

Explanation

The reported changes are limited to OpenAIChatStreamingState::observe and a focused codec regression test. Both changes support issue #1506. No unrelated production behavior or binding surface change is identified.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@willkill07

Copy link
Copy Markdown
Member

/ok to test 076f16f

@github-actions

Copy link
Copy Markdown

@willkill07
willkill07 merged commit 046575a into NVIDIA:main Oct 26, 2026
168 of 170 checks passed

This branch was previously deployed

1 inactive deployment
fern — 076f16f9 Deployed Oct 26, 2026 by copy-pr-bot[bot] via Preview docs #6545
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.

[Bug]: Azure OpenAI streams come out with empty id and model

2 participants