ADK 2.0: Graphs, Collab Modes, Dynamic Flows Fix Agent Pains
Google's ADK 2.0 shifts agent logic from unreliable LLM prompts to code-defined graphs, singleton/task sub-agent modes, and async Python workflows with auto-checkpointing and human-in-loop for deterministic, resumable multi-agent systems.
Graph-Based Workflows Make Routing Deterministic
Move complex routing logic from bloated LLM prompts to code-defined graphs with nodes (agents, tools, functions, human input) and edges. In ADK 1.0, a support router relied on a single agent with massive instructions like "classify then call handler, never skip," leading to failures like skipped classification or wrong handlers as prompts grew. ADK 2.0 fixes this: define the graph explicitly in code, e.g., start → classifier agent → router → branches to bug/billing/feature handlers. The LLM only classifies (short prompt: "return category in uppercase: BUG, BILLING, or FEATURE_REQUEST"), while code handles deterministic routing, parallel execution, and nesting. Demo: Support agent processes "500 errors on analytics page" via bug handler, "Pro Plan cost" via billing, "add dark mode" via feature—traces show exact graph path, no LLM flakiness.
Collaborative Modes Automate Sub-Agent Handoffs
Control sub-agent behavior with modes under a coordinator: singleton runs once and auto-returns results; task allows clarifying questions then auto-returns on completion. ADK 1.0 made handoffs manual and error-prone. Now, coordinators delegate cleanly: e.g., travel planner coordinator lists sub-agents (weather_checker mode=singleton, flight_booker mode=task) with instructions like "delegate weather to weather_checker, flights to flight_booker." Demo: "Weather in Paris today?" → singleton weather_checker responds, control returns. "Book SFO to CDG" → task flight_booker asks "exact date?" (user: April 28th), completes, returns. Complex: "Weather and flight to Paris" → uses both, asks date, books—coordinator stays in control without manual intervention.
Dynamic Workflows Add Human-in-Loop Resilience
Build async Python workflows with @node decorator (turns functions into steps with if/else logic), request_input (pauses for human response), and ctx.resume_data (resumes from checkpoint). Ideal for enterprise: auto-approve <$100 refunds, human-approve >$100. Demo: Refund agent for $50 → auto-approves/processes. For $350 → decides >$100, requests input ("Approve?"), user says yes → resumes via ctx.resume_data, approves. Enables durable, resumable flows for approvals, compliance, fraud—AI decides but humans gatekeep high-stakes calls.