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

# Team Human in the Loop

> Demonstrates team with member tool requiring confirmation.

```python team_human_in_the_loop.py theme={null}
"""
Team Human in the Loop
======================

Demonstrates team with member tool requiring confirmation.
"""

from agno.agent.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.os import AgentOS
from agno.os.interfaces.agui import AGUI
from agno.team import Team
from agno.tools import tool

# ---------------------------------------------------------------------------
# Create Example
# ---------------------------------------------------------------------------

db = SqliteDb(db_file="/tmp/agui_team_hitl.db")


@tool(requires_confirmation=True)
def send_email(to: str, subject: str, body: str) -> str:
    """Send an email."""
    return f"Email sent to {to} with subject '{subject}'."


researcher = Agent(
    name="Researcher",
    model=OpenAIResponses(id="gpt-5.5"),
    db=db,
    instructions="Answer factual questions concisely. You do not send emails.",
    markdown=True,
)

emailer = Agent(
    name="Emailer",
    model=OpenAIResponses(id="gpt-5.5"),
    db=db,
    tools=[send_email],
    instructions=(
        "You send emails. Call send_email with the recipient, a subject, and a body; "
        "if the user did not give a subject or body, draft a reasonable one. "
        "After a confirmed send, briefly say the email was sent. "
        "If the user declines, do not resend; acknowledge it was cancelled."
    ),
    markdown=True,
)

support_team = Team(
    name="support_team",
    model=OpenAIResponses(id="gpt-5.5"),
    members=[researcher, emailer],
    db=db,
    instructions="Route email requests to the Emailer and factual questions to the Researcher.",
    add_history_to_context=True,
    markdown=True,
)

agent_os = AgentOS(
    teams=[support_team],
    interfaces=[AGUI(team=support_team, prefix="/team_human_in_the_loop")],
)
app = agent_os.get_app()


# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    agent_os.serve(app="team_human_in_the_loop:app", port=9001, reload=True)
```

## Run the Example

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

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

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

Full source: [cookbook/05\_agent\_os/interfaces/agui/team\_human\_in\_the\_loop.py](https://github.com/agno-agi/agno/blob/v2.7.4/cookbook/05_agent_os/interfaces/agui/team_human_in_the_loop.py)
