litellm/tests/integration/messages_endpoint
ryan-crabbe-berri 454989e516
fix(router): free streamed Responses API requests without waiting for a full gc (#52215)
* test(router): streamed Responses API requests are freed without a gc pass

Covers a Responses stream read to the end, one that fell back mid-stream and one the caller closed mid-stream at the Router, and a streamed /v1/responses call through the proxy read to the end or dropped by the client (#51936). Streamed chat completions through the proxy stay covered as a guard.

* fix(router): free streamed Responses API requests without waiting for a full gc

The Responses stream wrapper was a class defined per call, so the class and
its closures over the attempt sat in a reference cycle, and the fallback
generator held the wrapper strongly. A finished or dropped stream kept its
request, logging object and provider iterator alive until a gen-2 gc.

Move FallbackResponsesStreamWrapper to module level, let the generator and
recovery helpers reach it only through a weakref, and stop binding the caught
mid-stream error to a generator frame local, whose traceback pinned that frame
after a fallback or same-group retry.

Fixes #51936

* test(router): name the freed-stream cases by how they end and rerun-proof the held-open gate

Derive the parametrized endings from their Literal, drop a guard that repeated an existing fallback
ordering test, reset the integration upstream gate per run, and keep the terminal event tuple private.

* style(router): keep the existing complexity suppression on the Responses stream wrapper builder

* test(router): drop the section heading comment from the freed-stream tests

* fix(router): drop a finished Responses stream's failure explainer so the fallback walk can be freed

The explainer added for cross-group fallback errors closes over the walk, and the walk keeps the
last fallback stream, so a stream that fell back mid-way stayed alive until a full gc. Release it
once the stream ends, after every place that reads it.
2026-11-17 15:55:39 -08: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(integration): stop requiring safeguards calls to wait for the anthropic beta map (#52329) 2026-11-17 11:40:48 -08:00
responses_bridge
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(router): free streamed Responses API requests without waiting for a full gc (#52215) 2026-11-17 15:55:39 -08: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