Master deterministic workflow patterns including sequential, parallel, conditional, and looping execution for reliable multi-agent automation.
Component | Purpose |
---|---|
Step | Basic execution unit |
Agent | AI assistant with specific role |
Team | Coordinated group of agents |
Function | Custom Python logic |
Parallel | Concurrent execution |
Condition | Conditional execution |
Loop | Iterative execution |
Router | Dynamic routing |
StepInput
and StepOutput
provides standardized interfaces for data flow between steps:
So if you make a custom function as an executor for a step, make sure that the input and output types are compatible with the StepInput
and StepOutput
interfaces.
This will ensure that your custom function can seamlessly integrate into the workflow system.Take a look at the schemas for StepInput
and StepOutput
.StepInput
object.
Parameter | Type | Default | Description |
---|---|---|---|
name | Optional[str] | None | Name of the step for identification |
agent | Optional[Agent] | None | Agent to execute for this step |
team | Optional[Team] | None | Team to execute for this step |
executor | Optional[StepExecutor] | None | Custom function to execute for this step |
step_id | Optional[str] | None | Unique identifier for the step (auto-generated if not provided) |
description | Optional[str] | None | Description of the step's purpose |
max_retries | int | 3 | Maximum number of retry attempts on failure |
timeout_seconds | Optional[int] | None | Timeout for step execution in seconds |
skip_on_failure | bool | False | Whether to skip this step if it fails after all retries |
Parameter | Type | Default | Description |
---|---|---|---|
evaluator | Union[Callable[[StepInput], bool], Callable[[StepInput], Awaitable[bool]], bool] | Required | Function or boolean to evaluate the condition |
steps | WorkflowSteps | Required | Steps to execute if the condition is met |
name | Optional[str] | None | Name of the condition step |
description | Optional[str] | None | Description of the condition step |
Parameter | Type | Default | Description |
---|---|---|---|
*steps | *WorkflowSteps | Required | Variable number of steps to execute in parallel |
name | Optional[str] | None | Name of the parallel execution block |
description | Optional[str] | None | Description of the parallel execution |
Parameter | Type | Default | Description |
---|---|---|---|
steps | WorkflowSteps | Required | Steps to execute in each loop iteration |
name | Optional[str] | None | Name of the loop step |
description | Optional[str] | None | Description of the loop step |
max_iterations | int | 3 | Maximum number of iterations for the loop |
end_condition | Optional[Union[Callable[[List[StepOutput]], bool], Callable[[List[StepOutput]], Awaitable[bool]]]] | None | Function to evaluate if the loop should end |
Parameter | Type | Default | Description |
---|---|---|---|
selector | Union[Callable[[StepInput], Union[WorkflowSteps, List[WorkflowSteps]]], Callable[[StepInput], Awaitable[Union[WorkflowSteps, List[WorkflowSteps]]]]] | Required | Function to select steps dynamically (supports both sync and async functions) |
choices | WorkflowSteps | Required | Available steps for selection |
name | Optional[str] | None | Name of the router step |
description | Optional[str] | None | Description of the router step |
Parameter | Type | Default | Description |
---|---|---|---|
name | Optional[str] | None | Name of the steps group for identification |
description | Optional[str] | None | Description of the steps group's purpose |
steps | Optional[List[Any]] | [] | List of steps to execute sequentially (empty list if not provided) |
Steps
really shines - creating distinct sequences for different content types or workflows:
workflow_using_steps.py
workflow_using_steps_nested.py
selector_for_image_video_generation_pipelines.py