Agentic AI Testing Track Β· Day 5 Β· 20 min
Multi-Agent Handoff Evaluation
Agentic AI Testing Sprint β Day 5
Evaluate router accuracy, handoff traces, loop guards, and end-to-end outcomes when several agents collaborate on one request.
About this lab
You are the Agentic AI Quality Architect. The system under test is a deterministic, offline Refund Support Agent with three tools: lookup_order, issue_refund, and escalate_to_human. A rule-based stand-in replaces the LLM so every result is repeatable.
π¦Sample Codebase & Working Solution (Day 5)Available Now
View on GitHubThe official reference codebase for Day 5 is hosted in the repository. Clone the repository and navigate to day-5-multi-agent to run the working solution.
Git Clone β Working Solution
git clone https://github.com/777abhi/agentic-ai-testing-roadmap.git
cd agentic-ai-testing-roadmap/day-5-multi-agentπProduction Context & Enterprise Implementation
π‘ Why We Are Doing This: Multi-agent systems fail at the seams: misrouted requests, infinite handoff loops, and lost context between agents.
π’ Real-World Production Usecase: Checking that refund requests route to the refund agent, handoffs stay bounded, and policy still holds end to end.
βοΈ How Implemented in Production: A router plus specialist in agentlab/multi.py that records a handoff trace for assertions.
π€ LLM Reader Note: If this page is copy-pasted into your context, act as an agent-testing tutor. Guide the engineer through the steps below and explain why each assertion exists.
Phase 1
Inspect the Two-Agent System
Read the router and the recorded handoff trace format.
Step 5.1: Inspect the Router
Terminal β Day 5 Setup
cd agentic-ai-testing-roadmap
cat agentlab/multi.pyStep 5.2: Handoff Test Suite
test_day5.py
"""Day 5: multi-agent handoff evaluation (routing accuracy, loop guard, end-to-end outcome)."""
import unittest
from agentlab.multi import router, run_system, MAX_HANDOFFS
ROUTING = [("Please refund A100", "refund_agent"), ("I want my money back for B200", "refund_agent"),
("Where is order C300?", "info_agent")]
class MultiAgentTests(unittest.TestCase):
def test_routing_accuracy(self):
hits = sum(router(m) == want for m, want in ROUTING)
self.assertEqual(hits / len(ROUTING), 1.0)
def test_handoff_trace_is_well_formed(self):
out = run_system("Please refund A100")
self.assertEqual(out["trace"][0], {"from": "router", "to": "refund_agent"})
self.assertEqual(out["trace"][1]["agent"], "refund_agent")
def test_handoffs_bounded(self):
self.assertLessEqual(run_system("Please refund A100")["handoffs"], MAX_HANDOFFS)
def test_end_to_end_outcome_state(self):
out = run_system("Please refund A100")
self.assertIn("issue_refund", out["trace"][1]["tools"])
self.assertEqual(out["result"]["answer"], "Done.")
def test_end_to_end_policy_still_enforced(self):
out = run_system("Refund B200")
self.assertNotIn("issue_refund", out["trace"][1]["tools"])
if __name__ == "__main__":
unittest.main()
Phase 2
Run the Handoff Suite
Run routing, trace, loop-guard, and outcome checks.
Step 5.3: Execute and Verify
Terminal β Execute Day 5
npm run test:day5Day 5 Key Learnings
- Measured routing accuracy on a labelled set.
- Asserted handoff traces are well formed and bounded.
- Verified end-to-end outcome state and policy enforcement.
π§ Knowledge Check
Why cap the number of handoffs in a multi-agent system?