Skip to content
mentoor

Topic 3 of 5 · 5 min read

Finding the agent that caused a failure

Goal: Locate the first wrong step in a failed multi-agent trace and name the agent responsible for it.

The agent that shows the error is rarely the agent that caused it: walk the trace back to the first wrong value and blame that step. Errors travel. A bad fact written early is passed along, summarised and trusted until something far downstream fails.

Check yourself · 1 of 3

In a failed multi-agent run, which span should you blame?

Choose one answer

Why it matters

Fixing the loudest agent wastes time. If the writer agent crashes on a missing field, tightening the writer changes nothing when the researcher never fetched the field. Teams that blame the reporter keep patching the wrong prompt.

The method

  1. Define the correct answer. What should the final output have said? Without that, you cannot find the first deviation.
  2. Start at the failure and step backwards. For each step ask: was this input already wrong when it arrived?
  3. Find the first wrong value. Look at the earliest span whose output differs from the truth. Everything after it is downstream.
  4. Classify the cause at that span.
    • Bad input to the agent (the brief was vague or contradictory).
    • Bad tool result (empty, stale, truncated or an error swallowed as text).
    • Bad model output (a guess presented as fact, an ignored instruction).
    • Bad handoff (context dropped when work moved between agents).
  5. Check it is the first one. Fix or replay from that span and see whether later spans change.

Before and after

Before: "The summariser agent produced a report with a 0 total. Fix the summariser." After reading the trace:

agent: researcher
  tool: sales.query(region="EMEA")   status ok
    result: "[]"                      <- empty list, no error
agent: analyst
  generation: "No rows returned, assuming total is 0"   <- invented fallback
agent: summariser
  generation: "Total revenue: 0"

The first wrong step is the sales.query result: the filter used EMEA while the table stores emea. The analyst compounded it by guessing. The summariser did exactly what it was told. The fix is a case-insensitive filter and a tool rule that an empty result is reported as a warning.

What goes wrong

  • Blaming the last agent. It is the one with the visible symptom.
  • Stopping at the first suspicious span. A strange output is not necessarily wrong. Check against the truth.
  • Accepting "tool returned ok". A successful call can still return nothing useful.
  • Several causes at once. A vague brief and a stale tool can both be present; list each and fix them in order.

Examples

The dropped constraint

The lead's brief to the writer says: "Draft the notice. Do not mention the discount code." In the trace, the handoff span to worker-writer contains only the first sentence. The writer is not at fault; the handoff dropped the constraint. Fix the handoff payload, not the writer's prompt.

Two causes

A report cites last year's price. The trace shows the researcher's search tool returned a 2024 page first, and the analyst did not check the date. Cause one is the tool ranking, cause two is the analyst's missing date check. Fix the tool first, because it feeds every agent that uses it.

Key points

  • Define the correct output first; the first span that deviates from it is the cause, not the last one that fails.
  • Step backwards from the failure and ask at each span whether its input was already wrong.
  • Classify the cause: bad brief, bad tool result, bad model output or a dropped handoff.
  • An ok tool status with an empty or stale result is a frequent origin of downstream errors.
  • Confirm by replaying from the suspected span and checking that later spans change.

Common mistakes

  • Fixing the agent whose output crashed instead of the one that introduced the bad value.
  • Reading tool status as ok and moving on without opening the tool result.
  • Skipping a written statement of what the correct output should have been.
  • Changing several agents at once, so you cannot tell which change helped.

Check yourself · 2 of 3

A tool span has status ok but its result is an empty list, and later agents invent a total of 0. What is the first wrong step?

Choose one answer

Check yourself · 3 of 3

The handoff span to a worker is missing the constraint that the lead's brief contained. Where do you fix it?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic