Day 2:Supervisor-Worker Routing & Structured Handoff Protocols
Battle-tested daily lesson note • 100% runnable code, interview Q&A, test suite & interactive quiz
Day 2: Supervisor-Worker Routing & Structured Handoff Protocols
1. First-Principles Problem: The Multi-Agent "Telephone Game"
When a Supervisor delegates work to a Worker by passing raw unstructured chat history:
- The Worker wastes thousands of tokens reading irrelevant prior turns.
- Critical entities (incident IDs, namespace names, time windows) get dropped or hallucinated across hops.
Solution: Typed Handoff Envelopes (Pydantic)
Every delegation from Supervisor Worker must be serialized as a strict HandoffTaskEnvelope, and every Worker Supervisor return value must be a WorkerReportEnvelope containing:
worker_nameroot_cause_hypothesisevidence_metrics(Dict[str, Any])confidence()recommended_command
In Simple English: Stop the Agent "Telephone Game" (Typed Handoff Envelopes)
Think of the children's game "Telephone": if Agent 1 dumps a 4,000-word messy chat log onto Agent 2, Agent 2 misses the tiny pod name buried on line 43 and wastes 3,000 tokens reading greetings!
Solution (Typed Handoff Envelopes): Agent 1 hands Agent 2 a clean 5-field structured brief (incident_id, namespace, time_window, goal, constraints), and Agent 2 returns a crisp 5-field WorkerReportEnvelope (hypothesis, evidence_metrics, confidence, recommended_command). Zero fluff, zero lost facts, 80% lower token cost!