1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Shared `reqwest` client construction for upstream HTTP calls.
//!
//! Centralises timeout configuration so model and tool routers fail fast on
//! stalled upstream providers instead of leaving requests hanging
//! indefinitely. The defaults are chosen to bound mid-stream stalls while
//! still allowing slow first-token generation.
use Duration;
/// Maximum time allowed to establish a TCP+TLS connection to upstream.
const CONNECT_TIMEOUT: Duration = from_secs;
/// Maximum time allowed between successive bytes on a response body.
///
/// Bounds idle stalls on streaming (SSE) responses without limiting the
/// total stream duration. Generous enough to accommodate long first-token
/// latencies on reasoning models, short enough to surface dead connections
/// in a reasonable time window.
const READ_TIMEOUT: Duration = from_secs;
/// How long an idle pooled connection is kept before being closed.
const POOL_IDLE_TIMEOUT: Duration = from_secs;
/// TCP keepalive interval used to detect half-open connections to upstream.
const TCP_KEEPALIVE: Duration = from_secs;
/// Build the shared `reqwest::Client` used for upstream model and tool
/// calls.
///
/// Falls back to `reqwest::Client::new()` if the configured builder fails
/// (which only happens when the TLS backend cannot be initialised); the
/// fallback preserves prior behaviour rather than aborting the server.