Skip to main content

Documentation Index

Fetch the complete documentation index at: https://agno-v2-team-approvals.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.workflow.step import Step
from agno.workflow.types import StepInput, StepOutput
from agno.workflow.workflow import Workflow


def summarize(step_input: StepInput) -> StepOutput:
    prev = step_input.previous_step_content or ""
    return StepOutput(content=f"Summary: {prev[:200]}")


# Inner workflow
researcher = Agent(
    name="Researcher",
    model=OpenAIChat(id="gpt-4o-mini"),
    instructions="You are a research assistant. Be concise (2-3 sentences).",
)

inner_workflow = Workflow(
    name="Research Workflow",
    description="Researches a topic and summarizes",
    steps=[
        Step(name="research", agent=researcher),
        Step(name="summarize", executor=summarize),
    ],
)

# Outer workflow: pass inner_workflow directly (no Step wrapper)
writer = Agent(
    name="Writer",
    model=OpenAIChat(id="gpt-4o-mini"),
    instructions="Write a polished paragraph from the research provided.",
)

outer_workflow = Workflow(
    name="Auto-Wrap Example",
    description="Inner workflow passed directly in steps list",
    steps=[
        inner_workflow,  # Auto-wrapped into Step(name="Research Workflow", workflow=inner_workflow)
        Step(name="write", agent=writer),
    ],
)


if __name__ == "__main__":
    outer_workflow.print_response(
        input="What are the benefits of open source software?",
        stream=True,
    )

Run the Example

git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/04_workflows/06_advanced_concepts/workflow_as_a_step

pip install agno openai

python nested_workflow_pass_direct_workflow.py