Skip to content

fix: OpenAI Responses stream reports a null response id - #322

Closed
cunninghamcard-bit wants to merge 1 commit into
fix/openai-file-search-sends-max-num-results-as-an-integerfrom
fix/openai-responses-stream-reports-a-null-response-id
Closed

cunninghamcard-bit wants to merge 1 commit into
fix/openai-file-search-sends-max-num-results-as-an-integerfrom
fix/openai-responses-stream-reports-a-null-response-id

Conversation

@cunninghamcard-bit

Copy link
Copy Markdown
Contributor

Summary

Before: an OpenAI or Azure Responses stream that never received response.created finished with providerMetadata.<key>.responseId: "".

After: as in @ai-sdk/openai 4.0.83, it finishes with responseId: null. The generate path already wrote null for a missing id.

Found while porting the upstream Azure tests (case responses › doStream › should handle file_citation annotations without optional fields in streaming). Part of the #276 list.

How it works today

OpenAIResponsesLanguageModel::do_stream
└─ ResponsesStreamTransformer
   ├─ "response.created" → response_id = response.id                 aimux-providers/src/openai/responses/responses_convert.rs:740
   └─ flush → Finish { provider_metadata: { <key>: { responseId: response_id.unwrap_or_default() } } }   :1517
                                                ← upstream: let responseId: string | null = null   (openai-responses-language-model.ts:1587)
                                                   flush → providerMetadata.responseId: responseId → null   (:2932)
convert_responses_generate → { responseId: data.id or null }        responses_convert.rs:328   (already null)

What this PR changes

let mut pm = json!({ "responseId": self.response_id });   responses_convert.rs:1517   (None → null)

Tests (tests/openai_upstream_e2e_test.rs): a_stream_without_response_created_finishes_with_a_null_response_id streams only response.completed; on master it fails with left: String(""), right: Null. The upstream case is ported in the Azure test PR.

Docs: CHANGELOG Fixed.

Type of change

  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change
  • New provider
  • New / updated binding
  • Docs / RFC

Checklist

  • cargo +1.99 fmt -p aimux-providers -- --check passes
  • cargo +1.99 clippy -p aimux-providers --lib --tests -- -D warnings passes
  • cargo +1.99 test -p aimux-providers --test openai_upstream_e2e_test passes (23)
  • scripts/check_provider_boundaries.sh passes
  • Updated relevant docs (CHANGELOG)
  • Commit messages follow Conventional Commits

Notes for reviewers

Second of three OpenAI fixes (#321 file search integer ← this PR ← reasoning delta item id ← the Azure test PR). Nothing in the workspace reads responseId back from the finish metadata.


Generated by Claude Code

… never started

@ai-sdk/openai 4.0.83 starts the stream's `responseId` at `null`
(openai-responses-language-model.ts:1587) and only `response.created` sets
it, so a stream without that event finishes with `responseId: null`. aimux
wrote an empty string. The generate path already writes `null`.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5

Copy link
Copy Markdown
Contributor Author

Folded into #323 together with the other OpenAI fixes, so each vendor has one fix PR. This change is commit 595eedc2 there. Closing this one; the branch stays as it is.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant