Lab 21.5 Solution: Architecting Multi-Agent Systems
Goal
This solution provides the architectural blueprints and justifications for the scenarios presented in the Milestone Challenge.
Scenario 1: The Legal Review Pipeline
Recommended Pattern: Hybrid Static + Structured Routing
-
Design:
START->ExtractorExtractor->PrivacyChecker(Edge 1)Extractor->LiabilityChecker(Edge 2)PrivacyChecker->JoinNodeLiabilityChecker->JoinNodeJoinNode->ReviewRouter(Structured Routing via Dictionary)ReviewRouter->SeniorPartner(IF high risk)ReviewRouter->Summarizer(IF low risk)
-
Justification:
- Performance: Using parallel edges and a
JoinNodeensures that both legal checks happen concurrently, minimizing wait time. - Predictability: The logic for "High Risk" vs "Low Risk" should be deterministic (Structured Routing) to ensure every contract follows the exact legal procedure.
- Performance: Using parallel edges and a
Scenario 2: The Multi-Turn Story Writer
Recommended Pattern: Cyclic Workflow (Module 20)
-
Design:
START->refinement_orchestrator— a single@node(rerun_on_resume=True)function. TheWorkflow'sedgesare simply[("START", refinement_orchestrator)]; there is no edge that loops back to a previous node.- Inside
refinement_orchestrator, a plain Pythonforloop repeatedly callsctx.run_node(critic, current_story)and, unless the critic responds "APPROVED", callsctx.run_node(refiner, ...)to produce the next draft. - The loop breaks as soon as the critic returns "APPROVED" (or a
max_iterationscap is reached), and the function returns the final story.
-
Justification:
- Iteration: This scenario requires a feedback loop. Rather than modeling the cycle as a graph edge that returns to a previous node, ADK 2.0 implements it with standard Python control flow (
for/while) inside one orchestrator node, callingctx.run_node()oncritic/refinerfor each pass -- simpler to reason about and debug than a literal cyclic graph.
- Iteration: This scenario requires a feedback loop. Rather than modeling the cycle as a graph edge that returns to a previous node, ADK 2.0 implements it with standard Python control flow (
Scenario 3: The Global Enterprise Support Bot
Recommended Pattern: Distributed Graphs (A2A - Module 21)
-
Design:
START->WebOrchestratorWebOrchestrator->RemoteA2aAgent(EU Logistics)
-
Justification:
- Security & Ownership: Since the EU agent is in a different project and managed by a different team, the A2A protocol is mandatory. It allows the main bot to delegate tasks securely over the network without needing access to the EU agent's source code or private project resources.
Self-Reflection Answers
- Hybrid Approach: Real systems often start with a static business process (Static) but then encounter "messy" data that needs Python logic (Dynamic) or external expertise (Distributed). Hybrid designs offer the best balance of control and flexibility.
- Collaborative Team Risks: In a regulated environment, "Collaborative" agents might deviate from a strict protocol or lose the "Chain of Custody." For financial/legal tasks, Static/Structured graphs are preferred for auditability.
- Graph Mental Model: Business leaders understand flowcharts and process maps. Explaining an AI system as a "Graph of Nodes" makes the ROI and process logic much clearer than just saying "it's an intelligent chat."