litellm/tests/unit/llms/openai/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
..
count_tokens fix(responses): cache bridged system prompts on stored GPT-6.2 requests (#52906) 2026-11-19 14:03:43 -08:00
__init__.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_openai_count_tokens_transformation.py fix(responses): send bridged system prompts as input messages so GPT-6.2 caches them (#52599) 2026-11-18 21:12:55 +00:00
test_openai_responses_data_residency.py feat(openai): bill gov.api.openai.com FedRAMP endpoint with 1.1x uplift (#49951) 2026-11-04 08:57:42 -08:00
test_openai_responses_guardrail_handler.py fix(responses): preserve deferred tool references on Anthropic routes (#52977) 2026-11-19 15:55:31 -08:00
test_openai_responses_guardrail_tool_merge.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_openai_responses_http.py fix(responses): preserve typed parts when logprobs is omitted (#48686) 2026-10-27 18:33:39 -07:00
test_openai_responses_transformation.py fix(bedrock): drop another model's signed thinking when replaying to a non-Claude Converse target (#50073) 2026-11-06 03:15:49 -08:00