> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Human in the Loop: Dojo Demo

> HITL tool: generate_task_steps (requires_confirmation).

```python human_in_the_loop.py theme={null}
"""
Human in the Loop — Dojo Demo
==============================

HITL tool: generate_task_steps (requires_confirmation)

Dojo expects generate_task_steps that returns:
- steps: list of {description: str, status: "enabled"|"disabled"|"executing"}

The frontend renders a step selector UI where user can toggle steps and confirm/reject.
"""

from typing import List

from agno.agent.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools import tool
from pydantic import BaseModel, Field


class TaskStep(BaseModel):
    description: str = Field(description="Description of the step")
    status: str = Field(
        default="enabled", description="Status: enabled, disabled, or executing"
    )


@tool(requires_confirmation=True)
def generate_task_steps(steps: List[TaskStep]) -> str:
    """Generate a list of task steps for the user to review and confirm.

    The frontend will display these steps with checkboxes.
    User can enable/disable steps before confirming execution.
    """
    enabled_steps = [s for s in steps if s.status == "enabled"]
    return f"Executing {len(enabled_steps)} steps: " + ", ".join(
        s.description for s in enabled_steps
    )


hitl_agent = Agent(
    name="human_in_the_loop",
    model=OpenAIResponses(id="gpt-5.5"),
    tools=[generate_task_steps],
    instructions="""You help users plan tasks that require confirmation.

When asked to plan something (trip, recipe, project, etc.):
1. Break it down into clear steps (5-10 steps typically)
2. Use the generate_task_steps tool with a list of steps
3. Each step should have a description and status="enabled"

Example: For "plan a trip to Paris", create steps like:
- Book flights
- Reserve hotel
- Plan activities
- Pack luggage
- etc.

The user will review and confirm which steps to execute.""",
    markdown=True,
)
```

## Run the Example

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

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno 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 `human_in_the_loop.py`, then run:

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

Full source: [cookbook/05\_agent\_os/interfaces/agui/human\_in\_the\_loop.py](https://github.com/agno-agi/agno/blob/main/cookbook/05_agent_os/interfaces/agui/human_in_the_loop.py)
