SequentialWorkflow extends BaseWorkflow to implement the sequential orchestration pattern. A PlanningAgent decomposes the task into steps; each step is then executed by an ExecutionAgent and validated by a MonitoringAgent before the next step begins. Failed steps are retried up to max_retries times before the pipeline aborts.
Import
Constructor
Dictionary of agent instances. Must contain all three of the following keys:
| Key | Expected type |
|---|---|
"planner" | PlanningAgent |
"executor" | ExecutionAgent |
"monitor" | MonitoringAgent |
Optional list of tools. When provided,
tools[0] is used as a context compressor before each step execution. The first tool must expose either an invoke(text) or _run(text) method (e.g. CompressContextTool).Methods
run
Executes the full sequential plan–execute–monitor loop.
The high-level objective. Passed directly to
PlanningAgent.generate_plan().Maximum number of retry attempts per step before the workflow aborts. The step is tried
max_retries + 1 times total.Return value
On success — all steps validated:Indicates the workflow completed without any unrecoverable step failure.
Ordered list of step results.
Indicates the workflow was aborted due to a step that could not be validated.
The step description string that caused the abort.
Results for all steps that completed successfully before the failure.
Context accumulation
After each successful step, its result is appended to a running
context string as "\n[Step N Result]: <result>". This accumulated context is passed to the executor on every subsequent step.If tools is non-empty, tools[0] is invoked to compress the accumulated context before each execution call, keeping prompt size manageable.