Skip to content
mentoor

Topic 4 of 5 · 4 min read

Reading an agent's run trace

Goal: Read an agent's run trace and identify the wrong tool call and the instruction change that fixes it.

A run trace is the step-by-step record of what an agent did: each thought, tool call, input and result. Read it, not just the final answer, to see where a run went wrong. An answer can look fine while the agent used the wrong tool or invented a fact along the way.

Check yourself · 1 of 3

What should you check first when an agent's answer looks right?

Choose one answer

Why it matters

An agent is not deterministic. The same message can take a different path tomorrow. So you test it with a set of cases, not one try, and you check the path as well as the answer. Builders such as Copilot Studio, OpenAI Agent Builder, Zapier Agents and n8n show runs, tool calls or logs in a test pane or run history. Use them.

How to do it

  1. Build a small test set. Start with 8 to 10 messages: easy ones, forbidden requests, missing facts and odd wording. Keep the set and rerun it after every change.
  2. Open the trace of each run. Look at the first tool call. Was it the right tool, with the right input?
  3. Check every result against the answer. Each fact in the final answer should appear in a tool result. If it does not, the agent made it up.
  4. Count the steps. The same call repeated, or many calls for a simple message, signals a loop or a confused choice.
  5. Check the stop. Did it hand off when its rules said to?
  6. Fix one thing, rerun the whole set. A change that fixes one case can break another.

Before and after

Before: The reply says "Your order ships Friday." The tester sees a friendly answer and passes the run.

After: The tester opens the trace. The agent called Search help articles, not Get order status, and no tool returned a ship date. The date was invented. The fix is a clearer description for Get order status ("Use whenever the customer asks about shipping or delivery") and a rule in the instructions: "Give dates only from a tool result."

What goes wrong

  • Judging only the final text. A confident wrong answer passes.
  • Testing one run. A path that works once may fail the next time.
  • Fixing the instructions with a long new paragraph when the real cause is a vague tool description.
  • Changing several things at once, so nobody knows which change helped.

Examples

Reading a short trace

  1. User: "When will order 4471 arrive?"
  2. Agent calls Search help articles (query: "order 4471 arrival").
  3. Result: 2 general articles about delivery times.
  4. Agent replies: "It will arrive Friday."

The wrong tool was called at step 2, and no result contains a date. The reply is made up.

A starter test set

Two easy lookups, two messages with no order number, one refund demand, one attempt to override the rules, one message in a different language, one with two orders in it, and one that the tools cannot answer. Eight cases cover most failure types.

Key points

  • A run trace shows each tool call, input and result, so you can see how the answer was made.
  • Check every fact in the final answer against a tool result to catch made-up details.
  • Repeated calls or many calls for a simple message point to a loop or a wrong tool choice.
  • Keep a fixed test set and rerun all of it after each change.
  • Fix one thing at a time, and look first at tool names and descriptions before adding more instructions.

Common mistakes

  • Passing a run because the final text sounds right.
  • Testing each case only once.
  • Adding long instructions when the tool description is the real problem.
  • Changing many settings between test runs.

Check yourself · 2 of 3

A trace shows the agent calling the same lookup tool six times with the same input. What does this most likely mean?

Choose one answer

Check yourself · 3 of 3

In a trace, the agent answered a shipping question using Search help articles and invented a date. Which change is the best first fix?

Choose one answer

Practice items, not counted towards your mastery.

Start here