litellm/tests/documentation_tests
kenneth-berri 74d512eb73
fix(proxy): bill full provider usage on interrupted /chat/completions streams (#54542)
* fix(proxy): bill full provider usage on interrupted /chat/completions streams

When a client disconnects mid-stream the proxy now keeps reading the provider
stream in a detached task until its final usage chunk and bills that, as
/v1/messages already does. Drains are capped and time-limited.

Ports #49715 onto current main.

Co-authored-by: nuernber <benjamin.nuernberger@jpl.nasa.gov>

* fix(proxy): bill drains stopped at shutdown on the chunks read, type the new test helpers

* fix(proxy): count drained streams on the router, bound the shutdown wait, always close the provider stream

* fix(proxy): count a drain that yields nothing on the router, give shutdown billing a minimum wait

* fix(proxy): read a drained stream's usage off its chunks when the drain yields nothing

* test(proxy): an abandoned queued stream bills the whole provider reply

* fix(proxy): a drain stopped early counts its billed tokens on the router

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

* fix(proxy): only drain a disconnected chat stream for providers that keep generating

A provider that stops generating when the connection closes would generate and bill the rest of
the reply only because the proxy kept reading. The drain now runs for Bedrock by default, and
CHAT_COMPLETIONS_DISCONNECT_DRAIN_PROVIDERS opts other providers in.

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

* fix(proxy): drain a disconnected chat stream only for Bedrock

The issue reports Bedrock, so the drain is limited to it and the setting that opted other providers in is removed.

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

---------

Co-authored-by: nuernber <benjamin.nuernberger@jpl.nasa.gov>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-30 13:46:23 -08:00
..
test_api_docs.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_circular_imports.py
test_env_keys.py fix(proxy): bill full provider usage on interrupted /chat/completions streams (#54542) 2026-11-30 13:46:23 -08:00
test_exception_types.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_general_setting_keys.py [Fix] Scope documentation workflow to match CircleCI and add missing router settings 2026-03-28 11:23:53 -07:00
test_optional_params.py Litellm dev 12 28 2024 p1 (#7463) 2024-12-28 20:26:00 -08:00
test_readme_providers.py feat(vector_stores): add Valkey as a managed vector store provider (#37002) 2026-08-18 21:45:22 +00:00
test_requests_lib_usage.py LITELLM: Remove requests library usage (#7235) 2024-12-17 12:50:04 -08:00
test_router_settings.py test(docs): read only the first column of the router_settings reference table 2026-09-18 19:11:39 +00:00
test_standard_logging_payload.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00