Agents in a pipeline need a shared bus, and in Google ADK that bus is session state: one agent’s output_key saves its reply into session state, and the next agent reads it back with a template such as {draft}. That is how a drafter hands a draft to a reviewer without re-running the draft step. Name the key for what it holds, such as draft or shortlist, and write it before the next agent runs. A key that is never read is clutter; a result that is never saved is work the next agent must repeat.
What you need
- Two ADK agents that run in order: a producer and a consumer
- A named state key for the result, for example draft
- A test input with a known correct first-stage result
Step 1: Set the output key on the producer agent
Give the producer agent an output_key naming the state key its reply should be saved under. Keep the name short and descriptive of the content.
Step 2: Read the key in the consumer agent
Write the consumer agent’s instruction to read the saved value with the template, such as {draft}, and to work from it. The consumer must not re-run the producer’s step.
Step 3: Run the pair and check the state carried over
Run the pair on the test input and confirm the consumer’s output builds on the producer’s result. If the consumer repeats the producer’s work, the key was not saved or not read.
Worked example: synthetic state handoff
The table below is a synthetic example. It shows the expected result of the state handoff; no agent was run.
| Check | Expected | Result |
|---|---|---|
| Producer saves under draft | Yes | Pass |
| Consumer reads {draft} | Yes | Pass |
| Consumer repeats producer work | No | Pass |
| Final answer builds on draft | Yes | Pass |
Expected result (UNTESTED). the draft is saved under its key, the reviewer reads it, and the final answer builds on it without repeated work. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- State is the shared bus between stages, so a key name that is vague will be misread later.
- Session state persists across turns, so an old value under the same key can leak into a new task.
- The consumer can only read what the producer actually saved, so check the saved value, not just the final answer.
- A key saved by one agent and read by none is clutter; remove unused keys.
