Workflow as a step inside another Workflow. The inner workflow runs as a single step in the outer workflow, with output chained to the next step.
Basic Example
nested_workflow.py
inner_workflow as its first step. The inner workflow’s output flows into the writing_phase step.
How It Works
- The outer workflow reaches a step with
workflow=inner_workflow - The inner workflow’s
.run()executes with the prepared input (chained from the previous step) - Session state is deep-copied into the inner workflow and merged back after execution
- The inner workflow’s output is converted to a
StepOutputwithstep_type=StepType.WORKFLOW - Execution continues to the next step in the outer workflow
Two Ways to Declare
auto_wrap.py
Inner workflows and primitives
An inner workflow can use the same primitives and combinations as any top-level workflow in Agno: agents, executors, nestedSteps, Condition, Loop, Router, and Parallel, mixed however your pipeline needs.
The basic example uses agent and executor steps inside the inner workflow. Deep nesting shows multiple levels with Parallel and sub-workflows.
Deep Nesting
Workflows can be nested multiple levels deep. Each level runs its own sub-workflows independently.deeply_nested.py
Streaming Events
When streaming, inner workflow events bubble up with anested_depth field. Use this to distinguish inner vs. outer events.
event_inspection.py
Developer Resources
- Nested workflow example
- Auto-wrap example
- Event inspection example
- With Condition
- With Loop
- With Router
- Deep nesting (3 levels)