litellm/tests/unit/responses
owen-hj fb7bb3143e
fix(responses): encode ids on faked Responses streams and drop unmarked reasoning on affinity pins (#53746)
* fix(responses): encode ids on faked Responses streams and drop unmarked reasoning on affinity pins

A streamed Responses call that litellm answers with a faked stream (web search
interception, providers without native streaming, a JSON answer to a streamed
request) returned the upstream response id and raw reasoning ids and blobs. The
next turn could then not be routed back to the deployment that minted the
reasoning, and a mixed replay reached the wrong deployment and failed with
invalid_encrypted_content

The faked stream now encodes its response the way the non-streamed path does,
so the id carries the deployment and, with encrypted_content_affinity on, the
reasoning carries its origin marker. An already-encoded response is left as is.
The web search wrap now reuses the handler's replay so it passes the request
metadata too

When the affinity check pins a request by one item's marker, encrypted reasoning
with no marker is now dropped, keeping its summary, since its origin is unknown

* test(routing): expect the affinity pin to strip the unmarked reasoning blob

* test(responses): cover the post-success hook request and the /v1/messages pin strip with real objects

* fix(responses): drop ids paired with stripped reasoning so store-default turns answer

With store unset, OpenAI answers 400 to a resent function_call or assistant
message whose stored id names a reasoning item the request no longer carries

When the strip removes a reasoning item's id, the output items that follow it
in the same response now lose their ids too

* fix(responses): replay id-less web_search_call items in the chat bridge

The affinity strip drops the id of a web_search_call that follows a stripped reasoning item, since OpenAI answers 400 when that id is resent without its reasoning item. The chat bridge rejected an id-less web_search_call and answered 500 when such a session moved to a Claude group, so it now replays the item as text the same way it replays one without an action

* fix(router): send unmarked reasoning to the pinned deployment as before

Take out the unmarked reasoning strip on affinity pins, the id drop for output items after a stripped reasoning item, and the chat bridge text replay for id-less web_search_call items. The strip cost sessions that worked their hidden reasoning, and a code_interpreter_call session answered 400 where the merge base answered 200, since OpenAI needs both that call's id and its reasoning item when store is unset

The faked Responses stream id encoding stays, which is the fix LIT-11035 asks for

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-23 09:43:29 -08:00
..
litellm_completion_transformation fix(mcp): drop hosted MCP tool_choice under drop_params and honor drop_params in Bedrock batch rows (#53697) 2026-11-23 08:51:59 -08:00
mcp fix(mcp): drop hosted MCP tool_choice under drop_params and honor drop_params in Bedrock batch rows (#53697) 2026-11-23 08:51:59 -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: 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_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: 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 feat(gemini): support Gemini Live Avatar on Vertex AI realtime (#53270) 2026-11-21 15:06:59 -08:00
test_responses_websocket_all_providers.py fix(responses): replay tool calls a client answers in managed WebSocket history (#53410) 2026-11-22 22:23:30 +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: 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): encode ids on faked Responses streams and drop unmarked reasoning on affinity pins (#53746) 2026-11-23 09:43:29 -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