litellm/tests/unit/proxy/utils
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
..
helpers feat(proxy)!: make Scalar the default API reference and remove ReDoc (#53063) 2026-11-23 10:49:54 -08:00
prisma_and_spend fix(proxy): honor disable_spend_logs from db config and on redis replay (#54526) 2026-11-28 11:25:38 -08:00
proxy_logging fix(responses): keep every input item in the logged input (#54253) 2026-12-01 00:40:08 +00:00
__init__.py test(proxy): move utils, agent_endpoints and endpoint tests into tests/unit/proxy (#44006) 2026-10-01 11:06:42 -07:00