Sequential Agents
Execute agents one after another in a specific order
Sequential agents create powerful pipelines where agents execute in a specific order, with each step building on the results of the previous one. Think assembly line for AI - each agent specializes in one part of the process, and the final result is the combined output of all steps working together.
Perfect for workflows where order matters: research before analysis, writing before editing, data collection before processing. Unlike parallel agents that run simultaneously, sequential agents guarantee execution order and enable sophisticated multi-step reasoning.
When Order Matters
Use sequential agents when each step depends on the previous one's output. The magic happens when agents pass enriched context down the pipeline, creating more sophisticated results than any single agent could achieve.
Quick Start Example
Here's a market research pipeline that transforms a simple query into comprehensive business intelligence:
import { LlmAgent, SequentialAgent, WebSearchTool } from "@iqai/adk";
// Step 1: Gather raw data
const researchAgent = new LlmAgent({
name: "market-researcher",
model: "gemini-2.5-flash",
instruction: `
Research the given company/topic thoroughly. Focus on:
- Current market position and competitors
- Recent news and developments
- Financial performance and growth trends
`,
tools: [new WebSearchTool()],
});
// Step 2: Analyze the collected data
const analysisAgent = new LlmAgent({
name: "business-analyst",
model: "gemini-2.5-flash",
instruction: `
Analyze the research data from the previous step. Identify:
- Key opportunities and threats
- Market trends and patterns
- Competitive advantages and weaknesses
Provide data-driven insights with specific examples.
`,
});
// Step 3: Create actionable recommendations
const strategistAgent = new LlmAgent({
name: "business-strategist",
model: "gemini-2.5-flash",
instruction: `
Based on the research and analysis, create strategic recommendations:
- 3-5 specific, actionable strategies
- Risk assessment for each recommendation
- Timeline and resource requirements
Format as an executive summary.
`,
});
// Sequential pipeline: research → analyze → strategize
const marketIntelligencePipeline = new SequentialAgent({
name: "market-intelligence-pipeline",
description: "Comprehensive market analysis and strategy development",
subAgents: [researchAgent, analysisAgent, strategistAgent],
});
// Use the pipeline
const result = await marketIntelligencePipeline.run({
message:
"Analyze Tesla's position in the EV market and suggest growth strategies",
});Visual Flow
How Sequential Processing Works
Sequential agents create a data pipeline where information gets progressively enriched at each step:
🔄 Execution Flow
- Agent 1 receives the original input and processes it
- Agent 2 gets both the original input AND Agent 1's output
- Agent 3 receives original input + Agent 1's output + Agent 2's output
- This continues for each agent in the sequence
💡 Context Accumulation
Each agent sees the full conversation history, so later agents can reference and build upon earlier agents' work. This creates sophisticated reasoning chains that single agents can't achieve.
🎯 Deterministic Order
Execution order is guaranteed - no race conditions or unpredictable results. Perfect for production workflows where consistency matters.
Data Flow Between Agents
Agents automatically share session state, so later agents can reference earlier results. Use descriptive output and clear instructions to help agents understand what information to pass forward.
Real-World Use Cases
📊 Business Intelligence Pipeline
Research → Analysis → Strategic Recommendations → Executive Summary
📝 Content Creation Workflow
Draft → Fact-check → Edit → Style Review → Final Polish
🔍 Technical Documentation
Code Analysis → Documentation Draft → Technical Review → User Testing → Publication
⚖️ Legal Document Review
Initial Review → Compliance Check → Risk Assessment → Final Approval
🧪 Scientific Analysis
Data Collection → Statistical Analysis → Peer Review → Conclusion Generation
When to Choose Sequential Agents
Perfect For Sequential Processing
- Use when: Each step builds on the previous one's output
- Benefit: Creates sophisticated reasoning chains impossible with single agents
✅ Choose Sequential When:
- Dependencies matter - Later steps need earlier results
- Quality control - Each stage validates and improves the work
- Specialization - Different expertise needed at each step
- Compliance - Regulated workflows requiring specific order
- Complex reasoning - Multi-step analysis and decision making
❌ Don't Use Sequential When:
- Tasks are completely independent
- Speed is more important than thoroughness
- You need real-time parallel processing
- Simple, single-step operations
Related Topics
How is this guide?