litellm/tests
ellisc42 34dea88f04
fix(router): send /v1/messages message_start live during thinking when retries are on (#54319)
* fix(router): send /v1/messages lifecycle frames live when only a retry can take over

With the router's default retries and no fallback, message_start and
content_block_start were held until the first content delta, so a long
thinking pass showed the client nothing but the proxy's keepalive ping.
They now go out as soon as the provider sends them, and a retry before
content drops its repeat of the frames already sent. A fallback or a
refusal fallback keeps the hold.

* fix(router): send /v1/messages message_start live when only a retry can take over

With default num_retries, every lifecycle frame waited for the first content delta, so a long thinking pass showed the client nothing but the 15 s keepalive ping. Now message_start, plus any ping or SSE comment in front of it, goes out as soon as the provider sends it whenever only a same-group retry can take over

Block starts and every other pre-content frame stay held, because a retry's first block can differ from the first attempt's (adaptive thinking can open text where the first attempt opened thinking, and redacted_thinking carries new data each time). A retry or a context-window fallback drops its own message_start and then sends its frames unchanged, so the client sees one message_start and a valid frame sequence. A fallback, refusal fallback, order level, or weighted failover left keeps the full hold, and so does a stream whose first frame is not recognized

* test(integration): pin message_start sent live when only a retry can take over

* test(router): cover live pings, repeat retries, replayed retries, and a cut retry on /v1/messages streams

* test(integration): expect the first attempt's message id when a retry follows a live message_start

* test(integration): assert one message_start on a retried bridged messages stream

* fix(router): keep message_start held for threaded /v1/messages streams

A request with a message thread keeps the old hold, so the client sees the message id of the attempt that answers and its next continue finds the thread. Also types two test literals and the guardrail initializer lookup so the basedpyright count stops flipping between runs.

* fix(router): keep message_start held when a context window fallback can answer the stream

A context_window_fallbacks list for the stream's group can take over after a retry fails, so the stream policy now reports it and message_start waits for content as before. streaming.py also reuses the shared SSE frame terminators.

* fix(router): keep held /v1/messages streams on base's raw reads so a ping next to message_start stays held

* fix(router): detect a content delta split across reads on held /v1/messages streams

* docs(router): name context_window_fallback in the stream_policy stub

* fix(router): keep the client's message id and ping order after a live message_start retry

* test(messages): read the retried stream's spend row under the id the client saw

* fix(router): log the client's message id on a retried stream's own logging object

* fix(messages): carry the call's logger on the SDK stream so a retried stream logs the client's message id

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-25 12:06:26 +00:00
..
_support test(rate-limit): wait for the Rust limiter's queued log lines before comparing them (#54257) 2026-11-24 21:17:18 +00:00
audio_tests feat(vertex-ai)!: support gemini 3.1 flash tts (#31915) 2026-10-21 04:18:42 +00:00
base_sdk_tests fix(packaging): ship the license public key in the litellm-proxy sdist (#52970) 2026-11-19 23:18:32 +00:00
basic_proxy_startup_tests feat(docker)!: one shipped image and one entrypoint beside the Dockerfile (#43332) 2026-11-10 18:32:16 -08:00
benchmarks fix(guardrails): classify only the frames each read completes in Presidio's first-frame wait (#54379) 2026-11-25 11:15:49 +00:00
code_coverage_tests feat(gnani): add Prisma v2.5 and v3.0 realtime transcription (#53828) 2026-11-25 10:51:59 +00:00
documentation_tests chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
e2e test(responses-bridge): cover multi-turn GPT-6.2 prompt caching on OpenAI and Bedrock Mantle (#54361) 2026-11-25 11:39:57 +00:00
e2e_harness test(e2e): move the Claude Code matrix to Opus, Sonnet and Haiku 5.5, Fable 5.2 and GPT-6 (#54305) 2026-11-25 01:47:03 +00:00
fixtures
harness_e2e fix(harness): set PWD to the working directory of local sandbox commands (#47530) 2026-10-20 20:06:11 +00:00
integration fix(router): send /v1/messages message_start live during thinking when retries are on (#54319) 2026-11-25 12:06:26 +00:00
rust-python-harness fix(gateway): serve messages drop, summary and timeout settings like Python (#51236) 2026-11-25 09:26:12 +00:00
test_litellm_rust test(rust): update rust-wheel messages tests to main's current behaviour (#54223) 2026-11-24 12:24:37 -08:00
typing chore: move config and docs off the repo root (#50966) 2026-11-11 18:29:35 -08:00
unit fix(router): send /v1/messages message_start live during thinking when retries are on (#54319) 2026-11-25 12:06:26 +00:00
windows_tests ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
__init__.py
_fake_openai_endpoint_server.py
_flush_vcr_cache.py
_live_test_helpers.py
_master_key.py
_module_state.py ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
_openai_record_replay_proxy.py
_process_helpers.py
_vcr_conftest_common.py ci: remove CircleCI (#50950) 2026-11-11 15:38:27 -08:00
_vcr_redis_persister.py
_wait_helpers.py
_ws_vcr.py
AGENTS.md
capturing_transport.py
eval_swe_bench.py
fake_openai_endpoint.py
gettysburg.wav
large_text.py
openai_batch_completions.jsonl
pyrightconfig.json
README.MD
test_logging.conf
test_rust_python_harness.py
VCR_TESTING.md
white_100x100.png

In total litellm runs 1000+ tests

[02/20/2025] Update:

To make it easier to contribute and map what behavior is tested,

we've started mapping the litellm directory in tests/unit

This folder can only run mock tests.