Week 15 • Day 2Week 15

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:

  1. The Worker wastes thousands of tokens reading irrelevant prior turns.
  2. Critical entities (incident IDs, namespace names, time windows) get dropped or hallucinated across hops.

Solution: Typed Handoff Envelopes (Pydantic)

Every delegation from Supervisor →\to Worker must be serialized as a strict HandoffTaskEnvelope, and every Worker →\to Supervisor return value must be a WorkerReportEnvelope containing:

  • worker_name
  • root_cause_hypothesis
  • evidence_metrics (Dict[str, Any])
  • confidence (∈[0.0,1.0]\in [0.0, 1.0])
  • 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!