New Tool Radar

AI Agents & Automation

How to Set a Per-Tool Timeout on Agent Tool Calls

Set a per-tool timeout on agent tool calls so one slow tool cannot stall the whole run.

Schematic with three steps: Set the timeout from the tool's normal; Decide what happens when the timeout fires; Test with a slow tool and confirm.

A tool call with no timeout can hang forever, and a hung tool call is a hung run. The fix is a timeout per tool, not one global timeout for the whole agent: a search that should take two seconds gets a short timeout, while a report that takes a minute gets a longer one. CrewAI’s agent settings already separate these concerns, with a maximum execution time for the task and a maximum requests-per-minute limit alongside it. Set the timeout from how long the tool normally takes, not from a guess, and decide in advance what the agent does when the timeout fires: retry once, fall back, or stop with a clear message.

What you need

  • A tool that has hung or run slowly before, with its normal run time noted
  • A timeout length per tool, based on its normal run time plus headroom
  • A named outcome for a timeout: retry once, fall back, or stop

Step 1: Set the timeout from the tool’s normal time

For each tool, set a timeout a little above its normal run time: a two-second search gets a short timeout, a slow report gets a longer one. One timeout for all tools fits none of them.

Step 2: Decide what happens when the timeout fires

Write down the timeout outcome per tool before it happens: retry once with a shorter request, try a fallback tool, or stop and report. A timeout with no planned outcome is just a different way to hang.

Step 3: Test with a slow tool and confirm the run continues

Run a task against a deliberately slow tool and confirm the call times out, the planned outcome happens, and the run either recovers or stops cleanly instead of hanging.

Worked example: synthetic tool timeout check

The table below is a synthetic example. It shows the expected result of per-tool timeouts; no agent was run.

Tool Timeout On timeout
Search 10 seconds Retry once
Fetch page 30 seconds Fall back
Build report 120 seconds Stop and report
No tool hangs the run Yes Pass

Expected result (UNTESTED). each tool has its own timeout, a slow call times out on schedule, and the run recovers or stops cleanly. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • A timeout that is too short kills slow but healthy calls, so set it from measured times.
  • A timeout stops the wait, not the work: the tool may still finish on its own side.
  • Timeouts do not fix a slow tool; they only bound the damage it can do.
  • A retry after a timeout can repeat a write, so pair retries with idempotency keys.

Sources

See all