[Fix] Request Timeout needs to be also fetched from litellm_settings.request_timeout#25591
[Fix] Request Timeout needs to be also fetched from litellm_settings.request_timeout#25591harish876 wants to merge 7 commits intoBerriAI:mainfrom
litellm_settings.request_timeout#25591Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
add fetch ``request_timeout`` from litellm_settings
Greptile SummaryThis PR fixes Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| litellm/main.py | Extracts timeout resolution into _resolve_completion_timeout() with an explicit None-chain; correctly handles httpx.Timeout coercion and the sentinel to distinguish the package default (6000 s) from an operator-supplied value. |
| litellm/constants.py | Introduces DEFAULT_REQUEST_TIMEOUT_SECONDS = 6000.0 as an importable sentinel; request_timeout is unchanged in value (6000 s) so Router, speech/TTS, and other subsystems are unaffected. |
| tests/test_litellm/test_completion_timeout_resolution.py | Good coverage of explicit timeout, kwargs alias, and httpx coercion paths, but the sentinel branch (litellm.request_timeout == 6000.0 → 600 s) — the core production path — is not directly tested. |
| tests/test_litellm/llms/azure_ai/claude/test_main_azure_anthropic_timeout.py | New mock test verifying that completion() propagates the resolved timeout to the Azure Anthropic handler; clean and well-scoped. |
| tests/test_litellm/llms/azure_ai/claude/test_azure_anthropic_handler.py | Adds assertions that _get_httpx_client and post() both receive the correct timeout; strengthens existing non-streaming test. |
| tests/test_litellm/llms/custom_httpx/test_http_handler.py | Two new unit tests verify that _get_httpx_client correctly applies both float and httpx.Timeout objects; no real network calls, appropriate for the unit-test folder. |
| tests/local_testing/test_azure_anthropic_sync_post.py | Integration smoke-test for per-request timeout via httpbin; correctly placed in local_testing (not test_litellm), skips when httpbin is unreachable. |
| tests/llm_translation/test_azure_openai.py | Adds top-level import httpx alongside existing from httpx import Headers/Client; no functional change. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[completion called] --> B{timeout arg set?}
B -- yes --> G[use timeout arg]
B -- no --> C{kwargs timeout set?}
C -- yes --> G
C -- no --> D{kwargs request_timeout set?}
D -- yes --> G
D -- no --> E{litellm.request_timeout set?}
E -- no --> F[600 s fallback]
E -- yes --> H{== DEFAULT_REQUEST_TIMEOUT_SECONDS 6000s?}
H -- yes sentinel fires --> F
H -- no operator-set value --> G
G --> I{httpx.Timeout and provider lacks support?}
I -- yes --> J[coerce to float read timeout or 600]
I -- no --> K[float coerce or pass through]
J --> L[resolved timeout passed to provider]
K --> L
F --> K
Reviews (5): Last reviewed commit: "Merge branch 'main' of https://github.co..." | Re-trigger Greptile
…efaults handled in the proxy
litellm_settings.request_timeout
| @@ -393,7 +393,7 @@ | |||
| ) | |||
There was a problem hiding this comment.
request_timeout default change widens scope beyond completion()
Changing the default from 6000 to 600 fixes the completion() regression flagged in the previous thread, but litellm.request_timeout is also the default for Router.__init__ (self.timeout = timeout or litellm.request_timeout, router.py:530), speech() (main.py:6760), and the Anthropic / Azure-Anthropic / OpenAI count-token handlers. All of these would silently drop from a 6000 s ceiling to 600 s for users who have not set an explicit timeout. Long-running router calls or TTS jobs that complete in 600–6000 s will now time out.
Per the "avoid backwards-incompatible changes without user-controlled flags" rule, consider keeping the constant at 6000 (or introducing a separate COMPLETION_REQUEST_TIMEOUT constant) and only using the explicit-600 fallback inside _resolve_completion_timeout() itself, where you control the scope.
Rule Used: What: avoid backwards-incompatible changes without... (source)
ishaan-berri
left a comment
There was a problem hiding this comment.
what problem does this solve ?
| return entry | ||
|
|
||
|
|
||
| def _resolve_completion_timeout( |
There was a problem hiding this comment.
this should be it's own file + class
ishaan-berri
left a comment
There was a problem hiding this comment.
- this just solves it for /chat/completions what about /responses, /messages do they have the same bug ?
- IS there a simpler way to fix this across call types
| resolved_from_litellm_request_timeout_attr = True | ||
| if timeout is None: | ||
| timeout = 600 | ||
| elif ( |
There was a problem hiding this comment.
this section looks super complicated, can you write cleaner code here ?
it's hard to follow how this logic is set
…anthropic-timeout-bug
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 29203053 | Triggered | Generic Password | fdccbcb | .circleci/config.yml | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
Relevant issues
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/test_litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
CI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Screenshots / Proof of Fix
Type
🆕 New Feature
🐛 Bug Fix
🧹 Refactoring
📖 Documentation
🚄 Infrastructure
✅ Test
Changes
litellm/main.pyAdded
_resolve_completion_timeout()with an explicitNonechain (avoidsor/truthiness bugs):timeoutargumentkwargs["timeout"]kwargs["request_timeout"](model / deployment alias)getattr(litellm, "request_timeout", None)— picks uplitellm_settings.request_timeoutafter proxy config load600secondsPreserved
httpx.Timeoutbehavior: unchanged for providers wheresupports_httpx_timeoutis true; otherwise coerce using read timeout (or600.0).completion()setstimeout = _resolve_completion_timeout(...)so all provider branches (includingazure_ai→azure_anthropic_chat_completions.completion) see the same resolved value.Docstring on the helper describes sources: deployment/model config vs
litellm_settings.request_timeout.