litellm/tests/unit/llms/anthropic/messages
zoveki 89ab210fc9
fix(anthropic): close the Responses upstream when a bridged /v1/messages stream is closed (#51274)
* fix(anthropic): close the Responses upstream when a bridged /v1/messages stream is closed

* fix(anthropic): close the Responses upstream in sequence and close a sync upstream too

Closing the bridged /v1/messages stream now closes its frames first and the
Responses upstream second, the order the native Anthropic stream uses, so a
close refused while another task is reading leaves that read alone. A sync
Responses upstream, which has close() but no aclose(), is closed as well.

* fix(responses): end a sync stream read quietly when the caller closes the stream

A create stream's aclose() closes the Responses upstream while a cancelled
read can still be running in a worker thread. That read used to report an
OpenAI failure for a close the app made. Also annotate the new test locals
with Final

* fix(anthropic): close a sync Responses stream only after its in-flight read returns

Closing the httpx response under a cancelled worker read made that read fail and log
an OpenAI failure. The bridge now closes a sync upstream right after the read returns,
so the Responses iterator keeps its existing close behavior and partial-cost logging

* fix(anthropic): let the reading thread close a sync Responses stream after its in-flight read

* chore: re-run pull request checks

* fix(anthropic): end a create stream's read quietly once another task closes it

* fix(anthropic): import SupportsAclose from stream_close, where main moved it

* test(anthropic): record close-test failures with a real Logging callback, not a mock

* test(anthropic): type the failure recorder callback and give the logging object a fixed start time

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-17 22:14:25 +00:00
..
adapters fix(anthropic): close /v1/messages thinking blocks with a signature and keep bridged output (#52116) 2026-11-16 20:44:27 -08:00
context_management feat(callbacks-parallel-request-limiter): port parallel request limiter v3 to a rust callback (#51537) 2026-11-16 22:56:38 -08:00
native fix(anthropic): close /v1/messages thinking blocks with a signature and keep bridged output (#52116) 2026-11-16 20:44:27 -08:00
responses_adapters fix(anthropic): close the Responses upstream when a bridged /v1/messages stream is closed (#51274) 2026-11-17 22:14:25 +00:00
__init__.py
conftest.py feat(redis): serve the proxy's common Redis call with Rust stores (#50170) 2026-11-06 06:01:11 +00:00
test_advisor_orchestration.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_anthropic_native_passthrough_spend_logging.py refactor(anthropic): rename llms/anthropic/pass_through to llms/anthropic/messages (#48510) 2026-10-27 10:08:25 -07:00
test_caller_model_checks.py feat(callbacks-parallel-request-limiter): port parallel request limiter v3 to a rust callback (#51537) 2026-11-16 22:56:38 -08:00
test_convertible_blocks.py refactor(anthropic): rename llms/anthropic/pass_through to llms/anthropic/messages (#48510) 2026-10-27 10:08:25 -07:00
test_reasoning_effort_fields.py fix(azure_ai): send reasoning_effort to Foundry reasoning models (#51775) 2026-11-16 16:40:16 -08:00
test_safeguards.py refactor(router): move router callers onto the entry points and invert the proxy imports (#48847) 2026-10-29 17:26:33 +00:00
test_stream_assembly.py refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00