New Tool Radar

AI Agents & Automation

How to Trace Agent Tool Calls to Debug a Failed Run

Follow an agent run tool call by tool call, so you can see exactly where it went wrong instead of guessing from the final answer.

Schematic illustration with three step boxes: capture the full trace, find the bad jump, and fix that step.

A failed agent run usually has one bad jump: a decision to call a tool with the wrong arguments, or a tool result the agent misread. The trace is the record that shows it: workflow state, branch reason, tool name, redacted arguments, result, model id, latency, retries, pauses and escalations. If you cannot query that after a bad run, you have theater, not observability.

Before you start

An agent runtime that logs tool calls, or a wrapper that records them, and one failed run to inspect.

Capture the full trace for the run

Turn on trace logging before the run, not after it fails: the trace must include every tool call with its arguments, the result returned, and the model’s next decision. Redact secrets from the arguments before they reach the log.

Keep the trace with the run id, the model id, and the prompt version, so the same failure can be reproduced later.

Walk the trace decision by decision

Start from the first tool call and read forward: what the agent asked for, what came back, and what it did next. Mark the first step where the agent’s decision does not follow from the tool result.

Common bad jumps are calling the wrong tool for the job, passing a value the tool never returned, and treating an error message as a success.

Fix the step, not the whole agent

Fix only the step that jumped: tighten the tool description, add argument validation, or change the prompt for that decision. Then re-run the same task and compare the new trace with the old one.

If the same jump appears in other runs, the fix belongs in the shared tool or prompt, not in one task.

Practice check: fictional Maple Corner order agent, failed run, 6 tool calls

The table below is fictional practice material, worked out by hand from the stated trace. It is the expected result for the practice run, not a run of any agent.

Step Tool called Result Verdict
1 lookup_order ORD-4821 1 row returned Correct
2 get_customer Customer found Correct
3 refund_order Called with wrong amount Bad jump – amount from memory
4 refund_order retry Error: amount mismatch Correct retry
5 lookup_order ORD-4821 1 row returned Correct recovery
6 refund_order Refund issued Correct

The bad jump is step 3: the agent called refund with an amount from memory instead of the amount the lookup returned. The fix is to require the amount to come from the tool result, not from the conversation.

Expected result. UNTESTED: the trace in the practice table is worked out by hand, not measured by running an agent. Capture the full trace of your own failed run, walk it decision by decision, and mark the first step that does not follow from the tool result.

Limits

  • A trace without the tool arguments cannot show a bad jump: log the arguments, redacted, not just the tool names.
  • The final answer rarely shows where a run went wrong: debug from the trace, not from the output.

Sources

See all