Parallel Agents
Run multiple agents simultaneously for faster processing
The ParallelAgent
The ParallelAgent
executes sub‑agents concurrently, allowing independent tasks to run simultaneously for improved performance. Use it when tasks are truly independent and do not depend on intermediate results from each other. Orchestration is deterministic; sub‑agents can be any type, including LlmAgent
.
Visual
Quick Example
Here's how to create a research workflow that runs three specialized agents in parallel:
import { LlmAgent, ParallelAgent } from "@iqai/adk";
// Create three specialized research agents
const webAgent = new LlmAgent({
name: "web_researcher",
description: "Web research",
model: "gemini-2.5-flash",
instruction: "Search the web for current information",
// tools: [new GoogleSearchTool()],
outputKey: "web_result",
});
const wikiAgent = new LlmAgent({
name: "wiki_researcher",
description: "Wikipedia research",
model: "gemini-2.5-flash",
instruction: "Find comprehensive background information",
// tools: [new WikipediaTool()],
outputKey: "wiki_result",
});
const newsAgent = new LlmAgent({
name: "news_researcher",
description: "News research",
model: "gemini-2.5-flash",
instruction: "Find latest news and developments",
// tools: [new NewsTool()],
outputKey: "news_result",
});
// Create parallel coordinator that runs all three simultaneously
const researchCoordinator = new ParallelAgent({
name: "research_coordinator",
description: "Coordinates parallel research",
subAgents: [webAgent, wikiAgent, newsAgent],
});
How it Works
When a ParallelAgent
runs:
- Concurrent execution: Starts each sub‑agent concurrently
- Isolated branches: Each child runs in its own branch; events interleave in time
- Result collection: Results are available via events/state; ordering is not deterministic
Independent execution and state
Sub‑agents run independently. If you need coordination:
- Use shared session state with unique keys and design for concurrent writes
- Aggregate results in a follow‑up step (for example, a
SequentialAgent
after the parallel step)
Visual
Key Benefits
- Speed: Independent tasks run concurrently instead of sequentially
- Efficiency: Better resource utilization for unrelated work
- Scalability: Handle multiple data sources or perspectives simultaneously
When to Use
Independence Required
Use parallel agents only when tasks are truly independent and don't need to share results during execution.
Ideal for:
- Multi-source research (web, news, academic papers)
- Content analysis (fact-checking + grammar + style review)
- Data validation across different systems
- Getting multiple expert perspectives
Avoid when:
- Tasks depend on each other's results
- Sequential processing is required
- Resource constraints limit concurrent execution
Related Topics
How is this guide?