Confirmation Required Stream
Team HITL Streaming: Member agent tool requiring confirmation.
"""Team HITL Streaming: Member agent tool requiring confirmation.
This example demonstrates how a team pauses when a member agent's tool
requires human confirmation in streaming mode. After confirmation the team
resumes with continue_run().
Note: When streaming with member agents, use isinstance() with TeamRunPausedEvent
to distinguish the team's pause from member agent pauses.
"""
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.run.team import RunPausedEvent as TeamRunPausedEvent
from agno.team.team import Team
from agno.tools import tool
from agno.utils import pprint
# Database is required for continue_run to work - it stores the paused run
# ---------------------------------------------------------------------------
# Setup
# ---------------------------------------------------------------------------
db = SqliteDb(db_file="tmp/team_hitl_stream.db")
# ---------------------------------------------------------------------------
# Tools
# ---------------------------------------------------------------------------
@tool(requires_confirmation=True)
def deploy_to_production(app_name: str, version: str) -> str:
"""Deploy an application to production.
Args:
app_name (str): Name of the application
version (str): Version to deploy
"""
return f"Successfully deployed {app_name} v{version} to production"
# ---------------------------------------------------------------------------
# Create Members
# ---------------------------------------------------------------------------
deploy_agent = Agent(
name="Deploy Agent",
role="Handles deployments to production",
model=OpenAIResponses(id="gpt-5-mini"),
tools=[deploy_to_production],
db=db,
)
# ---------------------------------------------------------------------------
# Create Team
# ---------------------------------------------------------------------------
team = Team(
name="DevOps Team",
members=[deploy_agent],
model=OpenAIResponses(id="gpt-5-mini"),
db=db,
)
# ---------------------------------------------------------------------------
# Run Team
# ---------------------------------------------------------------------------
if __name__ == "__main__":
for run_event in team.run(
"Deploy the payments app version 2.1 to production", stream=True
):
# Use isinstance to check for team's pause event (not the member agent's)
if isinstance(run_event, TeamRunPausedEvent):
print("Team paused - requires confirmation")
for req in run_event.active_requirements:
if req.needs_confirmation:
print(f" Tool: {req.tool_execution.tool_name}")
print(f" Args: {req.tool_execution.tool_args}")
req.confirm()
response = team.continue_run(
run_id=run_event.run_id,
session_id=run_event.session_id,
requirements=run_event.requirements,
stream=True,
)
pprint.pprint_run_response(response)Example behavior
The deployment tool is a demonstration stub that returns a success string. The caller automatically calls req.confirm() for every confirmation requirement; replace that line with an actual approval decision before connecting a deployment service. A new tool call can pause the resumed run again; see Multi-Round User Input for a loop that handles repeated pauses.
Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno openai sqlalchemyExport your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"Run the example
Save the code above as confirmation_required_stream.py, then run:
python confirmation_required_stream.pyFull source: cookbook/03_teams/20_human_in_the_loop/confirmation_required_stream.py