Building Workflows
Define steps, loops, conditions, and parallel execution in workflows.
Workflows orchestrate your agents and teams as a series of steps executed in a flow that you control.
Building Blocks
Workflowmanages the run and executes its configured steps.Stepwraps exactly one executor: anAgent, aTeam, a custom Python function, or a nestedWorkflow.Stepsgroups steps into a named sequential unit.Looprepeats one or more steps until an end condition succeeds or the iteration cap is reached.Parallelruns independent steps concurrently and aggregates their outputs.Conditionruns its steps when a boolean evaluator passes and an optional else branch when it fails.Routerpicks which step or steps run next from its choices.
When using a custom Python function as an executor for a step, StepInput and
StepOutput provide standard interfaces for data flow between steps.
Your First Workflow
You can mix agents, teams, and functions as steps in the same workflow:
from agno.agent import Agent
from agno.team import Team
from agno.workflow import StepInput, StepOutput, Workflow
research_team = Team(
name="Research Team",
members=[
Agent(
name="Researcher",
instructions="Research the requested market and list the main competitors.",
)
],
)
content_agent = Agent(
name="Writer",
instructions="Turn the supplied research into a concise competitive analysis.",
)
def data_preprocessor(step_input: StepInput) -> StepOutput:
research = step_input.previous_step_content or "No research was returned."
return StepOutput(content=f"Research to analyze:\n{research}")
workflow = Workflow(
name="Mixed Execution Pipeline",
steps=[
research_team,
data_preprocessor,
content_agent,
],
)
workflow.print_response(
"Analyze the competitive landscape for fintech startups",
markdown=True,
)Install
uv pip install -U agno openaiSet OpenAI Key
Set your OPENAI_API_KEY as an environment variable. You can get one from OpenAI.
export OPENAI_API_KEY=sk-***Next Steps
| Task | Guide |
|---|---|
| Execute a workflow and process events | Running Workflows |
| Choose a control-flow primitive | Workflow Patterns |
| Implement a function executor | Custom Functions in Workflows |