Skip to content

How to debug multi-agent systems

Record every handoff in one connected trace, then find the first agent whose output went wrong, not the last one that showed the error. Fixing the right agent, with the right evidence, is what the four steps below do.

By Arun Prasad · Published · Last updated

On this page

Why debugging multi-agent systems matters

A multi-agent run can report success at every step and still miss what the user wanted. When one agent hands a bad output to the next, the error travels, and the place where it shows up is often far from where it started.

AI agents don't fail like normal software. A tool can return a 200 and the task can still fail. Standard monitoring shows the request went through, not whether the answer was right. In a multi-agent system this gets worse: errors can cascade through handoffs, and agent coordination requires careful state tracking. Hidden agent state is a third source of failures.

The four steps below follow that order. First capture the handoffs, then find the first bad output, then check state, then reproduce the failure.

Step 1: Track communication between agents when one hands work to another

Capture each handoff as a step in one connected run. Then you can read the whole path in order.

For each handoff, you want these things in the run:

  • What the sending agent passed on.
  • What the receiving agent got.
  • The tool calls the receiving agent made.
  • Any retries.

If the sender's output and the receiver's input are both in the run, you can see whether the message changed on the way or was already wrong when it left.

In PRISM by Block Convey, the Agent Runs view shows steps, tool calls, retries, handoffs and state. Agent steps appear when your integration sends them.

If your agents run as separate services, give every trace the same session ID so they group into one conversation. Session IDs can't be backfilled after the fact, so set them before you need them.

Step 2: Find which agent caused a failure that spread to the others

Start from the failing outcome and walk backward through the handoffs. Stop at the first step where the output no longer matched what the task needed. Fix the problem there, not at the last agent that threw the error.

A practical way to do it:

  • Write down what the user was trying to get done. This is the outcome you check against.
  • Start at the final output and ask whether it met that goal.
  • Move one handoff back and ask the same question of that agent's output.
  • Keep going until you reach an output that was correct. The step right after it is your first bad output.

That's how you find the first bad output: walk back through the handoffs and judge each one against the goal.

Status codes won't tell you where to stop, because every step may have succeeded. You have to judge each output against the goal.

PRISM helps with the judging. It tracks the outcome against the user's goal, not just span status. It also groups repeated failures into patterns and shows how many sessions share each one, so you can tell a one-off from something that keeps happening. For a failure, it traces it to a likely cause: prompt, missing source, retrieval, stale state, tool choice, parameter, guardrail or workflow step. Treat that as a lead to check against the trace, not a verdict.

Step 3: Catch memory drift in an agent's hidden state

Memory drift happens when an agent's knowledge diverges from reality over multiple turns. To catch it, compare what the agent should know at each step with the state recorded in the run. Then look at the multi-turn session for the point where behavior starts to drift.

You can only check state that was recorded.

With state recorded, do this:

  • Write down what the agent should know at a given step. For example, the user's order number, or the decision a previous agent made.
  • Compare that with the recorded state at that step.
  • If they differ, step back until you find where the state changed. That is where the drift began.
  • Look at the session as a whole. Drift often shows across turns: early answers are right and later ones slowly aren't.

In PRISM, the Sessions view shows the multi-turn journey and drift. The Agent Runs view shows the state recorded at each step.

Step 4: Replay a multi-agent run to reproduce a failure

Reproduce the failure by running the same inputs through your agents again. One passing replay does not prove a fix, because model output varies from run to run.

Because results vary, run the failing case several times before and after you change anything. If it fails in some runs and passes in others, you've learned something about the cause. A single pass after a fix tells you much less than it seems to.

Keep the failing case. Once you've fixed the problem, it should become a test you run every time you change the system.

PRISM has two features that help here:

  • Synthetic Scenarios. You describe the app and PRISM writes simulated users from that description and your Knowledge Base. A failing scenario becomes a regression test. They are built from the app description and Knowledge Base, not from your production sessions.
  • Checking the fix. After a fix is merged, PRISM compares pass rates for the 7 days before and the 7 days after the merge. That tells you whether the pass rate moved, not just whether one run passed.

How this looks in production

PRISM shows a multi-agent run through four connected views:

  • Traces: per-run request, response, model, cost, timing and scores.
  • Sessions: the multi-turn journey and drift.
  • Agent Runs: steps, tool calls, retries, handoffs and state.
  • Scores & Alerts.

When a run fails, PRISM traces it to a likely cause from this list: prompt, missing source, retrieval, stale state, tool choice, parameter, guardrail or workflow step. It also groups repeated failures into patterns and shows how many sessions share each one. This is how you move from "the last agent errored" to "the second agent's handoff was wrong." See Agent Observability for the views in detail.

As in the steps above, what you see depends on what your integration sends.

Getting data in. The SDK is Python only. LangGraph is supported through wrap_langgraph. Traces that share a session_id form one conversation. For other languages or frameworks, PRISM accepts OpenTelemetry (OTLP) trace export over http/protobuf or http/json; gRPC is not served. With OpenTelemetry, PRISM groups turns only from attributes you declare (gen_ai.conversation.id, session.id or prismtrace.session_id). It does not guess sessions. See integrations for the full list.

Example (Python, LangGraph):

Example · text
# pip install "prismtrace-sdk>=0.5.1"

import prismtrace
from prismtrace import wrap_langgraph

# Wrap your compiled LangGraph app before you call it.
# Every run shares a session_id so the turns group into one conversation.
traced_app = wrap_langgraph(app)

# Set a session_id before invoking — it cannot be backfilled later.
config = {"configurable": {"thread_id": "order-flow-42"}}

# Step 1 — first agent
result_1 = traced_app.invoke(
    {"messages": [{"role": "user", "content": "Check the status of order 1234."}]},
    config=config,
)

# Step 2 — second agent picks up the same conversation
result_2 = traced_app.invoke(
    {"messages": result_1["messages"] + [{"role": "user", "content": "Now escalate it."}]},
    config=config,
)

# Both invocations appear as steps in one Agent Run in PRISM,
# linked by the session_id PRISM reads from the LangGraph thread_id.

If you'd like to see your own handoffs in one run, you can send traces from your agents to PRISM.

Common mistakes

Most of these come from one habit: treating the last visible error as the cause.

  • Debugging the last agent instead of the first bad output. The agent that threw the error is often just the one that received bad input. Fix: walk back through the handoffs (Step 2) and fix at the first output that stopped matching the task.
  • Trusting step status without checking the outcome. Your agent can return success on every step and still miss what the user wanted. Fix: judge each output against the user's goal, not against whether the step returned without error.
  • Treating one passing replay as proof. Model output varies, so one pass can be luck. Fix: run the failing case several times before and after the change, and keep it as a regression test.
  • Leaving out the handoff data that would show where the output went wrong. If the message between two agents isn't in the run, you can't tell which side broke it. Fix: send what each agent passed and received, plus the state it relied on, before you need to debug.

Find the first agent that got it wrong

Send your agents' runs to PRISM and read each handoff in Agent Runs.

Free to start, 100 credits each month.