07. Frameworks & Libraries
Google ADK (Sequential, Parallel and Workflow Agents)
Google ADK (Agent Development Kit) builds multi-step agents with LLM workers plus deterministic workflow control: SequentialAgent runs sub-agents in fixed order, ParallelAgent runs independent branches concurrently, and graph workflows (nodes, edges, JoinNode) give precise fan-out/join routing. The model reasons inside steps; the workflow decides who runs when.
What you will learn
- Contrast LLM agents with deterministic workflow agents
- Design SequentialAgent and ParallelAgent pipelines
- Explain shared session state and output_key handoffs
- Sketch a graph fan-out / JoinNode workflow
- Answer interview questions with short, solid answers
Definition
Google’s Agent Development Kit (ADK) is a multi-language toolkit (Python, TypeScript, Go, and more) for composing agents. You combine LLM agents (instructions, tools, model reasoning) with workflow agents that orchestrate sub-agents deterministically — order and concurrency are code-defined, not left to the model.
Template workflow agents include SequentialAgent and ParallelAgent (plus Loop patterns). ADK also supports graph-based workflows with explicit nodes and edges for finer routing — the direction ADK 2.0 emphasizes for precise control.
Introduction
This lesson (#9 in Frameworks & Libraries) follows OpenAI Agents SDK. You saw handoffs and guardrails; ADK emphasizes deterministic sequential/parallel composition and graph workflows.
Next: Other Frameworks (LlamaIndex, Semantic Kernel, Haystack, PydanticAI, Mastra) — a survey of adjacent stacks.
Why Google ADK
- Clear split between reasoning agents and control-flow agents
- Sequential/parallel templates for common pipelines
- Shared session state for passing artifacts between steps
- Graph workflows for branching, fan-out/join, and code nodes
- Fits Google Cloud / Gemini-oriented agent builds
LLM agents vs workflow agents
LLM agents choose tools and wording. Workflow agents do not “think” about order — they execute a fixed composition of sub-agents.
- LLM agent - model-driven steps inside a role
- SequentialAgent - fixed ordered list of sub-agents
- ParallelAgent - concurrent independent sub-agents
- Loop / iterative templates - repeat until a condition
- Graph workflow - nodes + edges + optional JoinNode
SequentialAgent
SequentialAgent iterates sub_agents in list order and calls each run. All steps share an InvocationContext / session state, so earlier outputs (often via output_key) feed later instructions.
- Classic pipeline: writer → reviewer → refactorer
- Deterministic - not chosen by an LLM supervisor
- Shared state - easy single-turn data passing
- Sub-agents may still use models and tools
- Maps to Module 06 prompt chaining / specialty pipelines
ParallelAgent
ParallelAgent starts sub-agents concurrently. Branches are independent (no automatic shared conversation history between them). Session state is shared — write distinct output_key values, then have a later agent read them. Do not assume one branch can read another mid-flight.
- Use when tasks are independent (multi-source research)
- Event streams interleave - order is not deterministic
- Collect results from session keys, not assumed merge lists
- Follow with a sequential synthesizer if you need one answer
- Maps to Module 06 parallel specialized workers
Graph and workflow agents
Graph workflows define nodes and edges for precise routing: sequential edge lists from START, or multiple START paths that fan out and rejoin via JoinNode. Prefer graphs when templates are too coarse — branching, code-only nodes, and fan-in barriers.
- Sequential route - START then A then B then C
- Fan-out - multiple START paths run in parallel
- JoinNode - barrier that aggregates predecessor outputs
- Dynamic workflows - loops/conditionals in your code when graphs are static
- ADK 2.0 pushes graphs for reliability over prompt-only control
Map to earlier modules
- SequentialAgent ≈ pipeline collaboration / chaining
- ParallelAgent ≈ concurrent workers + merge
- JoinNode ≈ explicit sync barrier after fan-out
- LLM sub-agents ≈ specialized Module 06 roles
- LangGraph is a cousin idea (graphs/state); ADK is Google’s kit
- CrewAI hierarchical ≈ different metaphor (manager) for similar supervision needs
Failure modes
- ParallelAgent with hidden dependencies between branches
- Missing output_key - later steps cannot find prior results
- JoinNode predecessors that finish without output
- Using SequentialAgent when steps are independent (slow for no gain)
- Letting the LLM invent control flow that should be a workflow agent
Program / implementation notes
Start with SequentialAgent for dependent pipelines and ParallelAgent + synthesizer for independent research. Move to graph workflows when you need fan-out/join or non-AI code nodes. Always cap time/cost in your app layer.
- Keep secrets and authZ outside prompts
- Next: Other Frameworks (LlamaIndex, Semantic Kernel, Haystack, PydanticAI, Mastra)
Advantages and limitations
- Advantage: deterministic orchestration separate from LLM judgment
- Advantage: sequential/parallel templates are easy to teach and ship
- Advantage: graphs add precise routing and join semantics
- Limitation: template workflows are coarser than full custom graphs
- Limitation: parallel branches need careful state key design
- Limitation: still need your own auth, evals, and observability
Key points
- ADK separates LLM agents from deterministic workflow control.
- SequentialAgent runs sub-agents in fixed list order with shared state.
- ParallelAgent runs independent branches concurrently.
- Pass data via session state / output_key — not assumed chat merge.
- Graph workflows use nodes, edges, and JoinNode for fan-out/join.
- Model reasons inside steps; workflow decides who runs when.
FAQs
Does SequentialAgent use an LLM to pick the next step?
No. Order is the sub_agents list you defined. Sub-agents may use LLMs, but the sequence is deterministic.
Can ParallelAgent branches share conversation history?
Not automatically. Each branch is independent for events; use shared session state keys to exchange results after writes complete.
When use a graph instead of SequentialAgent?
When you need branching, fan-out/join, code-only nodes, or routing that templates cannot express cleanly.
ADK vs LangGraph?
Both offer graph-style control. ADK is Google’s agent kit with LLM + workflow templates/graphs; LangGraph is LangChain’s durable graph runtime. Pick by ecosystem and ops needs.
Interview questions
- What is a workflow agent in Google ADK?
Answer A deterministic orchestrator that runs sub-agents in a defined pattern (sequential, parallel, loop, or graph) — control flow is code-defined, not model-chosen.
- How does SequentialAgent work?
Answer It iterates sub_agents in list order, calling each run with shared invocation/session state so earlier outputs can feed later steps via keys like output_key.
- When use ParallelAgent?
Answer When sub-tasks are independent and speed matters (e.g., multi-source research). Collect results from distinct state keys, then optionally synthesize sequentially.
- What is JoinNode for?
Answer In graph workflows, JoinNode is a fan-in barrier that waits for all predecessor branches and passes their outputs to the next node.
- How do sequential steps share data?
Answer Through shared session/invocation state — typically writing named keys (output_key) that later agents read in instructions or code.
- Why separate LLM agents from workflow agents?
Answer So reliability of order and concurrency does not depend on prompt luck — models handle judgment; workflows handle structure.
Related topics
Practice task
Complete each numbered practice step in a notebook or doc before opening the next lesson.
- Design a SequentialAgent code pipeline (write → review → refactor) with one output_key per step.
- Design a ParallelAgent with 3 independent researchers and a follow-on synthesizer.
- List 2 reasons those researchers must not depend on each other’s mid-run messages.
- Sketch a graph fan-out of 3 tasks into a JoinNode into a final reporter.
- Answer interview questions 1, 2, and 3 in two sentences each.