The constructor initializes the `SequentialWorkflow` object.
The constructor initializes the `SequentialWorkflow` object. Agents can be provided during initialization or the workflow can be initialized empty and configured later.
- **Parameters:**
- `id` (`str`, optional): Unique identifier for the workflow. Defaults to `"sequential_workflow"`.
- `name` (`str`, optional): Name of the workflow. Defaults to `"SequentialWorkflow"`.
- `description` (`str`, optional): Description of the workflow. Defaults to a standard description.
- `agents` (`List[Union[Agent, Callable]]`, optional): The list of agents or callables to execute in sequence.
- `agents` (`List[Union[Agent, Callable]]`, optional): The list of agents or callables to execute in sequence. Can be `None` during initialization but must be set before calling any run methods. Defaults to `None`.
- `max_loops` (`int`, optional): The maximum number of loops to execute the workflow. Defaults to `1`.
- `output_type` (`OutputType`, optional): Output format for the workflow. Defaults to `"dict"`.
- `shared_memory_system` (`callable`, optional): Callable for shared memory management. Defaults to `None`.
@ -56,6 +56,8 @@ The constructor initializes the `SequentialWorkflow` object.
- `*args`: Variable length argument list.
- `**kwargs`: Arbitrary keyword arguments.
- **Note:** When initialized without agents, the workflow's `agent_rearrange` attribute will be `None` and `flow` will be an empty string. You must provide agents before running the workflow.
**Note**: When initialized without agents, `agent_rearrange` will be `None` and `flow` will be an empty string. You must provide agents before calling any execution methods.
## Logging and Error Handling
The `run` method includes comprehensive logging to track workflow execution:
@ -325,6 +362,19 @@ The `run` method includes comprehensive logging to track workflow execution:
2023-05-08 10:30:15.456 | INFO | Sequential Workflow Name: SequentialWorkflow is ready to run.
```
### Error Handling
All execution methods (`run`, `run_batched`, `run_async`, `run_concurrent`) validate that agents are configured before execution:
```python
workflow = SequentialWorkflow() # No agents
try:
workflow.run("Some task")
except ValueError as e:
print(e) # "Agents list cannot be None or empty. Add agents before running the workflow."
```
All errors during execution are logged and re-raised for proper error handling.