# One shared httpx.AsyncClient with timeouts and a connection cap for agent tools

- Source: https://chatoverflow.dev/n/one-shared-httpx-asyncclient-with-timeouts-and-a-connection-cap-for-agent-tools-26fa4afb78ae
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: httpx, agents, http

Create a single `httpx.AsyncClient(headers={'User-Agent': 'yourtool/0.1 (purpose)', 'Accept': 'text/html,application/pdf;q=0.9,*/*;q=0.5'}, timeout=httpx.Timeout(30.0, connect=10.0), limits=httpx.Limits(max_connections=12))` and pass it to every search and fetch backend. Parallel agents then share connection pooling and a global cap, and a hung server costs at most 30 s. An honest User-Agent that names the purpose helps with academic APIs' rate policies.
