litellm/tests/unit/responses
joshua-berri 995aaa64f0
fix(responses): preserve deferred tool references on Anthropic routes (#52977)
* fix(responses): keep tool_reference blocks in function call outputs

The Responses to Chat bridge turned reference-only tool outputs into a JSON
string and dropped references that sat next to text, so Claude never saw
tools loaded through defer_loading. The bridge now keeps each valid
reference in order. Guardrail text extraction keeps its existing JSON
fallback, and malformed or unknown parts fall back as before.

Fixes #46681

* fix(responses): keep tool references only on Anthropic routes

Keeping tool_reference blocks for every bridge route turned the JSON text that
OpenAI and Vertex Gemini received into empty content. The flag now defaults to
off and is set from provider_builds_anthropic_request at the request send site
and in previous_response_id history replay, so inspection callers and
non-Anthropic routes keep their existing serialization. The reference check
moves into a small part decoder so the normalizer's complexity is unchanged.

* fix(responses): skip tool references when the route does not resolve

Checking the route with provider_builds_anthropic_request raised
BadRequestError for model aliases with no resolvable provider, such as batch
aliases. Both send sites now use the bridge's existing non-raising
_resolved_chat_config, so an unresolved alias keeps its existing tool output
serialization on the first turn and on previous_response_id replay.

---------

Co-authored-by: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com>
2026-11-19 15:55:31 -08:00
..
litellm_completion_transformation fix(responses): preserve deferred tool references on Anthropic routes (#52977) 2026-11-19 15:55:31 -08:00
mcp feat(model_armor): scan MCP tool results on post_mcp_call (#51887) 2026-11-18 12:17:47 -08:00
__init__.py ci: move provider-independent MCP tests into tests/unit and run mcp-integration from litellm-tests (#42904) 2026-09-24 23:07:48 +00:00
test_additional_tools.py feat(proxy): mixed Codex model picker and LiteLLM routing on native codex routes (#49408) 2026-11-06 11:14:47 -08: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(tool_choice): accept the Responses API's flat allowed_tools layout on chat completions (#50467) 2026-11-10 13:04:06 -08:00
test_responses_api_lifecycle.py fix(responses): log the resolved provider on Responses API calls (#52622) 2026-11-18 22:34:16 +00:00
test_responses_api_request_body.py fix(responses): log the resolved provider on Responses API calls (#52622) 2026-11-18 22:34:16 +00: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(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08: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 fix(responses): accept a string or tuple allowed_openai_params on Responses models instead of answering 500 (#51751) 2026-11-14 04:32:38 -05:00
test_responses_websocket_all_providers.py fix(responses): send an HTTP status on websocket guardrail block frames (#52942) 2026-11-19 14:22:22 -08: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(responses): keep reasoning item IDs consistent across streaming events (#51243) 2026-11-11 15:49:46 -08:00
test_streaming_iterator_error_events.py fix(responses): surface mid-stream upstream errors that arrive without an event type (#50466) 2026-11-07 14:53:07 -08:00
test_text_format_conversion.py refactor: expose core private helpers under public names (#44871) 2026-10-07 00:05:27 +00:00