Skip to content

fix(responses): wrap converted-stream bridge responses into synthetic stream - #42821

Closed
agustin18 wants to merge 3 commits into
BerriAI:mainfrom
agustin18:fix/websearch-converted-stream-responses-500
Closed

agustin18 wants to merge 3 commits into
BerriAI:mainfrom
agustin18:fix/websearch-converted-stream-responses-500

Conversation

@agustin18

Copy link
Copy Markdown
Contributor

TLDR

When an interception callback (e.g. websearch_interception, code_interpreter_interception, headroom_interception) forces stream=False on /v1/responses to run the agentic loop, and the model routes to the chat completions bridge (use_chat_completions_api: True), the bridge was returning a plain non-async-iterable ResponsesAPIResponse instead of re-wrapping it as a synthetic event stream. This resulted in an immediate 500 when the proxy attempted async for over the response.

This PR re-wraps the completed ResponsesAPIResponse into MockResponsesAPIStreamingIterator when converted_stream_requested(kwargs) is set on the bridge path, mirroring the native responses path in llm_http_handler.py.

Relevant issues

Fixes #42770

Pre-Submission checklist

  • I have added meaningful tests
  • The handful of test files covering my change pass locally (pytest tests/test_litellm/responses/litellm_completion_transformation/test_handler.py -k wraps_converted_stream)
  • My PR passes all required CI/CD checks
  • My PR's scope is as isolated as possible; it only solves 1 specific problem

Type

🐛 Bug Fix
✅ Test

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

@agustin18
agustin18 requested a review from a team September 23, 2026 23:09
@CLAassistant

CLAassistant commented Sep 23, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@greptile-apps

greptile-apps Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The behavioral fix appears safe to merge, with only a non-blocking whitespace cleanup remaining

Findings

  1. P2 Extra blank line at EOF ▶

Summary

This PR restores stream-shaped Responses API output when a non-streaming chat-completions bridge result must satisfy a converted-stream request

  • Wraps completed bridged responses in the existing synthetic Responses API iterator
  • Makes synthetic iteration safe when no logging object is available
  • Adds sync and async regression coverage for all supported interception flags

Reviews (1) · Last reviewed commit: "fix(responses): wrap converted-stream br..."

@codspeed

codspeed Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 32 untouched benchmarks


Comparing agustin18:fix/websearch-converted-stream-responses-500 (1485cce) with main (9c958af)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (19f69ed) during the generation of this report, so 9c958af was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@codecov

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@agustin18
agustin18 force-pushed the fix/websearch-converted-stream-responses-500 branch from 8b33cbe to 259821f Compare September 26, 2026 07:21
@agustin18
agustin18 force-pushed the fix/websearch-converted-stream-responses-500 branch from 259821f to 6482c4e Compare October 18, 2026 01:53
…handler

Signed-off-by: agustin18 <agustinsaiz02@gmail.com>
Signed-off-by: agustin18 <agustinsaiz02@gmail.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

Thanks for the contribution! I'm closing this because #45433 already fixed it on main, so streamed web search on bridged deployments returns 200 now

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.

[Bug]: websearch_interception + use_chat_completions_api: streaming /v1/responses 500s — bridge returns non-async-iterable ResponsesAPIResponse

3 participants