litellm/tests/unit/batch_completion
izzybn 8409714ccd
fix(sdk): forward only completion()'s own arguments to fallbacks and model_list (#55227)
* fix(sdk): forward only completion()'s own arguments to fallbacks and model_list

* test(sdk): route the fallbacks regression test through the sync transport respx intercepts

* test(sdk): check a model_list call leaves the caller's list unchanged

* test(batch_completion): check a deployment never borrows another deployment's api key

* fix(sdk): count every model_list deployment of the same model toward the answer

* fix(sdk): fail over async model_list calls and reject unusable deployments

acompletion now races every matching model_list deployment through its own
acompletion call, returns the first answer, cancels the rest and raises the
last deployment's error when all fail. It runs before the provider lookup, so
a model_name alias works too. A model with no deployment, or a deployment
without a model, answers a BadRequestError on both paths.

* fix(sdk): close every stream an async model_list race does not return

When two deployments open a stream before the first answer is picked, the
other stream stayed open. The race now waits for the cancelled attempts and
closes every stream it does not return

* fix(sdk): try async model_list deployments in order instead of racing them

Racing every deployment sent each async call to all of them, left the
cancelled requests out of spend logs, and let the shared logging object
name whichever deployment started last. Each call now tries deployments
in list order and returns the first answer, so it sends one request
when the first deployment works and logs the one that answered

* test(batch_completion): drop real-time sleeps from the async model_list tests

The in-order and failover tests catch a racing or reordered implementation
without holding replies open, so they no longer wait on the clock

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-12-01 00:37:25 +00:00
..
__init__.py test: move offline router, retry and latency tests from local_testing to tests/unit (#45551) 2026-10-09 09:47:04 -07:00
test_main.py fix(sdk): forward only completion()'s own arguments to fallbacks and model_list (#55227) 2026-12-01 00:37:25 +00:00