By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
When a multi-agent system returns the wrong answer, you need to know which agent failed and why. Without traces connecting every LLM call, tool invocation, and agent handoff into a single view, you're debugging blind.
Start by capturing a complete trace from the client request through every agent hop and back. This means propagating W3C traceparent context across every remote call so that spans from different agents stitch together into one coherent timeline.
The trace shows you the supervisor planning, each agent executing its task, and the final synthesis. You can see latency at each step and spot where time disappears.
Log taskId and contextId on every span. These identifiers link what the client sees in their logs to what's happening inside a remote agent's logs. When you're reading logs from five different services, these IDs are your lifeline.
Record per agent: token counts, cost, latency, tool calls, retries, and final task state. This detail lets you attribute cost by agent and by skill—find the expensive specialist quickly when bills spike.
| Test | How |
|---|---|
| Contract tests | Stand up a mock A2A agent returning each task state (COMPLETED, FAILED, INPUT_REQUIRED, REJECTED, slow) and check your client handles every one |
| Routing evals | Given 50 user requests, does the supervisor choose the right agent? |
| Trajectory evals | Judge the sequence of steps, not just the final answer: unnecessary handoffs? loops? |
| Budget tests | Does the system actually stop at the token, time and handoff limit? |
| Chaos tests | Kill a remote agent mid-task; add latency; return malformed cards. Do you degrade gracefully? |
| Security tests | A remote agent returns an injected instruction. Does a privileged tool run? |
Multi-agent systems fail at handoffs. Set timeouts on every remote call and a total deadline for the whole task. Without them, a stuck agent will hang the entire system.
Retry only idempotent operations. Use message IDs so a repeated SendMessage doesn't spawn a duplicate task. Retries need backoff to avoid hammering a struggling service.
Have a fallback plan. Deploy fallback agents for critical skills, or escalate to a human when a remote agent is down. Don't let a single service outage break the whole workflow.
When the caller gives up or hits a deadline, cancel remote tasks immediately with CancelTask. This stops agents from burning tokens and cost on work that won't be used.
Multi-agent systems fail in the seams. Test the seams: handoffs, timeouts, malformed replies.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.