fix(azure): preserve responses API streaming events - #2174
Conversation
The Azure prompt-filter-only chunk guard was dropping every Responses API event, since those events also lack top-level id/object/choices/ usage. Skip the guard when the chunk carries a `type` field. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughAzure provider streaming transformation guards refined to preserve Responses API events by checking the ChangesAzure Streaming Transformation & Coverage
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Fixes Azure OpenAI streaming for models that use the Responses API (e.g., azure/gpt-5.5) by preventing the “prompt-filter-only leading chunk” guard from incorrectly dropping all Responses API events, which previously caused downstream “empty response” errors.
Changes:
- Update the Azure prompt-filter-only chunk drop guard to only trigger when the chunk also lacks
data.type, ensuring Responses API events (which always includetype) are preserved. - Apply the same defensive
data.typeexemption to the analogous guard forazure-ai-foundry. - Add unit tests covering: prompt-filter chunk dropping, Responses API output text delta passthrough, and
response.completedusage extraction.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/gateway/src/chat/tools/transform-streaming-to-openai.ts | Refines Azure/Azure-AI-Foundry streaming guard logic to avoid dropping Responses API events. |
| apps/gateway/src/chat/tools/transform-streaming-to-openai.spec.ts | Adds regression tests for Azure prompt-filter chunk handling and Responses API streaming/usage mapping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Streaming requests to
azure/gpt-5.5(and any other Azure model withsupportsResponsesApi: true) returned:The Azure prompt-filter-only chunk guard at
transform-streaming-to-openai.ts:687was dropping every Responses API event because those events also lack top-levelid/object/choices/usage(their data lives underdata.response.*or alongside atypefield). With every chunk transformed tonull, no content/tokens accumulated and the empty-response detector atchat/chat.ts:7204fired.Fix: only drop the chunk when
data.typeis also absent — Responses API events always carrytype(response.created,response.output_text.delta,response.completed, …); the chat-completions prompt-filter chunk does not.Same guard for
azure-ai-foundrygot the same treatment defensively (no current model triggers it, but the shape is identical).Test plan
response.completedusage extraction (11 tests total pass)azure/gpt-5.5streamingx-no-fallback: true—used_provider: "azure", content streams, usage reported correctlypnpm buildcleanpnpm formatclean🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests