> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-service-account.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Nested Workflow - Auto-Wrap (Passing Workflow Directly)

> Demonstrates passing a Workflow directly in the steps list without wrapping it in a Step().

Demonstrates passing a Workflow directly in the steps list without wrapping it in a Step(). The outer workflow auto-wraps it, using the inner workflow's name as the step name.

```python nested_workflow_pass_direct_workflow.py theme={null}
"""
Nested Workflow - Auto-Wrap (Passing Workflow Directly)

Demonstrates passing a Workflow directly in the steps list without
wrapping it in a Step(). The outer workflow auto-wraps it, using the
inner workflow's name as the step name.

Both approaches are equivalent:
    # Explicit (recommended for clarity)
    steps=[Step(name="research_phase", workflow=inner_workflow)]

    # Auto-wrap (concise shorthand)
    steps=[inner_workflow]
"""

from agno.agent import Agent
from agno.models.openai import OpenAIResponses
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=OpenAIResponses(id="gpt-5.4"),
    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=OpenAIResponses(id="gpt-5.4"),
    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

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno fastapi openai
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run the example">
    Save the code above as `nested_workflow_pass_direct_workflow.py`, then run:

    ```bash theme={null}
    python nested_workflow_pass_direct_workflow.py
    ```
  </Step>
</Steps>

Full source: [cookbook/04\_workflows/06\_advanced\_concepts/workflow\_as\_a\_step/nested\_workflow\_pass\_direct\_workflow.py](https://github.com/agno-agi/agno/blob/main/cookbook/04_workflows/06_advanced_concepts/workflow_as_a_step/nested_workflow_pass_direct_workflow.py)
