fix(anthropic): honor messages request timeout - #32827
fix(anthropic): honor messages request timeout#32827MelvinOrichiSocana-hs wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Greptile SummaryThe
Confidence Score: 4/5The change is narrowly scoped to the async Anthropic messages handler, reuses existing timeout-resolution infrastructure, and defaults to The fix is correct and well-tested. A missing test case for No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/llms/custom_httpx/llm_http_handler.py | Adds _resolve_anthropic_messages_timeout static method and threads the resolved timeout through _async_post_anthropic_messages_with_http_error_retry; logic is correct and uses the existing CompletionTimeout.resolve infrastructure. |
| tests/test_litellm/llms/custom_httpx/test_llm_http_handler.py | Adds two new mock-only tests covering timeout resolution precedence and end-to-end handler wiring; updates FakeAsyncClient.post signature to accept the new timeout kwarg, which is a necessary compatibility change. |
Reviews (1): Last reviewed commit: "fix(anthropic): honor messages request t..." | Re-trigger Greptile
|
@shivamrawat1 Thank you for taking a look |
|
merged in #33418 |
Relevant issues
Fixes #26752
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
Delays in PR merge?
N/A
Screenshots / Proof of Fix
I verified this with a real LiteLLM proxy request to
/v1/messagesand a local slow Anthropic-compatible HTTP upstream. The local upstream sleeps for1.25s, while the model config setsrequest_timeout: 0.3. This keeps the proof deterministic without sending a real provider requestConfig used for both runs:
Before fix, at base commit
bf02a4a47f, the request waited for the slow upstream and returned200, showing that the model-level timeout was not applied to the Anthropic/v1/messagesHTTP request:After fix, at commit
63019add86, the same request returns a LiteLLM timeout. The response body shows the configured0.3stimeout reached the HTTP request path:Local regression checks at commit
63019add86:Both passed locally. The targeted regression test also fails if the handler-level
timeout=handoff is removed, withassert None == 0.3Type
Bug Fix
Changes
Anthropic
/v1/messagesnow resolves per-request and configured timeouts through the shared completion timeout resolver, then forwards the resolved value into the async HTTP POST helperRegression coverage checks timeout precedence and the full async
/v1/messageshandler wiring into the HTTP client