litellm/tests/test_litellm/responses
Thibault Serot 3a2d14e1a6 fix(responses): continue MCP gateway tool turns from the final response and surface failures
When a /responses request uses a hosted MCP tool (server_url: litellm_proxy/<label>)
with store=true and the model calls a tool, the gateway auto-executes the tool and
streams one logical response stitched from several upstream responses: an interim
response whose only output is the function_call, then the post-tool answer

B1 (correctness): every streamed event was pinned to the first round's response id,
i.e. the interim response that carries the function_call but no tool output. The
client then continued the next turn from that dangling response and the provider
rejected it with "No tool output found for function call <id>", which on the
streaming path surfaced as a silent empty completion. The fix adopts each
auto-execute round's own response id (the cached id is reset when a follow-up round
starts) so the client continues from the final round, whose stored input chain
includes the function_call_output

B2 (robustness): initial and follow-up call failures were swallowed; the stream
emitted the mcp_list_tools discovery events and then closed with HTTP 200 and no
output and no error. The fix stashes the failure, makes the initial call eagerly in
aresponses_api_with_mcp so a pre-stream failure re-raises as a real 4xx before any
SSE bytes are written, and emits a terminal error event when a follow-up call fails
mid-stream

Adds regression tests covering continuation exposing the final round's response id
rather than the interim tool-call id, a follow-up failure emitting a terminal error
event, and an initial-call failure being stashed for eager re-raise
2026-07-13 11:33:02 +10:00
..
litellm_completion_transformation fix(responses): preserve reasoning_tokens through chat->responses usage translation (#32837) 2026-07-10 20:15:49 -07:00
mcp fix(responses): continue MCP gateway tool turns from the final response and surface failures 2026-07-13 11:33:02 +10:00
test_custom_tool_call.py fix(responses-bridge): custom tool round-trip and allowlist preservation for Codex CLI (#32258) 2026-07-06 17:34:27 -07:00
test_metadata_codex_callback.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_no_duplicate_spend_logs.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_null_test_fix.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_responses_api_bridge_flag.py refactor(responses): drop use_responses_api_bridge; fix PLR0915 2026-04-13 18:22:17 +05:30
test_responses_api_request_body.py test(responses): replace perma-skip azure shell e2e with offline coverage (#32444) 2026-07-08 10:01:41 -07:00
test_responses_prompt_management.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_responses_router_cooldown.py fix(responses): register cooldowns on failure + fail fast on stale encrypted_content (#27820) 2026-05-13 09:03:13 -07:00
test_responses_streaming_iterator.py fix(responses): stop scheduling sync success_handler concurrently with async_success_handler (#32239) 2026-07-07 09:13:50 -07:00
test_responses_utils.py fix(responses): make response-id encoding idempotent to prevent MCP gateway double-encoding previous_response_id (#32034) 2026-07-07 19:47:11 -07:00
test_responses_websocket_all_providers.py fix(responses): stop scheduling sync success_handler concurrently with async_success_handler (#32239) 2026-07-07 09:13:50 -07:00
test_sse_output_recovery.py Litellm oss staging 04 21 2026 2 (#26569) 2026-05-20 21:25:19 -07:00
test_streaming_iterator.py fix(streaming): stamp completion_start_time on first chunk for /v1/messages and /v1/responses (#32284) 2026-07-06 19:30:31 -07:00
test_streaming_iterator_error_events.py fix(responses-api): raise APIError on in-stream error events; widen ErrorEventError.param to accept dict (#32835) 2026-07-10 20:25:38 -07:00
test_text_format_conversion.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00