litellm/tests/unit/responses
joshua-berri a479cbb0c2
fix(caching): preserve caller message limits across chat bridges (#54500)
* fix(caching): count the caller's messages for max_messages on the chat completion bridges

responses() and anthropic.messages on providers that bridge to completion()
checked max_messages against the translated chat messages, so 5 Responses
items with grouped function calls were cached and 3 Anthropic messages with
3 tool results never were. Each bridge now stamps the caller's count into
the inner call's cache controls as a frozen CallerMessageCount, which the
cache gate reads before counting the request. A count an outer bridge
already stamped is kept, a forged int or dict under the key is ignored,
and string Responses input stays unstamped so it keeps its current gate.

* test(caching): cover string input, system prompts and async writes on the chat completion bridges

Restrict the cache to completion call types so the outer Responses and
Messages caches cannot hide the inner gate, and check that string Responses
input keeps its chat message count at max_messages 0 and 1, that a separate
system prompt is not a caller message, and that async Messages under the
limit is cached. Async tests now await cache writes and flush the logging
worker in a finally block.

---------

Co-authored-by: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com>
2026-11-25 13:06:17 -08:00
..
litellm_completion_transformation fix(caching): preserve caller message limits across chat bridges (#54500) 2026-11-25 13:06:17 -08:00
mcp feat(responses): store each bridged turn's path to the root so a fork replays only its ancestors (#49519) 2026-11-23 12:43:11 -08:00
__init__.py
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_input_items_query.py fix(proxy): forward limit, order, after, before and include on GET /v1/responses/{id}/input_items (#51259) 2026-11-20 07:54:26 -08:00
test_instructions_length.py fix(responses): send bridged system prompts too long for instructions as input (#52964) 2026-11-20 11:56:47 -08:00
test_metadata_codex_callback.py
test_no_duplicate_spend_logs.py
test_null_test_fix.py
test_responses_api_bridge_flag.py fix(responses): reject an unresolvable previous_response_id on the chat completions bridge (#53766) 2026-11-25 13:32:42 +00: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(router): count a Responses WebSocket turn's input against deployment ITPM (#53594) 2026-11-24 04:26:36 -08: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 fix(openai): relay provider error codes, types, and Responses params from OpenAI-compatible backends (#51809) 2026-11-24 02:23:00 +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_responses_utils.py fix(responses): reject an unresolvable previous_response_id on the chat completions bridge (#53766) 2026-11-25 13:32:42 +00:00
test_responses_websocket_all_providers.py fix(responses): reject an unresolvable previous_response_id on the chat completions bridge (#53766) 2026-11-25 13:32:42 +00: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_streaming_iterator.py fix(responses): always stream tool argument fields as strings for every Responses provider (#53953) 2026-11-24 03:45:17 +00:00
test_streaming_iterator_error_events.py fix(openai): relay provider error codes, types, and Responses params from OpenAI-compatible backends (#51809) 2026-11-24 02:23:00 +00:00
test_text_format_conversion.py