New Tool Radar

AI Agents & Automation

How to Measure Agent Tool Call Latency to Find the Slow Tool

Measure agent tool call latency so the slowest tool is found and fixed first.

Schematic with three steps: Record the duration of every tool call; Add the times up per tool and; Fix the slowest tool first, then measure.

When a run is slow, guessing which tool is slow wastes the fix. Measuring tells you: record how long each tool call takes, add the times up across runs, and the slowest tool stands out. LangSmith traces record tool calls and their timing, which makes the measurement a matter of reading the trace rather than adding new code. Measure before you optimize, because the tool you suspect is rarely the one that is slow, and fixing the wrong tool leaves the run just as slow as before.

What you need

  • A run with several tool calls, and a trace or log that records each call’s duration
  • A list of the tools to compare, with their call counts
  • A threshold for slow, such as a tool taking more than half the run’s time

Step 1: Record the duration of every tool call

For each tool call, record when it started and when it returned, with the tool name and the run id attached. A duration measured once is a sample; measure across several runs.

Step 2: Add the times up per tool and rank them

Sum the durations per tool across the runs and rank the tools slowest first, with their call counts beside them. A tool that is slow once is noise; a tool that is slow every time is the problem.

Step 3: Fix the slowest tool first, then measure again

Fix the top tool on the list, whether that means a faster query, a cache, or a shorter request, then measure again and confirm the run got faster. If it did not, the next tool on the list is the problem.

Worked example: synthetic tool latency check

The table below is a synthetic example. It shows the expected result of measuring latency; no tool was timed live.

Tool Calls Total time
search_docs 12 48 seconds
lookup_order 12 6 seconds
send_message 4 2 seconds
Slowest tool found first search_docs Pass

Expected result (UNTESTED). the timings show search_docs taking 48 seconds against 6 for the next tool, so it is fixed first. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Latency varies with the input, so compare the same kind of call, not different ones.
  • A slow tool may be slow because its service is slow, not because the tool is wrong.
  • Measuring adds overhead of its own, so keep the recording light.
  • Total time hides the shape: one slow call and many fast ones need different fixes.

Sources

See all