litellm/tests/unit/responses
izzybn c1eb4031d8
fix(responses): keep every input item in the logged input (#54253)
* fix(responses): keep every input item in the logged input

The cache control and prompt management hooks ran on the role-bearing input items only and left that filtered list as the logged messages, so function_call and function_call_output items never reached logging callbacks. A stray messages field on a /responses body also replaced the logged input

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(responses): keep the lint gate level and cover the stored prompt path

The pre-call logging check read the request body through untyped attribute accesses, which pushed the type gate past its ceiling. It now goes through one typed helper. Adds a regression test for a stored prompt on /responses

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(responses): log the copy a guardrail masked, test injection on native routing

A pre-call guardrail that rewrites only messages on a Responses call keeps its masked copy in the logged input, and one that replaces input is logged too. The cache-control logging tests now run on native Responses routing and assert the merged input with the injected marker

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(responses): log a string input as a user message and keep every item in WebSocket turn logs

Logging.update_messages wraps a str input the way Logging.__init__ does, so a /v1/responses call with input="..." still logs a user message after the logged input is reset from the hooked body. Each Responses WebSocket turn now logs every item of its response.create frame, so function_call and function_call_output items reach callbacks there too. The new tests are fully typed and their guardrail stubs return new dicts

* fix(responses): log nested response.create frames and record WebSocket turns without patching Logging

* fix(responses): set a WebSocket turn's logged messages through update_messages

log_pre_api_call's messages argument and the failed-turn token estimate read Logging.messages, which still held the connection's value. Also drop the WebSocket route from the responses input check, since its pre-call body never carries input

* test(responses): prove vector store context keeps tool items in the logged input

* fix(xecguard): read input_text and output_text parts when flattening messages

* test(responses): fake OpenAI over HTTP in the logged input tests and type the XecGuard test

---------

Co-authored-by: mateo <277851410+mateo-berri@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-12-01 00:40:08 +00:00
..
litellm_completion_transformation fix(responses): refuse a previous_response_id follow-up whose stored turns are redacted (#54636) 2026-11-30 21:08:16 +00:00
mcp fix(logging): keep tracebacks in one JSON record and log the token count skip at debug (#54603) 2026-11-30 18:19:05 +00: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_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(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 refactor(types): type the kwargs reads in the responses, images, realtime, files, rerank, batches and fine-tuning entrypoints (#54653) 2026-11-26 10:07:19 +00:00
test_responses_prompt_management.py fix(responses): keep every input item in the logged input (#54253) 2026-12-01 00:40:08 +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): stop reading a cancelled background response on, and free a drained stream without a cycle collection (#54789) 2026-11-27 04:24:01 +00: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): 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): keep every input item in the logged input (#54253) 2026-12-01 00:40:08 +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): 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(router): cool down an OpenAI realtime deployment whose key OpenAI rejects (#54660) 2026-11-30 21:08:53 +00:00
test_text_format_conversion.py refactor: expose core private helpers under public names (#44871) 2026-10-07 00:05:27 +00:00