litellm/tests/unit/responses
simonp9 594f862bf3
fix(streaming): rebuild each choice of an n>1 chat stream on its own (#49002)
* fix(streaming): rebuild each choice of an n>1 chat stream on its own

stream_chunk_builder folded every choice of an n>1 chat stream into choice 0, so post-call guardrails such as tool_permission re-emitted one choice holding every choice's tool calls, and spend logs and logging callbacks kept only the first choice's text. Each choice is now assembled from its own chunks, while usage, cost, and hidden params still read the whole stream. Cisco AI Defense compares each choice's streamed text on its own so safe n>1 streams still pass through unchanged.

* fix(streaming): keep bridged reasoning summaries on choice 0 and infer an unreported choice finish reason

* fix(streaming): match MCP follow-ups and bridged summary text to the rebuilt choices

MCP auto-execute now answers only the first choice's tool calls, since its
follow-up turn continues that choice alone. The Responses bridge streams a
space before each reasoning summary part after the first, matching the
non-streamed reply. build_base_response now takes the per-choice streams
instead of having its choices replaced afterwards

* fix(streaming): space every later reasoning summary part, deny per judged call, and rebuild in one text pass

* fix(guardrails): key tool_permission denials for custom tool calls too, and type the stream rebuild's messages

* fix(mcp): continue the first choice that called a tool when an n>1 reply auto-executes MCP tools

* fix(noma): scan each choice of a multi-choice reply on its own

* fix(noma): keep masked choices when a later choice's scan fails open on a stream

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-10-29 18:29:14 -07:00
..
litellm_completion_transformation fix(responses): only merge repeated Codex tools when drop_params is on (#49112) 2026-10-29 12:55:29 -07:00
mcp fix(streaming): rebuild each choice of an n>1 chat stream on its own (#49002) 2026-10-29 18:29:14 -07:00
__init__.py
test_additional_tools.py fix(responses): only merge repeated Codex tools when drop_params is on (#49112) 2026-10-29 12:55:29 -07:00
test_custom_tool_call.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_metadata_codex_callback.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_no_duplicate_spend_logs.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_null_test_fix.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_responses_api_bridge_flag.py fix(responses): reject or drop Responses params the chat completions bridge cannot translate (#48655) 2026-10-28 07:11:55 +00:00
test_responses_api_lifecycle.py fix(responses): resume background response streams with stream and starting_after (#48819) 2026-10-29 02:31:22 -07:00
test_responses_api_request_body.py fix(responses): forward top-level moderation param to OpenAI (#48708) 2026-10-28 10:33:11 -07:00
test_responses_prompt_management.py fix(sdk): decide MCP gateway routing without importing the proxy handler (#45961) 2026-10-20 01:44:54 +00:00
test_responses_router_cooldown.py refactor: expose core private helpers under public names (#44871) 2026-10-07 00:05:27 +00:00
test_responses_streaming_iterator.py fix(responses): resume background response streams with stream and starting_after (#48819) 2026-10-29 02:31:22 -07:00
test_responses_supported_endpoints_passthrough.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_responses_utils.py feat(chatgpt): forward client subscriptions through the gateway (#41522) 2026-10-26 15:44:05 -07:00
test_responses_websocket_all_providers.py fix(responses): drop the null created_by OpenAI rejects when output items are replayed (#48783) 2026-10-28 21:11:49 -07:00
test_rust_bridge_websocket.py refactor(rust-bridge): require the native extension (#48852) 2026-10-28 13:16:56 -07:00
test_sse_output_recovery.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_streaming_iterator.py fix(stream): the last usage frame carries litellm's bill in usage.cost (#48955) 2026-10-28 19:32:44 -07:00
test_streaming_iterator_error_events.py fix(responses): bill every round of a streamed MCP auto-execute on one spend row (#47445) 2026-10-21 02:56:38 +00:00
test_text_format_conversion.py refactor: expose core private helpers under public names (#44871) 2026-10-07 00:05:27 +00:00