Skip to content

fix(router)!: bound fake-streamed calls by the request timeout, not stream_timeout - #47162

Merged
mateo-berri merged 14 commits into
mainfrom
litellm_fake_stream_request_timeout
Oct 17, 2026
Merged

mateo-berri merged 14 commits into
mainfrom
litellm_fake_stream_request_timeout

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Bedrock serves some stream=True calls without streaming, so no byte arrives until the answer is done
  • stream_timeout then caps the whole call and cuts slow answers

How it solves it:

  • The call picks the limit once it knows whether the stream is faked
  • A live stream still gets stream_timeout, and a faked stream gets the longer of the two

Replaces #46908

Breaking change: outside the Router, stream_timeout on a direct SDK call or in the proxy's x-litellm-stream-timeout header now cuts live streams, where it was ignored. Remove it or set it equal to timeout to keep the old behavior

User Flow

Before: a Python app streams a long structured answer from Bedrock through the SDK Router and times out at 15s

  1. The developer builds Router(model_list=[<a Bedrock model>], timeout=120, stream_timeout=15)
  2. They stream a long json_schema answer with router.completion(..., stream=True) or router.acompletion
  3. Bedrock does not stream this request, so the first chunk arrives about 20s in
  4. At 15s the call raises litellm.Timeout: Connection timed out after Timeout(timeout=15.0) seconds

After: the same call is bounded by the 120s timeout and returns the whole answer

  1. The developer builds Router(model_list=[<a Bedrock model>], timeout=120, stream_timeout=15)
  2. They stream a long json_schema answer with router.completion(..., stream=True) or router.acompletion
  3. Bedrock does not stream this request, so the first chunk arrives about 20s in
  4. The full JSON arrives, and a live stream that stalls 15s still fails

Affected release

Router.acompletion regressed in v1.106.0-rc.1, and Router.completion had it in earlier releases

Decisions

A faked stream gets the longer of timeout and stream_timeout, since no byte arrives until the answer is written

Why the longer limit, where it is picked, which streams count as faked, and what keeps its current handling

The longer value is compared limit by limit when either is an httpx.Timeout. Using timeout alone was rejected because a caller who raised stream_timeout for a slow faked stream would fail sooner. Calling stream_timeout a total-time cap was rejected because a short one meant for stalled live streams kills every slow structured answer

The Router hands completion() both values and completion() picks one, because only completion() knows whether the provider streams for real once it has mapped the request (a json_schema request on a model without native structured output is only faked after that step). The alternative was to have the Router ask the provider up front, which cannot see that case, or to pass stream_timeout into every provider handler

A stream counts as faked when any site that dispatches it fakes it: the request's fake_stream flag, the provider config the handler uses, the Responses API bridge for models without native streaming, Vertex Gemma, Bedrock invoke ai21, and Microsoft 365 Copilot. Vertex legacy code models also fake the stream, but their handler gets no timeout at all, so neither value reaches them. For Azure that is the o-series handler's own check on the deployment name, used only when base_model or the deployment name is an o-series model, which is how the call is dispatched

A direct litellm.completion(stream=True, stream_timeout=X) or litellm.responses(...) call now applies X to a live stream, where before only the Router's single value reached it. The alternative was to pass the Router's value under a private key so direct callers keep having stream_timeout ignored, but a caller who sets it means it

On a stream request the Router's timeout is already the longer of the two values, so a stream that a deployment hook (web search, code interpreter, headroom) or an MCP loop answers with one non-streaming call never fails sooner than it did before, or sooner than the same call with stream=False. The alternative was to mark those calls as faked where each hook converts them, which misses the MCP loops. A text timeout, which is what an os.environ/ value in the config resolves to, is read as a number before the two are compared

A prompt-managed model that hands off to another model group passes on only the caller's or its own timeout and stream_timeout, so the target deployment's own values still win over the Router's

The Router splits the two values on chat, text_completion, adapter completion, /v1/messages and /v1/responses. The bridged routes reach completion(), which picks as above. The native /v1/responses route picks the same way from its own fake-stream check, and the native /v1/messages route, Python or Rust, treats every stream as live. Other Router calls (embeddings, images, audio) keep the single value they got before

Each route records the timeout it applied on the call's logging object, and the timeout error's timeout attribute (the proxy's x-litellm-timeout header) and the cooldown check for caller timeouts read that value. The alternative was to work the value out again in the wrapper from the logged params, which on native /v1/messages and /v1/responses held the raw request timeout. mock_timeout on a stream waits for stream_timeout, since the mock answers before the call knows whether its stream is faked

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Last updated: 6e5bddf. QA and /live-pr-risk ran on e7b051e, the last commit with a product diff, merged in whole from #46908

Before ran at 9aab6ec and after at e7b051e against real Bedrock. Model rows use the customer's Router(timeout=120, stream_timeout=15), and route rows curl a 2-worker proxy

Case Before After
Haiku 5.5 faked, sync Timeout, 15s limit OK in 20.3s
Haiku 5.5 faked, async Timeout, 15s limit OK in 24.2s
Llama 3.3 faked, sync Timeout, 3s limit OK in 12.0s
Llama 3.3 faked, async Timeout, 3s limit OK in 15.7s
Llama 3.3 faked, wide stream_timeout OK in 9.3s OK in 10.9s
Sonnet 4.6 live, 46s long OK in 48.2s OK in 46.4s
Sonnet 4.6 live, 0.5s limit Timeout, 0.5s limit Timeout, 0.5s limit
Faked, /v1/chat/completions HTTP 408 at 15.6s HTTP 200 in 22.1s
Faked, /v1/completions HTTP 500 at 3.2s HTTP 200 in 7.3s
Faked, /v1/messages HTTP 408 at 3.3s HTTP 200 in 6.8s
Faked, /v1/responses HTTP 408 at 3.3s HTTP 200 in 10.2s
Live, /v1/messages HTTP 200 in 11.7s HTTP 200 in 12.2s
Live, /v1/responses HTTP 200 in 11.7s HTTP 200 in 11.9s
Live, header 0.5s limit HTTP 408 at 1.5s, reports 0.5s HTTP 408 at 0.6s, reports 0.5s
Web search, /v1/messages, 2s limit HTTP 200 in 11.9s HTTP 200 in 10.5s
Faked responses, 3s and 1s HTTP 408 at 2.2s, reports 1.0s HTTP 408 at 4.2s, reports 3.0s
Direct chat, Sonnet live, 0.5s OK in 22.9s Timeout, 0.5s limit
Direct responses, Sonnet live, 0.5s OK in 31.3s Timeout, 0.5s limit

Haiku 5.5 faked stream, sync

$ REPRO_STREAM_TIMEOUT=15 REPRO_MAX_TOKENS=8000 uv run python fake_stream_router.py sync fake

Before (9aab6ec)

litellm <tree>/litellm/__init__.py model=bedrock/us.anthropic.claude-haiku-5-5 mode=sync kind=fake stream_timeout=15.0 timeout=120.0
FAILED after 23.8s: Timeout: litellm.Timeout: Connection timed out after Timeout(timeout=15.0) seconds.

LiteLLM: model group 'router-bedrock-haiku' failed with the error above. No fallback was attempted.

After (e7b051e)

litellm <tree>/litellm/__init__.py model=bedrock/us.anthropic.claude-haiku-5-5 mode=sync kind=fake stream_timeout=15.0 timeout=120.0
OK after 20.3s, 11375 chars of output
Client script, fake_stream_router.py

Arguments are sync|async and fake|real. fake adds the json_schema response format, and env vars pick the model and limits

import asyncio
import os
import sys
import time

import litellm
from litellm import Router

MODE = sys.argv[1]
KIND = sys.argv[2]
MODEL = os.environ.get("REPRO_MODEL", "bedrock/us.anthropic.claude-haiku-5-5")
STREAM_TIMEOUT = float(os.environ.get("REPRO_STREAM_TIMEOUT", "5"))
TIMEOUT = float(os.environ.get("REPRO_TIMEOUT", "120"))
MAX_TOKENS = int(os.environ.get("REPRO_MAX_TOKENS", "4000"))

SCHEMA = {
    "type": "object",
    "properties": {
        "countries": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {"name": {"type": "string"}, "history": {"type": "string"}},
                "required": ["name", "history"],
            },
        }
    },
    "required": ["countries"],
}
PROMPT = "Name 25 countries and give each a detailed three-sentence history."

router = Router(
    model_list=[
        {
            "model_name": "router-bedrock-haiku",
            "litellm_params": {"model": MODEL, "aws_region_name": "us-east-1", "max_tokens": MAX_TOKENS},
        }
    ],
    timeout=TIMEOUT,
    stream_timeout=STREAM_TIMEOUT,
    num_retries=0,
)

request = {
    "model": "router-bedrock-haiku",
    "messages": [{"role": "user", "content": PROMPT}],
}
if KIND in ("fake", "nonstream"):
    request["response_format"] = {"type": "json_schema", "json_schema": {"name": "countries", "schema": SCHEMA}}
if KIND in ("fake", "real"):
    request["stream"] = True


def consume_sync():
    response = router.completion(**request)
    if not request.get("stream"):
        return len(response.choices[0].message.content or response.choices[0].message.tool_calls[0].function.arguments)
    total = 0
    for chunk in response:
        delta = chunk.choices[0].delta
        total += len(delta.content or "") + sum(len(tc.function.arguments or "") for tc in (delta.tool_calls or []))
    return total


async def consume_async():
    response = await router.acompletion(**request)
    if not request.get("stream"):
        return len(response.choices[0].message.content or response.choices[0].message.tool_calls[0].function.arguments)
    total = 0
    async for chunk in response:
        delta = chunk.choices[0].delta
        total += len(delta.content or "") + sum(len(tc.function.arguments or "") for tc in (delta.tool_calls or []))
    return total


print(f"litellm {litellm.__file__} model={MODEL} mode={MODE} kind={KIND} stream_timeout={STREAM_TIMEOUT} timeout={TIMEOUT}")
start = time.monotonic()
try:
    chars = consume_sync() if MODE == "sync" else asyncio.run(consume_async())
    print(f"OK after {time.monotonic() - start:.1f}s, {chars} chars of output")
except Exception as error:
    print(f"FAILED after {time.monotonic() - start:.1f}s: {type(error).__name__}: {str(error)[:300]}")
Haiku 5.5 faked stream, async
$ REPRO_STREAM_TIMEOUT=15 REPRO_MAX_TOKENS=8000 uv run python fake_stream_router.py async fake

Before (9aab6ec)

litellm <tree>/litellm/__init__.py model=bedrock/us.anthropic.claude-haiku-5-5 mode=async kind=fake stream_timeout=15.0 timeout=120.0
FAILED after 17.3s: Timeout: litellm.Timeout: BedrockException: Timeout Error - litellm.Timeout: Connection timed out. Timeout passed=15.0, time taken=15.142 seconds

Deployment Info: request_timeout: None
timeout: None

LiteLLM: model group 'router-bedrock-haiku' failed with the error above. No fallback was attempted.

After (e7b051e)

litellm <tree>/litellm/__init__.py model=bedrock/us.anthropic.claude-haiku-5-5 mode=async kind=fake stream_timeout=15.0 timeout=120.0
OK after 24.2s, 13288 chars of output
Llama 3.3 70B faked stream, sync
$ REPRO_MODEL=bedrock/converse/us.meta.llama3-3-70b-instruct-v1:0 REPRO_STREAM_TIMEOUT=3 uv run python fake_stream_router.py sync fake

Before (9aab6ec)

litellm <tree>/litellm/__init__.py model=bedrock/converse/us.meta.llama3-3-70b-instruct-v1:0 mode=sync kind=fake stream_timeout=3.0 timeout=120.0
FAILED after 4.9s: Timeout: litellm.Timeout: Connection timed out after Timeout(timeout=3.0) seconds.

LiteLLM: model group 'router-bedrock-haiku' failed with the error above. No fallback was attempted.

After (e7b051e)

litellm <tree>/litellm/__init__.py model=bedrock/converse/us.meta.llama3-3-70b-instruct-v1:0 mode=sync kind=fake stream_timeout=3.0 timeout=120.0
OK after 12.0s, 9437 chars of output
Llama 3.3 70B faked stream, async
$ REPRO_MODEL=bedrock/converse/us.meta.llama3-3-70b-instruct-v1:0 REPRO_STREAM_TIMEOUT=3 uv run python fake_stream_router.py async fake

Before (9aab6ec)

litellm <tree>/litellm/__init__.py model=bedrock/converse/us.meta.llama3-3-70b-instruct-v1:0 mode=async kind=fake stream_timeout=3.0 timeout=120.0
FAILED after 5.4s: Timeout: litellm.Timeout: BedrockException: Timeout Error - litellm.Timeout: Connection timed out. Timeout passed=3.0, time taken=3.146 seconds

Deployment Info: request_timeout: None
timeout: None

LiteLLM: model group 'router-bedrock-haiku' failed with the error above. No fallback was attempted.

After (e7b051e)

litellm <tree>/litellm/__init__.py model=bedrock/converse/us.meta.llama3-3-70b-instruct-v1:0 mode=async kind=fake stream_timeout=3.0 timeout=120.0
OK after 15.7s, 13441 chars of output
Llama 3.3 70B faked stream with `timeout=3` and `stream_timeout=120`, async
$ REPRO_MODEL=bedrock/converse/us.meta.llama3-3-70b-instruct-v1:0 REPRO_TIMEOUT=3 REPRO_STREAM_TIMEOUT=120 uv run python fake_stream_router.py async fake

Before (9aab6ec)

litellm <tree>/litellm/__init__.py model=bedrock/converse/us.meta.llama3-3-70b-instruct-v1:0 mode=async kind=fake stream_timeout=120.0 timeout=3.0
OK after 9.3s, 5360 chars of output

After (e7b051e)

litellm <tree>/litellm/__init__.py model=bedrock/converse/us.meta.llama3-3-70b-instruct-v1:0 mode=async kind=fake stream_timeout=120.0 timeout=3.0
OK after 10.9s, 9012 chars of output
Sonnet 4.6 live stream, 46s long, sync
$ REPRO_MODEL=bedrock/us.anthropic.claude-sonnet-4-6 REPRO_STREAM_TIMEOUT=15 uv run python fake_stream_router.py sync real

Before (9aab6ec)

litellm <tree>/litellm/__init__.py model=bedrock/us.anthropic.claude-sonnet-4-6 mode=sync kind=real stream_timeout=15.0 timeout=120.0
OK after 48.2s, 17998 chars of output

After (e7b051e)

litellm <tree>/litellm/__init__.py model=bedrock/us.anthropic.claude-sonnet-4-6 mode=sync kind=real stream_timeout=15.0 timeout=120.0
OK after 46.4s, 18494 chars of output
Sonnet 4.6 live stream, 0.5s stream_timeout, async
$ REPRO_MODEL=bedrock/us.anthropic.claude-sonnet-4-6 REPRO_STREAM_TIMEOUT=0.5 uv run python fake_stream_router.py async real

Before (9aab6ec)

litellm <tree>/litellm/__init__.py model=bedrock/us.anthropic.claude-sonnet-4-6 mode=async kind=real stream_timeout=0.5 timeout=120.0
FAILED after 4.3s: Timeout: litellm.Timeout: BedrockException: Timeout Error - litellm.Timeout: Connection timed out. Timeout passed=0.5, time taken=0.652 seconds

Deployment Info: request_timeout: None
timeout: None

LiteLLM: model group 'router-bedrock-haiku' failed with the error above. No fallback was attempted.

After (e7b051e)

litellm <tree>/litellm/__init__.py model=bedrock/us.anthropic.claude-sonnet-4-6 mode=async kind=real stream_timeout=0.5 timeout=120.0
FAILED after 1.6s: Timeout: litellm.Timeout: BedrockException: Timeout Error - litellm.Timeout: Connection timed out. Timeout passed=0.5, time taken=0.638 seconds

Deployment Info: request_timeout: None
timeout: None

LiteLLM: model group 'router-bedrock-haiku' failed with the error above. No fallback was attempted.
Proxy cases, /v1/chat/completions, /v1/completions, /v1/messages, /v1/responses

Each tree boots with QA_TREE=<tree> python nodb_proxy.py --config qa_proxy.yaml --port $PORT --num_workers 2. The wrapper drops DATABASE_URL from the tree's .env and calls the CLI's run_server

import os
import sys

import dotenv

TREE_ENV = os.path.join(os.environ["QA_TREE"], ".env")
_original_load_dotenv = dotenv.load_dotenv


def _load_without_database_url(dotenv_path=None, *args, **kwargs):
    loaded = _original_load_dotenv(dotenv_path or TREE_ENV, *args, **kwargs)
    os.environ.pop("DATABASE_URL", None)
    return loaded


dotenv.load_dotenv = _load_without_database_url
os.environ.pop("DATABASE_URL", None)

if __name__ == "__main__":
    from litellm.proxy.proxy_cli import run_server

    run_server(sys.argv[1:])

Proxy config. The base leg's chat and live cases ran before the bedrock-llama entry was added, with the other entries the same

model_list:
  - model_name: bedrock-haiku
    litellm_params:
      model: bedrock/us.anthropic.claude-haiku-5-5
      aws_region_name: us-east-1
      max_tokens: 8000
  - model_name: bedrock-sonnet
    litellm_params:
      model: bedrock/us.anthropic.claude-sonnet-4-6
      aws_region_name: us-east-1
      max_tokens: 4000

  - model_name: bedrock-llama
    litellm_params:
      model: bedrock/converse/us.meta.llama3-3-70b-instruct-v1:0
      aws_region_name: us-east-1
      stream_timeout: 3

router_settings:
  timeout: 120
  stream_timeout: 15
  num_retries: 0

Faked, /v1/chat/completions, with countries_chat.json

{"model": "bedrock-haiku", "stream": true, "messages": [{"role": "user", "content": "Name 25 countries and give each a detailed three-sentence history."}], "response_format": {"type": "json_schema", "json_schema": {"name": "countries", "schema": {"type": "object", "properties": {"countries": {"type": "array", "items": {"type": "object", "properties": {"name": {"type": "string"}, "history": {"type": "string"}}, "required": ["name", "history"]}}}, "required": ["countries"]}}}}
$ curl -sN http://127.0.0.1:$PORT/v1/chat/completions -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" -d @countries_chat.json -w '\nHTTP %{http_code} in %{time_total}s\n'

Before (9aab6ec)

{"error":{"message":"litellm.Timeout: BedrockException: Timeout Error - litellm.Timeout: Connection timed out. Timeout passed=15.0, time taken=15.13 seconds\n\nDeployment Info: request_timeout: None\ntimeout: None\n\nLiteLLM: model group 'bedrock-haiku' failed with the error above. No fallback was attempted.","type":"invalid_request_error","param":null,"code":"408"}}
HTTP 408 in 15.617263s

After (e7b051e). 3 data: events, then HTTP 200 in 22.066431s. The full output is in the gist

Faked, /v1/completions, with completions_fake.json

{"model": "bedrock-llama", "stream": true, "prompt": "Name 25 countries and give each a detailed three-sentence history.", "max_tokens": 2000, "response_format": {"type": "json_schema", "json_schema": {"name": "countries", "schema": {"type": "object", "properties": {"countries": {"type": "array", "items": {"type": "object", "properties": {"name": {"type": "string"}, "history": {"type": "string"}}, "required": ["name", "history"]}}}, "required": ["countries"]}}}}
$ curl -sN http://127.0.0.1:$PORT/v1/completions -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" -d @completions_fake.json -w '\nHTTP %{http_code} in %{time_total}s\n'

Before (9aab6ec)

{"error":{"message":"litellm.InternalServerError: InternalServerError: OpenAIException - litellm.Timeout: Connection timed out. Timeout passed=3.0, time taken=3.126 seconds\n\nLiteLLM: model group 'bedrock-llama' failed with the error above. No fallback was attempted.","type":"internal_server_error","param":null,"code":"500"}}
HTTP 500 in 3.201119s

After (e7b051e). 3 data: events, then HTTP 200 in 7.283290s. The full output is in the gist

Faked, /v1/messages, with messages_fake.json

{"model": "bedrock-llama", "stream": true, "max_tokens": 2000, "tools": [{"name": "save_essay", "description": "Save a finished essay", "input_schema": {"type": "object", "properties": {"title": {"type": "string"}, "essay": {"type": "string"}}, "required": ["title", "essay"]}}], "messages": [{"role": "user", "content": "Use the save_essay tool to save a 900-word essay on the history of the printing press. Put the whole essay in the essay field."}]}
$ curl -sN http://127.0.0.1:$PORT/v1/messages -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" -d @messages_fake.json -w '\nHTTP %{http_code} in %{time_total}s\n'

Before (9aab6ec)

{"type":"error","error":{"type":"api_error","message":"litellm.Timeout: BedrockException: Timeout Error - litellm.Timeout: Connection timed out. Timeout passed=3.0, time taken=3.003 seconds\n\nLiteLLM: model group 'bedrock-llama' failed with the error above. No fallback was attempted."}}
HTTP 408 in 3.254696s

After (e7b051e). 6 data: events, then HTTP 200 in 6.782183s. The full output is in the gist

Faked, /v1/responses, with responses_fake.json

{"model": "bedrock-llama", "stream": true, "input": "Name 25 countries and give each a detailed three-sentence history.", "max_output_tokens": 2000, "text": {"format": {"type": "json_schema", "name": "countries", "schema": {"type": "object", "properties": {"countries": {"type": "array", "items": {"type": "object", "properties": {"name": {"type": "string"}, "history": {"type": "string"}}, "required": ["name", "history"]}}}, "required": ["countries"]}}}}
$ curl -sN http://127.0.0.1:$PORT/v1/responses -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" -d @responses_fake.json -w '\nHTTP %{http_code} in %{time_total}s\n'

Before (9aab6ec)

{"error":{"message":"litellm.Timeout: BedrockException: Timeout Error - litellm.Timeout: Connection timed out. Timeout passed=3.0, time taken=3.135 seconds\n\nLiteLLM: model group 'bedrock-llama' failed with the error above. No fallback was attempted.","type":"invalid_request_error","param":null,"code":"408"}}
HTTP 408 in 3.326239s

After (e7b051e). 10 data: events, then HTTP 200 in 10.162689s. The full output is in the gist

Live, /v1/messages, with messages_stream.json

{"model": "bedrock-sonnet", "stream": true, "max_tokens": 1500, "messages": [{"role": "user", "content": "Write a 600-word history of the printing press."}]}
$ curl -sN http://127.0.0.1:$PORT/v1/messages -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" -d @messages_stream.json -w '\nHTTP %{http_code} in %{time_total}s\n'
Before (9aab6ec47b): HTTP 200 in 11.683458s
After (e7b051e1b9): HTTP 200 in 12.200673s

Live, /v1/responses, with responses_stream.json

{"model": "bedrock-sonnet", "stream": true, "input": "Write a 600-word history of the printing press."}
$ curl -sN http://127.0.0.1:$PORT/v1/responses -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" -d @responses_stream.json -w '\nHTTP %{http_code} in %{time_total}s\n'
Before (9aab6ec47b): HTTP 200 in 11.748594s
After (e7b051e1b9): HTTP 200 in 11.896104s

Live stall with the x-litellm-stream-timeout header, with sonnet_chat_stream.json. The x-litellm-timeout response header reports the limit that cut the stream

{"model": "bedrock-sonnet", "stream": true, "max_tokens": 1500, "messages": [{"role": "user", "content": "Write a 600-word history of the printing press."}]}
$ curl -sN http://127.0.0.1:$PORT/v1/chat/completions -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" -H "x-litellm-stream-timeout: 0.5" -D headers.txt -d @sonnet_chat_stream.json -w '\nHTTP %{http_code} in %{time_total}s\n'; cat headers.txt

Before (9aab6ec)

HTTP/1.1 408 Request Timeout
date: Sat, 17 Oct 2026 01:58:30 GMT
x-litellm-call-id: 6480c5da-b8ae-4087-b7f0-dd8b0d579b44
x-litellm-response-cost: 0
x-litellm-key-spend: 0.0
x-litellm-timeout: 0.5
content-length: 369
content-type: application/json
x-frame-options: DENY
content-security-policy: frame-ancestors 'none'
x-content-type-options: nosniff

{"error":{"message":"litellm.Timeout: BedrockException: Timeout Error - litellm.Timeout: Connection timed out. Timeout passed=0.5, time taken=0.632 seconds\n\nDeployment Info: request_timeout: None\ntimeout: None\n\nLiteLLM: model group 'bedrock-sonnet' failed with the error above. No fallback was attempted.","type":"invalid_request_error","param":null,"code":"408"}}
HTTP 408 in 1.512223s

After (e7b051e)

HTTP/1.1 408 Request Timeout
date: Sat, 17 Oct 2026 06:10:23 GMT
x-litellm-call-id: 754fb9f3-4c81-48f7-9bc5-35e34480c9f4
x-litellm-response-cost: 0
x-litellm-key-spend: 0.0
x-litellm-timeout: 0.5
content-length: 369
content-type: application/json
x-frame-options: DENY
content-security-policy: frame-ancestors 'none'
x-content-type-options: nosniff

{"error":{"message":"litellm.Timeout: BedrockException: Timeout Error - litellm.Timeout: Connection timed out. Timeout passed=0.5, time taken=0.501 seconds\n\nDeployment Info: request_timeout: None\ntimeout: None\n\nLiteLLM: model group 'bedrock-sonnet' failed with the error above. No fallback was attempted.","type":"invalid_request_error","param":null,"code":"408"}}
HTTP 408 in 0.554413s
Faked /v1/responses on a deployment with timeout 3 and stream_timeout 1

The same proxy also serves bedrock-llama-short, the Llama 3.3 deployment with its own timeout: 3 and stream_timeout: 1. The faked stream should run to 3s, and the x-litellm-timeout response header should report 3.0

$ curl -sN http://127.0.0.1:$PORT/v1/responses -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" -D headers.txt -d @responses_fake_short.json -w '\nHTTP %{http_code} in %{time_total}s\n'; cat headers.txt

Before (9aab6ec)

HTTP/1.1 408 Request Timeout
date: Sat, 17 Oct 2026 00:55:02 GMT
x-litellm-call-id: 0a179c5b-d769-4733-bb5e-75b39ff96c39
x-litellm-model-id: bbdc4188107f0bd73c84cb65279a666f0fb7e50efc21f6100aaeec5c5fe052df
x-litellm-version: 1.107.0
x-litellm-response-cost: 0
x-litellm-key-spend: 0.0
x-litellm-timeout: 1.0
content-length: 317
content-type: application/json
x-frame-options: DENY
content-security-policy: frame-ancestors 'none'
x-content-type-options: nosniff

{"error":{"message":"litellm.Timeout: BedrockException: Timeout Error - litellm.Timeout: Connection timed out. Timeout passed=1.0, time taken=1.148 seconds\n\nLiteLLM: model group 'bedrock-llama-short' failed with the error above. No fallback was attempted.","type":"invalid_request_error","param":null,"code":"408"}}
HTTP 408 in 2.169311s

After (e7b051e)

HTTP/1.1 408 Request Timeout
date: Sat, 17 Oct 2026 06:13:06 GMT
x-litellm-call-id: ec064c00-fe2e-4087-a538-ba698704b892
x-litellm-model-id: bbdc4188107f0bd73c84cb65279a666f0fb7e50efc21f6100aaeec5c5fe052df
x-litellm-version: 1.107.0
x-litellm-response-cost: 0
x-litellm-key-spend: 0.0
x-litellm-timeout: 3.0
content-length: 317
content-type: application/json
x-frame-options: DENY
content-security-policy: frame-ancestors 'none'
x-content-type-options: nosniff

{"error":{"message":"litellm.Timeout: BedrockException: Timeout Error - litellm.Timeout: Connection timed out. Timeout passed=3.0, time taken=3.142 seconds\n\nLiteLLM: model group 'bedrock-llama-short' failed with the error above. No fallback was attempted.","type":"invalid_request_error","param":null,"code":"408"}}
HTTP 408 in 4.187914s
Direct SDK calls without a Router

litellm.acompletion and litellm.aresponses called straight from an app, with timeout=120 and the stream_timeout named in each row. The faked row should succeed on both sides. The live rows show the breaking change in the TLDR, where the base ignored stream_timeout

import asyncio
import os
import sys
import time

import litellm

CALL = sys.argv[1]
KIND = sys.argv[2]
MODEL = os.environ.get("DIRECT_MODEL", "bedrock/us.anthropic.claude-sonnet-4-6")
STREAM_TIMEOUT = float(os.environ.get("DIRECT_STREAM_TIMEOUT", "3"))
TIMEOUT = float(os.environ.get("DIRECT_TIMEOUT", "120"))
PROMPT = "Name 25 countries and give each a detailed three-sentence history."
SCHEMA = {
    "type": "object",
    "properties": {
        "countries": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {"name": {"type": "string"}, "history": {"type": "string"}},
                "required": ["name", "history"],
            },
        }
    },
    "required": ["countries"],
}


async def completion_chars() -> int:
    extra = (
        {"response_format": {"type": "json_schema", "json_schema": {"name": "countries", "schema": SCHEMA}}}
        if KIND == "fake"
        else {}
    )
    stream = await litellm.acompletion(
        model=MODEL,
        aws_region_name="us-east-1",
        messages=[{"role": "user", "content": PROMPT}],
        max_tokens=2000,
        stream=True,
        timeout=TIMEOUT,
        stream_timeout=STREAM_TIMEOUT,
        **extra,
    )
    total = 0
    async for chunk in stream:
        delta = chunk.choices[0].delta
        total += len(delta.content or "") + sum(len(tc.function.arguments or "") for tc in (delta.tool_calls or []))
    return total


async def responses_events() -> int:
    stream = await litellm.aresponses(
        model=MODEL,
        aws_region_name="us-east-1",
        input=PROMPT,
        max_output_tokens=2000,
        stream=True,
        timeout=TIMEOUT,
        stream_timeout=STREAM_TIMEOUT,
    )
    events = 0
    async for _ in stream:
        events += 1
    return events


print(f"litellm {litellm.__file__} call={CALL} kind={KIND} model={MODEL} timeout={TIMEOUT} stream_timeout={STREAM_TIMEOUT}")
started = time.monotonic()
try:
    count = asyncio.run(completion_chars() if CALL == "acompletion" else responses_events())
    print(f"OK after {time.monotonic() - started:.1f}s, {count} {'chars' if CALL == 'acompletion' else 'events'}")
except Exception as error:
    print(f"FAILED after {time.monotonic() - started:.1f}s: {type(error).__name__}: {' '.join(str(error).split())[:300]}")

Direct chat, Llama faked

$ DIRECT_MODEL=bedrock/converse/us.meta.llama3-3-70b-instruct-v1:0 DIRECT_STREAM_TIMEOUT=3 uv run python direct_sdk.py acompletion fake
Before (9aab6ec47b): OK after 11.6s, 9360 chars
After (e7b051e1b9): OK after 16.6s, 7789 chars

Direct chat, Sonnet live, 0.5s

$ DIRECT_STREAM_TIMEOUT=0.5 uv run python direct_sdk.py acompletion live
Before (9aab6ec47b): OK after 22.9s, 8857 chars
After (e7b051e1b9): FAILED after 1.8s: Timeout: litellm.Timeout: BedrockException: Timeout Error - litellm.Timeout: Connection timed out. Timeout passed=0.5, time taken=0.632 seconds

Direct responses, Sonnet live, 0.5s

$ DIRECT_STREAM_TIMEOUT=0.5 uv run python direct_sdk.py aresponses live
Before (9aab6ec47b): OK after 31.3s, 720 events
After (e7b051e1b9): FAILED after 3.0s: Timeout: litellm.Timeout: BedrockException: Timeout Error - litellm.Timeout: Connection timed out. Timeout passed=0.5, time taken=0.636 seconds
Rust /v1/messages live stream, 0.3s and 30s stream_timeout

The SDK Router's aanthropic_messages(stream=True) against Anthropic Haiku 5.5 on the Rust path (LITELLM_RUST=1), with Router(timeout=120, stream_timeout=X, num_retries=0). The Rust path still uses stream_timeout as the whole call's limit on both sides, and the 30s row shows the 0.3s limit is what cuts it

import asyncio
import os
import sys
import time

import litellm
from litellm import Router

MODEL = os.environ.get("RM_MODEL", "anthropic/claude-haiku-5-5")
STREAM_TIMEOUT = float(os.environ.get("RM_STREAM_TIMEOUT", "0.3"))
router = Router(
    model_list=[{"model_name": "m", "litellm_params": {"model": MODEL, "api_key": os.environ["ANTHROPIC_API_KEY"]}}],
    timeout=120,
    stream_timeout=STREAM_TIMEOUT,
    num_retries=0,
)


async def main() -> None:
    print(f"litellm {litellm.__file__} LITELLM_RUST={os.environ.get('LITELLM_RUST')} stream_timeout={STREAM_TIMEOUT}")
    started = time.monotonic()
    try:
        stream = await router.aanthropic_messages(
            model="m",
            messages=[{"role": "user", "content": "Write three long paragraphs about rivers."}],
            max_tokens=600,
            stream=True,
        )
        chunks = 0
        async for _ in stream:
            chunks += 1
        print(f"OK {chunks} chunks in {time.monotonic() - started:.1f}s")
    except Exception as error:
        print(f"ERR {type(error).__name__}: {' '.join(str(error).split())[:220]} after {time.monotonic() - started:.1f}s")


asyncio.run(main())
sys.exit(0)
$ LITELLM_RUST=1 RM_STREAM_TIMEOUT=0.3 uv run python rust_msgs.py; LITELLM_RUST=1 RM_STREAM_TIMEOUT=30 uv run python rust_msgs.py

Before (9aab6ec)

litellm <tree>/litellm/__init__.py LITELLM_RUST=1 stream_timeout=0.3
ERR APIConnectionError: litellm.APIConnectionError: upstream network error: error sending request for url (https://api.anthropic.com/v1/messages) NoneType: None This looks like a bug in LiteLLM rather than in your request. File it with one clic after 3.0s
litellm <tree>/litellm/__init__.py LITELLM_RUST=1 stream_timeout=30.0
OK 172 chunks in 5.0s

After (e7b051e)

litellm <tree>/litellm/__init__.py LITELLM_RUST=1 stream_timeout=0.3
ERR APIConnectionError: litellm.APIConnectionError: upstream network error: error sending request for url (https://api.anthropic.com/v1/messages) NoneType: None This looks like a bug in LiteLLM rather than in your request. File it with one clic after 1.9s
litellm <tree>/litellm/__init__.py LITELLM_RUST=1 stream_timeout=30.0
OK 163 chunks in 5.0s
Web search on a /v1/messages stream, deployment timeout 2 and stream_timeout 120

A stream that web search answers with one non-streaming call. Config haiku-websearch is Bedrock Haiku 5.5 with timeout: 2, stream_timeout: 120, the websearch_interception callback and a Tavily search tool. It should finish with the search result and a summary on both sides. The previous tip answered 408 after 2.6s here, which the last commit fixed. Full streams are in the gist

$ curl -sN http://127.0.0.1:$PORT/v1/messages -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" -d '{"model": "haiku-websearch", "stream": true, "max_tokens": 1500, "tools": [{"type": "web_search_20250305", "name": "web_search", "max_uses": 1}], "messages": [{"role": "user", "content": "Search the web for the history of the printing press, then write a 400-word summary."}]}' -w '\nHTTP %{http_code} in %{time_total}s\n' > out.txt

Before (9aab6ec)

content blocks: server_tool_use web_search_tool_result thinking text
text words: 383
HTTP 200 in 11.949107s

After (e7b051e)

content blocks: server_tool_use web_search_tool_result thinking text
text words: 401
HTTP 200 in 10.491285s
/audit at 062a17b: PASS, 54 cells on base and twice on head, 43 controls

Base leg at merge base 9aab6ec, head and controls legs at 062a17b, each with its own Postgres, Redis, scripted upstream and 4-worker run, head twice with the same seed and order seed. The matrix has every row and the evidence. The /live-pr-risk report lists every dependent of the change and how each was checked

Contract Base Head
Faked stream slower than stream_timeout, chat, messages, responses, completions 408 or 500 at 1.0s 200
Faked stream slower than both limits 408 at 1.0s, header 1.0 408 at 2.0s, header 2.0
Live stream slower than stream_timeout, chat, messages, responses 408 at 1.0s 408 at 1.0s
Stream a web search hook answers in one call, chat and messages 200 200
42 existing Bedrock stream timeout cells green green
43 sibling interception cells not run green

The web search cells answer 408 at the 1.0s timeout on the mid-PR commit 67aab01, so they catch that regression. One existing cell, test_s7_a_negative_timeout_has_already_expired_for_streams_and_non_streams_alike, answered 200 in the second head run. It flakes at the same rate on base, and the cause is the aiohttp transport, which this PR does not touch (Low caveat)

New cells: tests/integration/providers/test_bedrock_stream_timeout_wire.py::test_f1_to_f4_a_faked_stream_slower_than_its_stream_timeout_is_answered_within_the_deployment_timeout, ::test_f5_a_faked_stream_slower_than_both_limits_times_out_at_the_deployment_timeout, ::test_c11_to_c13_a_live_stream_slower_than_its_stream_timeout_still_fails_at_the_stream_timeout, and tests/integration/streaming/test_interception_converted_stream_options.py::test_a_converted_stream_slower_than_the_deployment_timeout_is_answered_within_its_stream_timeout

Surprises, none caused or changed by this PR
  • Timeout errors print Deployment Info: timeout: None despite set timeouts
  • /v1/completions reports the base leg's timeout as HTTP 500
  • Llama 3.3 on Bedrock rejects tool_choice on /v1/messages

Type

🐛 Bug Fix

Caveats (if any)

High

  • Outside the Router, stream_timeout now cuts live streams, the declared breaking change. A stall after the first chunk raises MidStreamFallbackError

Medium

Low

  • Azure o-series, Vertex Gemma, Bedrock invoke ai21, and Microsoft 365 Copilot detection is unit-tested only, for lack of deployments
  • mock_timeout, a test-only flag, waits for stream_timeout on a faked stream
  • A faked stream that times out on a caller's timeout skips cooldown, like stream=False at the base
  • A proxy A2A agent with no streaming card keeps stream_timeout, since it fakes the stream later
  • A timeout=-1 integration cell flakes on base and head because of the aiohttp transport

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR
Bugbot summary

[!NOTE]
High Risk
Changes core HTTP timeout resolution across Router, completion, responses, and messages paths, with a documented breaking change for direct live-stream callers who set stream_timeout.

Overview
Fixes fake-streamed completions (e.g. Bedrock json_schema / non-native streaming) timing out at stream_timeout even when timeout is much larger, by teaching CompletionTimeout about StreamKind (LIVE vs FAKED vs non-streamed): live streams use stream_timeout as the read bound; faked streams use the per-limit maximum of timeout and stream_timeout.

completion() classifies faked streams (provider should_fake_stream, responses bridge, Gemma, AI21, Azure o-series, M365 Copilot, etc.) before resolving timeouts and records the applied limit on the logging object so timeout errors, proxy headers, and retries see the value actually used. The Router stops collapsing everything into one timeout—it passes timeout + stream_timeout on streaming routes and uses stream_request_kwargs where handlers need both.

Breaking: direct litellm.completion / responses (and proxy x-litellm-stream-timeout) now enforce stream_timeout on real live streams, where it was previously ignored outside the Router.

Reviewed by Cursor Bugbot for commit 6e5bddf. Bugbot is set up for automated code reviews on this repo. Configure here.

…ream_timeout

A stream=True call that the provider serves as one non-streaming request (Bedrock Converse for json_schema on models without native structured output, tools on some Llama models, ai21) gets no byte until generation ends, so stream_timeout acted as a total-duration cap. The Router now passes timeout and stream_timeout separately to chat completion calls, and completion() applies stream_timeout only when it reads a live stream.
…on_stream_timeout

# Conflicts:
#	tests/unit/llms/bedrock/chat/test_bedrock_converse_handler.py
…lit timeouts on every surface

A faked stream now takes the longer of timeout and stream_timeout, so a caller
who raised stream_timeout to cover a slow fake stream keeps that headroom.
Azure o-series dispatch is mirrored when deciding whether a stream is faked.
text_completion, /v1/messages and /v1/responses through the Router now get
timeout and stream_timeout separately, like chat calls.
Native /v1/messages and /v1/responses now record the timeout they applied, so
x-litellm-timeout and the cooldown guard read the real limit instead of the raw
request value. A prompt-managed model also passes on only the caller's or its
own timeout, so the target deployment's timeout still wins.
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litellm-stampbot

@codecov

codecov Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.89041% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
litellm/litellm_core_utils/completion_timeout.py 92.98% 4 Missing ⚠️
litellm/main.py 96.15% 1 Missing ⚠️
litellm/messages/dispatch.py 83.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litellm-stampbot

@kerry-berri

kerry-berri commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

litellm-stampbot: risk low

Approved at 2c3d4c7.

Rules (stampbot/risk_rules.yml):

  • low: no rule flagged it

Cursor Bugbot: Low Risk at 2c3d4c7. Test-only changes with no production code in this diff; risk is limited to CI runtime and any false assumptions if implementation lags these tests. Bugbot run requested, finished in 5 min.
Bugbot Low is low, Medium and High are high. The judge model was not called.

Pushes do not re-run this check. Comment @litellm-stampbot again to re-check the new head.

@kerry-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@kerry-berri kerry-berri added the risk:low Small, isolated, low-risk change label Oct 17, 2026

@kerry-berri kerry-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low risk by rule and by judgement at 2c3d4c7

…imeout' into litellm_fake_stream_request_timeout
@mateo-berri mateo-berri changed the title test(router): regression tests for faked-stream timeouts fix(router)!: bound fake-streamed calls by the request timeout, not stream_timeout Oct 17, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@codspeed

codspeed Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ 1 benchmark spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 32 untouched benchmarks


Comparing litellm_fake_stream_request_timeout (6e5bddf) with main (1552b5b)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (e0514d9) during the generation of this report, so 1552b5b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@litereview

litereview Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

⚠️ code-review

5/5 · Ready for human review

Scope: full · Full PR review.

Completed · Checks failed.

No correctness findings.

I traced the chat, text_completion, adapter, /v1/messages and /v1/responses paths from the Router through completion() and responses() to the timeout each handler applies. A live stream still gets stream_timeout. A faked stream gets the longer of timeout and stream_timeout. Retries and fallbacks recompute both values for each deployment. The breaking change (stream_timeout now cuts live streams on direct SDK calls and with the proxy header) carries the ! marker, and the PR explains the impact and migration.

Checks and execution details
  • Passed · Real testing evidence (required): The scoped paths are litellm/llms/custom_httpx/llm_http_handler.py and litellm/llms/microsoft_365_copilot/chat/transformation.py. Their changes pick which timeout applies. In the handler, _resolve_anthropic_messages_timeout now records the applied timeout. In the Copilot config, should_fake_stream returns True; only _completion_fakes_stream consumes it, because the Copilot handler already wraps every stream in MockResponseIterator. Neither change alters request, message, tool, response, chunk or usage translation. Not applicable: no LLM translation changes in the scoped paths.

For the timeout behavior itself, I ran tests/integration/run.py providers --workers 2 tests/integration/providers/test_bedrock_stream_timeout_wire.py against a real proxy with Postgres, Redis and a scripted Bedrock peer: 52 passed. That includes the new test_f1_to_f4 cases (faked ai21 converse streams on chat, messages, responses and completions, each answered within the deployment timeout), test_f5 (a faked stream times out at the deployment timeout and sets x-litellm-timeout: 2.0) and test_c11_to_c13 (a live stream still fails at stream_timeout).

  • Passed · Compatibility requirements (required): There is a real incompatibility. Before the PR, a direct litellm.completion(stream=True, stream_timeout=0.5) call or the proxy's x-litellm-stream-timeout header outside the Router had stream_timeout ignored; CompletionTimeout.resolve read only timeout/request_timeout. After the PR, resolve(..., stream_kind=LIVE) returns stream_timeout, so a slow live stream now times out. The PR description's QA rows show this: direct chat with Sonnet live at 0.5s went from OK to Timeout. Faked Router streams also wait longer now: the larger of the two limits instead of stream_timeout. The title is fix(router)!: ..., and the description has a Breaking change: paragraph with migration steps (remove stream_timeout or set it equal to timeout). The notice is complete.
  • Passed · Changed behavior and result consistency (required): Standards read: root AGENTS.md/CONTRIBUTING.md, tests/AGENTS.md, tests/integration/AGENTS.md and README.md.

Paths traced:

  • Router._update_kwargs_with_deployment(splits_stream_timeout=True) → CompletionTimeout.stream_request_kwargs, which sets timeout to the longer value and keeps stream_timeout → completion() → _completion_fakes_stream, which checks optional fake_stream (Groq/Bedrock set it in map_openai_params before the check runs), the Responses bridge, Gemma, ai21, Azure o-series and the provider config → CompletionTimeout.resolve(stream_kind) → logging.record_applied_timeout → _get_wrapper_timeout for e.timeout.
  • Native responses() uses its own should_fake_stream and for_stream.
  • In /v1/messages, the handler treats every stream as live, and the Rust dispatch path _native_kwargs substitutes stream_timeout.
  • The passthrough branch, generic handlers gated by _STREAM_TIMEOUT_AWARE_GENERIC_HANDLERS, and the prompt-management hand-off.
  • AnthropicAdapter.translate_completion_input_params forwards both timeout and stream_timeout (checked by direct execution).

Boundary cases:

  • stream_timeout absent: timeout is used unchanged.
  • stream=False: stream_timeout is ignored.
  • httpx.Timeout versus a float: compared limit by limit.
  • String values from os.environ/: coerced with float.

Retries and fallbacks: a local stub run with two deployments (stream_timeout 1 vs 30) showed each retry and fallback hop gets its own deployment's values (('http://a',120.0,1.0), ('http://b',200.0,30.0)), so no stale value leaks between hops.

Unit tests: test_completion_timeout_resolution, test_router_timeout, test_router, test_main, responses, Azure, Bedrock, Copilot and Gemma suites: 1770 passed. In the Rust dispatch suite, 24 passed. test_public_anthropic_messages_keeps_the_python_result failed, but the cause is unrelated: it reaches the live Anthropic API (401 invalid key), and it still fails with the PR's _native_kwargs change reverted.

No unresolved defects remain.

  • Passed · Targeted unit suites (optional): pytest tests/unit/test_completion_timeout_resolution.py tests/unit/test_router/test_router_timeout.py tests/unit/responses/test_responses_api_request_body.py tests/unit/llms/azure/chat/test_azure_base_model_routing.py tests/unit/llms/bedrock/chat/test_bedrock_converse_handler.py tests/unit/llms/microsoft_365_copilot/chat/test_handler.py tests/unit/llms/vertex_ai/vertex_gemma_models/test_vertex_gemma_transformation.py tests/unit/test_main.py tests/unit/test_router/test_router.py → 1770 passed in 396s.
  • Failed · Rust messages dispatch tests (optional): tests/test_litellm_rust/messages/test_dispatch.py: 24 passed, 1 failed. The new test_native_streams_are_bounded_by_stream_timeout cases passed. test_public_anthropic_messages_keeps_the_python_result makes a live Anthropic request and fails with 401 in this sandbox. It fails the same way with the PR's dispatch change reverted, so the PR did not cause it.

View review · Reviewed 6e5bddfca7e3

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@greptile-apps

greptile-apps Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge, with no new actionable findings

Summary

The PR gives fake streams the longer of timeout and stream_timeout, while live streams use stream_timeout. It carries both values through Router routes and records the timeout used for errors and cooldown checks

  • Stream calls now get a limit that matches how their provider answers.
  • The Router keeps request and stream limits separate on stream calls.
  • Timeout errors and Router checks use the limit applied to the call.

Reviews (2) · Last reviewed commit: "Merge remote-tracking branch 'origin/lit..." · Reviewed by Greptile

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread litellm/main.py Resolved
@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 6e5bddf. Configure here.

@mateo-berri
mateo-berri merged commit 16645cc into main Oct 17, 2026
99 checks passed
@mateo-berri
mateo-berri deleted the litellm_fake_stream_request_timeout branch October 17, 2026 22:08
Cartofante pushed a commit to CartoDB/litellm that referenced this pull request Oct 26, 2026
…erriAI#47419)

Backport of BerriAI#47419 to stable/1.106.x.
Cherry-picked from 3124797 (main).
Adapted to the line without BerriAI#41523. Registered rates are tracked per cost-map key in litellm.utils (_registered_pricing_fields, reset when litellm.model_cost is replaced, so a request-scoped registration does not outlive its catalog) instead of AliasedCostEntry.registered_fields. AliasedCostEntry and get_model_cost_map.py are untouched. The register_model replay now merges successive registrations as on main. An inference-profile ARN model_id is reduced to its profile id inside _invoked_model_id_for_cost rather than backporting the get_model_info ARN handling from BerriAI#46128. Only BerriAI#47419's lines are taken in completion_cost; base_model_pricing_provider (BerriAI#46318) and configured search cost (BerriAI#46571) are not. Tests: CONVERSE_ANSWER added to the slow_upstream helper (it came with BerriAI#47162, which is not backported), the isolated_pricing_registry fixture and custom-pricing helpers come from main's test file, and the ignore_stamped_cost assertion uses the line's response_cost_calculator signature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:low Small, isolated, low-risk change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants