A tool call that runs for a long time can block the whole agent loop, and a call that never returns wastes the run. A timeout ends the call after a fixed time and lets the agent report the failure or try another way. Set the timeout from how long the tool normally takes, with room to spare.
Checked on 2026-11-29. We did not run any tool for this guide. Every result below is an expected result, marked UNTESTED, for you to confirm on your own files.
Prerequisites
- A tool that sometimes runs slowly
- A record of how long the tool normally takes
- A timeout setting in the agent or tool config
Steps
1. Measure the normal run time
Run the tool three times and note how long each run takes.
Expected result: Three run times are recorded, for example 8, 11 and 9 seconds.
2. Set the timeout above the normal time
Set the timeout to about three times the normal time, for example 30 seconds for a 10 second tool.
Expected result: A timeout value is set and written down.
3. Run the tool with the timeout on
Run the task and watch what happens when the tool is slow.
Expected result: The tool finishes in time, or the timeout stops it and the agent reports it.
4. Handle the timeout in the agent
Tell the agent what to do on a timeout: report it, retry once, or skip the step.
Expected result: A timeout action exists: report, retry once, or skip.
Worked example
A practice search tool normally takes 10 seconds. The timeout was set to 30 seconds.
| Run | Seconds taken | Timed out? |
|---|---|---|
| Run 1 | 8 | No |
| Run 2 | 11 | No |
| Run 3 | 45 | Yes |
Expected result: Two runs finish under the timeout and the slow run stops at 30 seconds, so the agent reports it instead of waiting (UNTESTED – confirm it yourself.)
Verdict table
| Check | Expected result | Pass? |
|---|---|---|
| Measure the normal run time | Three run times are recorded, for example 8, 11 and 9 seconds. | – |
| Set the timeout above the normal time | A timeout value is set and written down. | – |
| Run the tool with the timeout on | The tool finishes in time, or the timeout stops it and the agent reports it. | – |
| Handle the timeout in the agent | A timeout action exists: report, retry once, or skip. | – |
Limits
- A timeout that is too short stops good work; measure first and set it with margin.
- A timeout does not fix why the tool is slow; check the tool or the network.
Sources
- Model Context Protocol (Stanford CS329T slides) – checked 2026-11-29
- The Model Context Protocol (MCP) for compliance data – checked 2026-11-29
- What is the Model Context Protocol (MCP)? – checked 2026-11-29
- Ollama v0.9.1 release notes – checked 2026-11-29
