Skip to content

Conversation

@yashwantbezawada
Copy link

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, the ClientTimeout was created without setting the total field:

timeout=ClientTimeout(
    sock_connect=timeout.get("connect"),
    sock_read=timeout.get("read"),
    connect=timeout.get("pool"),
)

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 total parameter to ClientTimeout:

timeout=ClientTimeout(
    total=timeout.get("timeout"),  # ← Added this line
    sock_connect=timeout.get("connect"),
    sock_read=timeout.get("read"),
    connect=timeout.get("pool"),
)

Now when a user specifies timeout=10, the request will properly timeout after 10 seconds.

Impact

  • Affected: OpenRouter users (and potentially other providers using base_llm_http_handler with aiohttp_transport)
  • Severity: High - Users cannot reliably control request timeouts
  • Backward compatibility: No breaking changes - only fixes existing broken behavior

Testing

The fix is straightforward and low-risk:

  • Adds a single parameter that was missing
  • Uses the same timeout dict structure already in use
  • Does not change any other timeout behavior

When using OpenRouter with a custom timeout (e.g., timeout=10),
the request would not timeout at the specified duration. Instead,
it would continue for up to 300 seconds (aiohttp's default total timeout).

This fix adds the `total` parameter to ClientTimeout, which properly
sets the overall timeout for the entire request lifecycle.

Root cause: ClientTimeout was only setting socket-level timeouts
(sock_connect, sock_read) and connection pool timeout, but not the
total request timeout.

Fixes BerriAI#16394
@vercel
Copy link

vercel bot commented Nov 8, 2025

@yashwantbezawada is attempting to deploy a commit to the CLERKIEAI Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Nov 8, 2025

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OpenRouter timeout not respected - uses default instead of user-configured value

2 participants