Workflows, and which shape to use
The three agents in the last three lessons are on their way out. ADK 2.0 added a Workflow, which does the same jobs and more.
Every one of those lessons printed the same warning: deprecated in favour of Workflow, and Workflow cannot yet be used as a sub agent of an LlmAgent. Both halves matter.
A workflow is a graph
from google.adk import Workflow
draft = LlmAgent(
name="draft",
model=PretendModel(replies=[say("dear customer, sorry")]),
instruction="Write a first reply.",
)An ordinary agent, with no output key this time. A workflow passes each node's result to the next one directly.
def shout(node_input):
"""An ordinary function, as a step in the workflow."""
return str(node_input).upper()This is the part the template agents could not do: a plain function as a step. No model is called for it, so it costs nothing.
polish = LlmAgent(
name="polish",
model=PretendModel(replies=[say("Dear customer, we are sorry.")]),
instruction="Fix the tone.",
)
writer = Workflow(name="writer", edges=[("START", draft, shout, polish)])One edge, listing what follows what. Instead of nesting agents inside a sequence, you say the route.
await run(writer, "The order was late")Same result as the sequence in lesson 17, with a function in the middle that no model had to be asked about.
- Functions are first class nodes. No wrapping string handling in an agent.
- Routing is explicit. Edges say what follows what, including branches.
- Fewer model calls. A deterministic step costs nothing at all.
ADK also offers dynamic workflows, where the control flow is ordinary Python with loops and conditions, and collaborative workflows, where one agent coordinates others.
The catch, said plainly
A Workflow cannot yet be a sub agent of an LlmAgent. So if your design is an agent that hands work to a fixed sequence, the deprecated SequentialAgent is still what does that today. That is why this course teaches both.
ADK also offers dynamic workflows, where you write the control flow as ordinary Python with loops and conditions, and collaborative workflows, where one agent coordinates others. Those are the two ends of the same idea: as much or as little structure as the job needs.
The catch, said plainly
A Workflow cannot yet be used as a sub agent of an LlmAgent. So if your design is an agent that hands work to a fixed sequence, the deprecated SequentialAgent is still the thing that does that today. That is why this course teaches both, and why the last three lessons were not a waste of your time.
Which shape to use
| Shape | Who decides the order | Use when |
|---|---|---|
One LlmAgent with tools | The model, per turn | The job is a model choosing tools in a loop |
| Sub agents and transfer | The model, once | Different kinds of problem, different specialists |
Workflow | You, as a graph | The steps are fixed, and some of them are plain code |
SequentialAgent and friends | You | The same, when it has to sit under an LlmAgent |
| A custom agent | You, in Python | Control flow none of the above can express |
The first two are model-driven and flexible. The rest are code-driven and predictable. Prefer the predictable one wherever the order is genuinely fixed, and prefer a workflow over the template agents in new code.
A worked decision
- Answering order questions: one
LlmAgentwith tools. The model decides which lookup to run. - Billing: a sub agent with a transfer. Different problem, different tools.
- The monthly summary: a workflow. Gather, count, write, with the counting as a function rather than an agent.
SequentialAgent and its two siblings everywhere. That code still runs. Knowing it is deprecated, and why it is still needed under an LlmAgent, is the thing those tutorials cannot tell you.- Rewrite the sequence from lesson 17 as a workflow and delete the polish agent's template.
- Put a function node between two agents that does something a model should never be asked to do, like arithmetic.
Every expert started right here.