You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/README.md
+11-8Lines changed: 11 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,19 +46,22 @@ These are more advanced examples, most of them involve some sort of MCP server t
46
46
47
47
## **Workflow Configurations**
48
48
49
-
These examples demonstrate sequential workflow execution where multiple agents are chained together. Each agent processes the output from the previous agent, creating a pipeline of transformations. Workflows don't require a root agent - they execute agents in the order defined in the workflow section.
49
+
These examples demonstrate workflow execution where multiple agents are chained together in sequential or parallel patterns. Workflows support both sequential execution (one agent after another) and parallel execution (multiple agents running concurrently). Workflows don't require a root agent - they execute agents in the order defined in the workflow section.
50
50
51
51
See [WORKFLOW_README.md](WORKFLOW_README.md) for detailed documentation.
52
52
53
-
| Name | Description/Purpose | Steps | Models Used |
Copy file name to clipboardExpand all lines: examples/WORKFLOW_README.md
+103-9Lines changed: 103 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
-
# Sequential Workflow Execution
1
+
# Workflow Execution
2
2
3
-
This directory contains examples of sequential workflow execution in cagent. Workflows allow you to chain multiple agents together, where each agent processes the output from the previous agent.
3
+
This directory contains examples of workflow execution in cagent. Workflows allow you to chain multiple agents together in sequential or parallel execution patterns, where agents process and transform data through a defined pipeline.
4
4
5
5
## Examples
6
6
@@ -39,14 +39,54 @@ The `joke_workflow.yaml` demonstrates a simple two-step comedy workflow:
39
39
./bin/cagent run examples/joke_workflow.yaml
40
40
```
41
41
42
+
### Parallel Translation Workflow
43
+
44
+
The `parallel_translation_workflow.yaml` demonstrates parallel execution where multiple agents process the same input concurrently:
45
+
46
+
1.**source_text** - Generates a technical explanation of Docker containers
47
+
2.**Parallel Step** - Three translation agents run simultaneously:
48
+
-**translate_spanish** - Translates to Spanish
49
+
-**translate_french** - Translates to French
50
+
-**translate_japanese** - Translates to Japanese
51
+
3.**formatter** - Combines all translations into a formatted output
52
+
53
+
```bash
54
+
./bin/cagent run examples/parallel_translation_workflow.yaml
55
+
```
56
+
57
+
### Parallel Sorting Workflow
58
+
59
+
The `parallel_sorting_workflow.yaml` shows parallel processing with compute-intensive tasks:
60
+
61
+
1.**generate_array** - Creates a random array of 100 integers
62
+
2.**Parallel Step** - Four sorting agents run concurrently:
63
+
-**bubble_sort** - Sorts using Bubble Sort
64
+
-**insertion_sort** - Sorts using Insertion Sort
65
+
-**merge_sort** - Sorts using Merge Sort
66
+
-**quicksort** - Sorts using QuickSort
67
+
3.**analyzer** - Compares and analyzes all sorting results
68
+
69
+
```bash
70
+
./bin/cagent run examples/parallel_sorting_workflow.yaml
71
+
```
72
+
42
73
## How It Works
43
74
44
75
The `run` command automatically detects workflows by checking if the configuration file contains a `workflow` section. No special command is needed!
45
76
77
+
### Execution Patterns
78
+
79
+
Workflows support two execution patterns:
80
+
81
+
1.**Sequential (`type: agent`)** - Agents run one after another, each receiving the previous agent's output
82
+
2.**Parallel (`type: parallel`)** - Multiple agents run concurrently, all receiving the same input, with outputs combined for the next step
83
+
46
84
## Workflow Configuration
47
85
48
86
### Basic Structure
49
87
88
+
#### Sequential Workflow
89
+
50
90
```yaml
51
91
version: "2"
52
92
@@ -63,14 +103,51 @@ workflow:
63
103
name: next_agent
64
104
```
65
105
106
+
#### Parallel Workflow
107
+
108
+
```yaml
109
+
version: "2"
110
+
111
+
agents:
112
+
generator:
113
+
model: openai/gpt-4o
114
+
instruction: Generate initial data
115
+
116
+
processor1:
117
+
model: openai/gpt-4o
118
+
instruction: Process data using method 1
119
+
120
+
processor2:
121
+
model: openai/gpt-4o
122
+
instruction: Process data using method 2
123
+
124
+
combiner:
125
+
model: openai/gpt-4o
126
+
instruction: Combine and analyze results
127
+
128
+
workflow:
129
+
- type: agent
130
+
name: generator
131
+
- type: parallel
132
+
steps:
133
+
- processor1
134
+
- processor2
135
+
- type: agent
136
+
name: combiner
137
+
```
138
+
66
139
### Key Features
67
140
68
141
1. **Sequential Execution**: Agents run in the order defined in the workflow
69
-
2. **Data Piping**: The output of each agent becomes the input for the next agent
70
-
3. **Automatic Context**: The first agent receives instructions to generate initial content, subsequent agents receive the previous output as input
71
-
4. **No Root Agent Required**: Workflows don't need a "root" agent - just define the agents used in your workflow steps
142
+
2. **Parallel Execution**: Multiple agents process the same input concurrently
143
+
3. **Data Piping**: The output of each step becomes the input for the next step
144
+
4. **Automatic Context**: The first agent receives instructions to generate initial content, subsequent agents receive the previous output as input
145
+
5. **Output Combination**: Parallel step outputs are concatenated in the order specified and passed to the next step
146
+
6. **No Root Agent Required**: Workflows don't need a "root" agent - just define the agents used in your workflow steps
0 commit comments