Skip to main content
Human-in-the-loop (HITL) allows you to require human approval before executing sensitive tool calls. When a tool marked as requiring approval is invoked by the agent, the execution pauses and waits for explicit user confirmation before proceeding.

How It Works

  1. Tool invocation: The agent decides to call a tool that requires approval
  2. Execution pauses: The run transitions to an await_approval state
  3. User reviews: The pending tool call is presented to the user for review
  4. User responds: The user approves or rejects the tool call
  5. Execution resumes: The agent continues with the approved tools or handles rejections

Configuring Approval for Custom Tools

To require approval for a custom function tool, embed agents.BaseTool and set RequiresApproval: true:

Configuring Approval for MCP Tools

For MCP tools, use the WithMcpApprovalRequiredTools option when retrieving tools:

Handling Approval in Your Application

When a tool requires approval, the agent execution pauses and returns with a paused status. The pending tool calls are available in the run state.

Agent Output

Execute() (via the handle’s Result()/Wait()) returns an *agents.AgentOutput. When approval is needed, its Status is RunStatusPaused and the paused run exposes one Interrupt per pending tool call in Interrupts:
Each Interrupt carries the intercepted call and the kind of gate:
Approval-required tools inside sub-agents (see Agent as a tool) bubble up to the parent’s Interrupts with IsNested: true, so the parent run pauses and surfaces them just like its own tools.

Resuming Execution

To resume execution after user review, send a FunctionCallInterruptResolutionMessage on the same thread, resolving each call by ID with InterruptActionApprove or InterruptActionReject. Execute() returns an *AgentHandle; the simplest way to wait for the resumed run is handle.Result():

Handling Rejections

To reject a call, resolve it with InterruptActionReject. You can approve some calls and reject others in the same Resolutions slice:
The agent will receive the rejection as tool output: "Request to call this tool has been declined" and can adjust its response accordingly.

Complete Example

Here’s a complete example with a mix of immediate and approval-required tools: