fix: respect user-configured timeout in OpenRouter requests #16405
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What happened?
Fixes #16394
When setting a timeout for OpenRouter requests (e.g.,
timeout=10), the request does not timeout at 10 seconds. Instead, it continues for up to 300 seconds (aiohttp's default total timeout).Root Cause
In
aiohttp_transport.py, theClientTimeoutwas created without setting thetotalfield:This meant that while socket-level timeouts were set, the overall request timeout was not, causing it to default to aiohttp's 300-second timeout.
Solution
Added the
totalparameter toClientTimeout:Now when a user specifies
timeout=10, the request will properly timeout after 10 seconds.Impact
base_llm_http_handlerwithaiohttp_transport)Testing
The fix is straightforward and low-risk: