---
title: "Set timeouts on every call · Agent Wranglers"
url: https://agentwranglers.se/playbook/api-design/reliability/timeouts
updated: 2026-10-20
licence: "All rights reserved"
---

# Set timeouts on every call

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [Reliability](https://agentwranglers.se/playbook/api-design/reliability)
- Rule: Give every outgoing and incoming request a time limit. Never wait forever on another service.
- How: Set a connect timeout and a total timeout on each HTTP client, database and queue call. Set each limit to about twice that call's 99th percentile time. Without measurements yet, start at 1 second to connect and 3 seconds in total. Make each inner limit shorter than the outer one, so the caller gets a clear 503 or 504 problem. The database query is shortest, then the server's request, then the screen's, as in [query time limits](https://agentwranglers.se/playbook/data/operations/query-timeouts) and [screen request time limits](https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures/request-timeouts). Model calls follow [model timeouts](https://agentwranglers.se/playbook/ai-features/latency-cost-and-fallbacks/model-timeouts).
- Check: Point a staging dependency at a server that accepts connections and never answers. The request fails within the set limit with a 504 or 503 problem.

Example:

```js
const response = await fetch('https://stock.example.com/items/TEA-01', { signal: AbortSignal.timeout(3000) })
```

```python
import httpx

response = httpx.get("https://stock.example.com/items/TEA-01", timeout=httpx.Timeout(3.0, connect=1.0))
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers api design playbook: https://agentwranglers.se/playbook/api-design/reliability/timeouts`.

- Previous: [Retry with backoff and jitter](https://agentwranglers.se/playbook/api-design/reliability/retry-backoff)
- Next: [Tell clients their rate limit](https://agentwranglers.se/playbook/api-design/reliability/rate-limit-headers)
- [Reliability](https://agentwranglers.se/playbook/api-design/reliability)
