Confirm Team Tool

This example demonstrates HITL for tools provided directly to the Team (not to member agents).

This example demonstrates HITL for tools provided directly to the Team (not to member agents). When the team leader decides to use a tool that requires confirmation, the entire team run pauses until the human confirms.

1"""Team HITL: Tool on the team itself requiring confirmation.
2
3This example demonstrates HITL for tools provided directly to the Team
4(not to member agents). When the team leader decides to use a tool
5that requires confirmation, the entire team run pauses until the
6human confirms.
7"""
8
9from kern.agent import Agent
10from kern.models.openai import OpenAIResponses
11from kern.team.team import Team
12from kern.tools import tool
13
14
15# ---------------------------------------------------------------------------
16# Tools
17# ---------------------------------------------------------------------------
18@tool(requires_confirmation=True)
19def approve_deployment(environment: str, service: str) -> str:
20 """Approve and execute a deployment to an environment.
21
22 Args:
23 environment (str): Target environment (staging, production)
24 service (str): Service to deploy
25 """
26 return f"Deployment of {service} to {environment} approved and executed"
27
28
29# ---------------------------------------------------------------------------
30# Create Members
31# ---------------------------------------------------------------------------
32research_agent = Agent(
33 name="Research Agent",
34 role="Researches deployment readiness",
35 model=OpenAIResponses(id="gpt-5.2-mini"),
36)
37
38
39# ---------------------------------------------------------------------------
40# Create Team
41# ---------------------------------------------------------------------------
42team = Team(
43 name="Release Team",
44 members=[research_agent],
45 model=OpenAIResponses(id="gpt-5.2-mini"),
46 tools=[approve_deployment],
47)
48
49
50# ---------------------------------------------------------------------------
51# Run Team
52# ---------------------------------------------------------------------------
53if __name__ == "__main__":
54 response = team.run("Check if the auth service is ready and deploy it to staging")
55
56 if response.is_paused:
57 print("Team paused - requires confirmation for team-level tool")
58 for req in response.requirements:
59 if req.needs_confirmation:
60 print(f" Tool: {req.tool_execution.tool_name}")
61 print(f" Args: {req.tool_execution.tool_args}")
62 req.confirm()
63
64 response = team.continue_run(response)
65 print(f"Result: {response.content}")
66 else:
67 print(f"Result: {response.content}")

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 team_tool_confirmation.py