Mastering agentic workflows with ADK for Java: Parallel agents
Let’s continue our exploration of ADK for Java (Agent Development Kit for building AI agents). In this series, we’ve explored two fundamental agentic workflows:
- First, we used
LlmAgentwith sub-agents to create a flexible, manager-and-specialists model. - Then, we used the
SequentialAgentto enforce a strict, linear order of operations.
But what if your problem isn’t about flexibility or a fixed sequence? What if it’s about efficiency? Some tasks don’t depend on each other and can be done at the same time. Why wait for one to finish before starting the next?
This is where the ADK for Java offers a third, powerful pattern: the ParallelAgent.
Maximum efficiency with parallel workflows
A parallel workflow is designed to execute multiple agents concurrently. It’s the perfect solution when you need to perform several independent tasks and want to get them done as quickly as possible. The ParallelAgent runs its sub-agents in separate threads, waits for all of them to complete, and then gathers the results.
This is ideal for:
- Comprehensive data gathering: Running different types of searches or analyses on the same topic simultaneously.
- Independent sub-tasks: Performing unrelated actions that can happen in any order.
- Saving time: Drastically reducing the total execution time compared to running the same tasks one after another.
A practical example: the market-researcher
Let’s look at our ParallelFlow.java example, illustrated by the below diagram:
Here’s the full source code, but we’ll explore each part in details further down:
https://gist.github.com/glaforge/da0c39d4e22e8e663ec2a31125f23021
Now let’s zoom in. We’ve built a market-researcher designed to quickly compile a report on a public company. The research involves several distinct tasks that don't depend on each other:
company-profiler: Finds the company's mission, CEO, headquarter, etc.news-finder: Scans for recent news headlines.financial-analyst: Looks up stock performance.
Those agents are taking advantage of the GoogleSearchTool to find up-to-date information, beyond LLM's training cut-off date.
We can run all three of these at the same time. Each agent is configured with an outputKey to store its findings, just like we saw with the SequentialAgent.
var companyProfiler = LlmAgent.builder()
.name("company-profiler")
// ...
.outputKey("profile")
.build();
var newsFinder = LlmAgent.builder()
.name("news-finder")
// ...
.outputKey("news")
.build();
var financialAnalyst = LlmAgent.builder()
.name("financial-analyst")
// ...
.outputKey("financials")
.build();The best of both worlds: a hybrid sequential-parallel flow
Now, here’s where we take our architecture to the next level. We’re composing different flows, by embedding our ParallelAgent inside a SequentialAgent.
This creates a multi-stage pipeline that combines the efficiency of parallel execution with the structured order of a sequence.
Here’s how our hybrid company-detective works. It's a SequentialAgent agent. It will trigger the parallel flow, and once it completes, it will compile the final report from the output of the parallel agents.
The sequential agent combines two steps:
return SequentialAgent.builder()
.name("company-detective")
.description(
"Collects various market information about a company.")
.subAgents(
marketResearcher,
reportCompiler
).build();- Step 1 (in parallel): Sub-agents are collecting information in parallel about the company, the latest news, and its financial status.
var marketResearcher = ParallelAgent.builder()
.name("market-researcher")
.description(
"Performs comprehensive market research on a company.")
.subAgents(
companyProfiler,
newsFinder,
financialAnalyst
)
.build();This agent’s only job is to execute the three research tasks concurrently. Once all three are done, it bundles their outputs (profile, news, financials) and passes them to the next stage in the sequence, thanks to outputKeys.
2. Step 2 (sequentially): A final report-compiler agent runs.
var reportCompiler = LlmAgent.builder()
.name("report-compiler")
.instruction("""
Your role is to synthesize the provided information...
## Company Profile
{profile}
## Latest News
{news}
## Financial Snapshot
{financials}
""")
.build();This agent is a standard step in our SequentialAgent. It takes the collected data from the completed parallel step and formats it into a clean, final report.
By structuring our flow this way, we’ve created a highly modular and extensible pipeline. The parallel research block is a self-contained, reusable component. We could easily add more sequential steps before or after it, like a step to verify the company’s stock ticker first, or a final step to email the report.
Example run
I asked my composite agent: Give me a report about Google. It ran through the various agents, and generated the following report about the company:
Click to read the full report:
https://gist.github.com/glaforge/075c3c645378990afd82336e1a204fea
Choosing the right workflow
Let’s quickly recap the three patterns we’ve covered:
LlmAgentwith sub-agents: Choose this for flexibility. The orchestrator LLM decides the best next step. It's great for conversational bots and user-driven tasks.SequentialAgent: Choose this for order. The process is fixed and predictable. It's perfect for automating linear, multi-step procedures.ParallelAgent: Choose this for efficiency. Independent tasks run concurrently. It's ideal for data gathering and speeding up workflows.
And as we’ve just seen, the true power comes from composing these patterns together to build sophisticated, real-world applications.
In the final article of this series, we’ll explore one more fascinating workflow: the loop flow, designed for tasks that require iteration and self-correction. Stay tuned!
Originally published at https://glaforge.dev on July 25, 2025.

