Repository navigation
fix(responses): propagate chat bridge stream errors - #39207
PriyanJindal wants to merge 1 commit into
Conversation
Greptile SummaryThis PR propagates terminal Responses API stream errors through the Chat Completions bridge and preserves streamed refusal text.
Confidence Score: 4/5The PR should not merge until retryable server-side stream failures preserve the Router’s configured mid-stream fallback behavior. The new bridge correctly surfaces provider errors, but representing every terminal error as APIError prevents server-side failures from reaching the Router branch that performs stream fallback. Files Needing Attention: litellm/completion_extras/litellm_responses_transformation/transformation.py
|
| Filename | Overview |
|---|---|
| litellm/completion_extras/litellm_responses_transformation/transformation.py | Adds error and refusal event conversion, but server-side failures use APIError and therefore bypass configured mid-stream fallbacks. |
| tests/test_litellm/completion_extras/litellm_responses_transformation/test_completion_extras_litellm_responses_transformation_transformation.py | Adds focused regression coverage, though the error tests currently encode APIError for server failures rather than exercising Router fallback behavior. |
Reviews (1): Last reviewed commit: "fix(responses): propagate chat bridge st..." | Re-trigger Greptile
| raise litellm.APIError( | ||
| status_code=_status_code_for_error_fields(error_type, error_code), | ||
| message=error_message, | ||
| llm_provider="openai", | ||
| model="responses", | ||
| ) |
There was a problem hiding this comment.
Server errors bypass fallbacks
When a Responses-backed stream emits a server-side failure and the Router has a fallback configured, this code raises APIError while the streaming fallback wrapper catches only MidStreamFallbackError, causing the request to terminate instead of using the configured fallback.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Codecov still reports one changed line without coverage in the Responses transformation; please add a focused assertion before maintainer review. |
|
#46438 now keeps OpenAI's code and message on stream error events. Could you narrow this PR to its refusal delta change? |
TLDR
Problem this solves:
How it solves it:
response.failedanderroreventsUser Flow
Before: a developer streams a Chat Completion through the Responses bridge and a provider-side failure looks like an empty successful response
POST /v1/chat/completionswith"stream": trueto a model routed through the Responses APIresponse.failedorerrorafter accepting the requestAfter: the same stream exposes the provider failure to the Chat Completions client
POST /v1/chat/completionsrequestresponse.failedorerrorafter accepting the requestA refusal stream now exposes its refusal text through
delta.refusalRelevant issues
Fixes #36768
Fixes #39203
Linear ticket
Pre-Submission checklist
Screenshots / Proof of Fix
Not applicable. This handles provider-generated terminal SSE events that cannot be deterministically induced with a live request
Type
Bug Fix
Caveats (if any)
Final Attestation