Overview
The Chain workflow executes agents in a defined sequence, where the output of each agent becomes the input to the next. This pattern is ideal for multi-step processes where each stage builds on the results of the previous one.Chain workflows support both simple sequential processing and cumulative modes where agents can see all previous responses.
Key Features
- Sequential Execution: Agents run one after another in a defined order
- Output Passing: Each agent’s output becomes the next agent’s input
- Cumulative Mode: Optional mode where agents see all previous responses
- Flexible Composition: Chains can include other workflow types
- Interactive Continuation: Chat with the final agent after chain execution
Basic Usage
Configuration Parameters
Name of the chain workflow
List of agent names in execution order
Description of the chain for other workflows
Whether each agent sees all previous responses
Open chat with final agent after chain execution
Cumulative Mode
In cumulative mode, each agent receives:- The original user request
- All previous agent responses
Command Line Usage
Run a chain from the command line:--quiet to return only the final response:
How It Works
- Initial Request: The user message is sent to the first agent
- Sequential Processing: Each agent processes its input and generates output
- Output Forwarding: The output becomes input for the next agent
- Final Response: The last agent’s response is returned
Non-Cumulative Flow
Cumulative Flow
Advanced Examples
Multi-Stage Content Pipeline
Cumulative Analysis Chain
Best Practices
Clear Boundaries
Define clear responsibilities for each agent in the sequence
Output Format
Ensure each agent’s output is suitable input for the next
Chain Length
Keep chains reasonably short (3-5 agents) for maintainability
Error Handling
Consider what happens if an agent fails mid-chain
Use Cases
- Content Creation: Research → Write → Edit → Publish
- Data Processing: Extract → Transform → Analyze → Report
- Multi-step Tasks: Fetch → Summarize → Translate → Format
- Quality Assurance: Generate → Review → Revise → Approve
Interactive Mode
After chain execution, you can continue chatting with the final agent:@agent-name in interactive mode.
Related Patterns
- Parallel - Run agents concurrently instead of sequentially
- Evaluator-Optimizer - Iterative refinement with feedback
- Orchestrator - Dynamic task decomposition and execution
