litellm/tests/unit/test_router
Charlie Freeman f6962c2ee8
fix(streaming): keep OpenRouter chunks that carry only reasoning_details (#48412)
* fix(streaming): preserve reasoning_details chunks in stream wrapper and proxy serializer (#48401)

* test(streaming): cover OpenRouter chunks that carry only reasoning_details end to end

Replace the predicate-level test with a stream test in the mapped test file. It feeds
OpenRouter SSE frames through the OpenRouter chunk parser and CustomStreamWrapper, sync
and async, and checks that the signature and encrypted reasoning_details pieces reach the
caller

* fix(anthropic): keep OpenRouter reasoning_details signatures in /v1/messages streams

Keeping reasoning_details-only chunks in the stream let them reach the
/v1/messages adapter, which opened an empty text block before tool calls
and still sent an empty signature_delta

The adapter now reads the signature from reasoning_details into the open
thinking block, and drops reasoning_details-only chunks that carry nothing
it can render, such as Gemini's encrypted reasoning

* fix(anthropic): split bundled reasoning_details signatures from text in /v1/messages streams

A chunk that carries a reasoning_details signature next to answer text or thinking text now splits into separate pieces, so the text block keeps its text and the signature stays in its thinking block

* fix(anthropic): keep /v1/messages streams unchanged by OpenRouter reasoning_details pieces

/v1/messages no longer turns a reasoning_details signature into a signature_delta. The proxy replays thinking blocks to OpenRouter as thinking_blocks, which OpenRouter ignores, so a streamed signature gave no replay benefit and two signed blocks could merge under one signature

A frame that holds only reasoning_details /v1/messages cannot show is skipped, so the stream wrapper fix opens no empty block before a tool call

* fix(streaming): count reasoning_details as sent output for fallback and /v1/completions

A stream that already sent a reasoning_details piece now counts as started for
mid-stream fallback and continuation, the same as reasoning_content, so another
deployment's answer is never spliced in after it. /v1/completions frames carry
the reasoning_details piece the same way they carry reasoning_content, instead
of turning it into an empty text frame.

* fix(anthropic): skip a reasoning_details-only /v1/messages frame only when it has one choice

---------

Co-authored-by: Charlie Freeman <243496084+cf3901646@users.noreply.github.com>
Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-25 19:24:55 -08:00
..
core fix(bedrock): send pass-through calls the model id chat completions sends (#53836) 2026-11-25 18:42:28 -08:00
__init__.py
test_enforce_model_rate_limits.py fix(gemini): return an error instead of an empty 200 when a Gemini image request gets no image (#29125) 2026-11-25 20:55:23 +00:00
test_io_token_rate_limits.py test(router): pin the clock in the mixed itpm and rpm limit test so a minute rollover cannot move its rpm counter (#54554) 2026-11-25 23:42:12 +00:00
test_router.py fix(streaming): keep OpenRouter chunks that carry only reasoning_details (#48412) 2026-11-25 19:24:55 -08:00
test_router_callback_hook_sequence.py
test_router_endpoints.py fix(proxy): resolve admin oidc api_key references on batch cancel, fine-tuning listing, OCR, /v1/messages and cache prediction (#53678) 2026-11-23 10:11:10 -08:00
test_router_entry_points.py
test_router_facade.py
test_router_fallbacks.py fix(router): preserve destination bearer credentials on Anthropic fallbacks (#54271) 2026-11-24 17:12:02 -08:00
test_router_fuzz_regressions_rust_only.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
test_router_get_deployments.py
test_router_helper_utils.py fix(gemini): return an error instead of an empty 200 when a Gemini image request gets no image (#29125) 2026-11-25 20:55:23 +00:00
test_router_host.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
test_router_max_parallel_requests.py feat(tts)!: stream audio from the provider as it arrives on /v1/audio/speech (#46222) 2026-11-17 15:03:12 +00:00
test_router_provider_endpoints.py
test_router_retries.py fix(router): with pre-call checks on, retry a context window error on a group deployment serving another model (#54157) 2026-11-25 10:57:40 +00:00
test_router_surface_check.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
test_router_timeout.py feat(messages): serve bedrock invoke messages on rust only (#51330) 2026-11-15 16:58:31 -08:00
test_router_vector_store_endpoints.py