Reject Member Tool Call
Handle rejection of a tool call by a team member agent.
This example demonstrates how the team handles rejection of a tool call. After rejection, the team continues and the model responds acknowledging the rejection.
1"""Team HITL: Rejecting a member agent tool call.23This example demonstrates how the team handles rejection of a tool4call. After rejection, the team continues and the model responds5acknowledging the rejection.6"""78from kern.agent import Agent9from kern.models.openai import OpenAIResponses10from kern.team.team import Team11from kern.tools import tool121314# ---------------------------------------------------------------------------15# Tools16# ---------------------------------------------------------------------------17@tool(requires_confirmation=True)18def delete_user_account(username: str) -> str:19 """Permanently delete a user account and all associated data.2021 Args:22 username (str): Username of the account to delete23 """24 return f"Account {username} has been permanently deleted"252627# ---------------------------------------------------------------------------28# Create Members29# ---------------------------------------------------------------------------30admin_agent = Agent(31 name="Admin Agent",32 role="Handles account administration tasks",33 model=OpenAIResponses(id="gpt-5.2-mini"),34 tools=[delete_user_account],35)3637# ---------------------------------------------------------------------------38# Create Team39# ---------------------------------------------------------------------------40team = Team(41 name="Admin Team",42 members=[admin_agent],43 model=OpenAIResponses(id="gpt-5.2-mini"),44)4546# ---------------------------------------------------------------------------47# Run Team48# ---------------------------------------------------------------------------49if __name__ == "__main__":50 response = team.run("Delete the account for user 'jsmith'")5152 if response.is_paused:53 print("Team paused - requires confirmation")54 for req in response.requirements:55 if req.needs_confirmation:56 print(f" Tool: {req.tool_execution.tool_name}")57 print(f" Args: {req.tool_execution.tool_args}")5859 # Reject the dangerous operation60 req.reject(note="Account deletion requires manager approval first")6162 response = team.continue_run(response)63 print(f"Result: {response.content}")64 else:65 print(f"Result: {response.content}")Run the Example
1# Clone and setup repo2git clone https://github.com/kern-ai/kern.git3cd kern/cookbook/03_teams/human_in_the_loop45# Create and activate virtual environment6./scripts/demo_setup.sh7source .venvs/demo/bin/activate89python confirmation_rejected.py