litellm/tests/integration/messages_endpoint
Rhythm Arya e6b673e6e0
fix(proxy): hold the logging object weakly in the detached stream failure hook (#51318)
* fix(proxy): hold the logging object weakly in the detached stream failure hook

The closure armed by _arm_detached_stream_failure_hook is stored on the
logging object and captured the logging object, the request data that
contains it, and the processing object that holds that data. Every
streamed /v1/messages request therefore ended in a reference cycle and
stayed in memory until a full cyclic GC pass instead of being freed by
reference counting when the stream finished.

Capture the logging object through a weakref, a copy of the request data
without the litellm_logging_obj key, and the route type as a value. The
hook adds the live logging object back to the request data when it fires.
All three callers reach the hook through the logging object, so it is
always alive at that point.

Add a regression test that streams a request to completion, drops every
reference, and checks with the cyclic collector disabled that the logging
object is gone.

Fixes #51277

* test(proxy): cover finished streamed /v1/messages calls being freed without a gc pass

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

* test(proxy): annotate the finished-stream gc test

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

* test(proxy): split the freed-calls assert message under the line limit

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

---------

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-11-15 15:13:24 -05:00
..
chat_bridge fix(anthropic)!: send /v1/messages PDF documents to OpenAI-shaped providers as file parts (#47166) 2026-10-29 08:06:12 -07:00
providers test(anthropic): expect adaptive thinking temperature dropping (#51859) 2026-11-14 21:20:11 +00:00
responses_bridge fix(anthropic): send detail on input_image parts bridged from /v1/messages to Responses (#46720) 2026-10-15 22:33:09 +00:00
safeguards fix(databricks): use the native Anthropic route for Claude /v1/messages (#46091) 2026-10-18 02:44:38 +00:00
test_anthropic_messages_caller_tools_wire.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_beta_gated_fields_wire.py feat(anthropic): pick the beta allowlist row per deployment and surface input_transformations (#49689) 2026-11-03 01:55:26 +00:00
test_finished_requests_freed_wire.py fix(proxy): hold the logging object weakly in the detached stream failure hook (#51318) 2026-11-15 15:13:24 -05:00
test_guardrail_block_stream.py fix(proxy): stream a guardrail block on /v1/messages as Anthropic events (#49010) 2026-10-29 05:32:55 -07:00
test_guardrail_long_tool_names_wire.py refactor(anthropic): rename llms/anthropic/pass_through to llms/anthropic/messages (#48510) 2026-10-27 10:08:25 -07:00
test_message_threads_wire.py feat(anthropic): forward message threads on native /v1/messages (#50976) 2026-11-10 18:33:54 -08:00
test_messages_additional_drop_params_wire.py fix(anthropic-messages): apply additional_drop_params before the unsupported param checks (#50753) 2026-11-10 01:35:35 +00:00
test_tool_result_text_wire.py feat(mistral): add native upstream token counting support (#50652) (#50653) 2026-11-14 03:19:57 -05:00