Async: Confirm Member Agent Tool

Same as confirmation_required.py but uses async run/continue_run.

1"""Team HITL: Async member agent tool confirmation.
2
3Same as confirmation_required.py but uses async run/continue_run.
4"""
5
6import asyncio
7
8from kern.agent import Agent
9from kern.models.openai import OpenAIResponses
10from kern.team.team import Team
11from kern.tools import tool
12
13
14# ---------------------------------------------------------------------------
15# Tools
16# ---------------------------------------------------------------------------
17@tool(requires_confirmation=True)
18def deploy_to_production(app_name: str, version: str) -> str:
19 """Deploy an application to production.
20
21 Args:
22 app_name (str): Name of the application
23 version (str): Version to deploy
24 """
25 return f"Successfully deployed {app_name} v{version} to production"
26
27
28# ---------------------------------------------------------------------------
29# Create Members
30# ---------------------------------------------------------------------------
31deploy_agent = Agent(
32 name="Deploy Agent",
33 role="Handles deployments to production",
34 model=OpenAIResponses(id="gpt-5.2-mini"),
35 tools=[deploy_to_production],
36)
37
38
39# ---------------------------------------------------------------------------
40# Create Team
41# ---------------------------------------------------------------------------
42team = Team(
43 name="DevOps Team",
44 members=[deploy_agent],
45 model=OpenAIResponses(id="gpt-5.2-mini"),
46)
47
48
49# ---------------------------------------------------------------------------
50# Run Team
51# ---------------------------------------------------------------------------
52if __name__ == "__main__":
53
54 async def main():
55 response = await team.arun("Deploy the payments app version 2.1 to production")
56
57 if response.is_paused:
58 print("Team paused - requires confirmation")
59 for req in response.requirements:
60 if req.needs_confirmation:
61 print(f" Tool: {req.tool_execution.tool_name}")
62 print(f" Args: {req.tool_execution.tool_args}")
63 req.confirm()
64
65 response = await team.acontinue_run(response)
66 print(f"Result: {response.content}")
67 else:
68 print(f"Result: {response.content}")
69
70 asyncio.run(main())

Run the Example

1# Clone and setup repo
2git clone https://github.com/kern-ai/kern.git
3cd kern/cookbook/03_teams/human_in_the_loop
4
5# Create and activate virtual environment
6./scripts/demo_setup.sh
7source .venvs/demo/bin/activate
8
9python confirmation_required_async.py