Human-in-the-loop patterns for AI agents
Practical approval patterns for TypeScript AI agents: gated tool calls, review queues, approver policies, and safe resume flows.
This page is the canonical guide to human-in-the-loop approval patterns for TypeScript AI agents. For a copy-paste recipe and UI wiring, see HITL approvals and ToolConfirmation.
#Gate a tool
import { makeTool } from '@agentskit/tools'
const deployTool = makeTool({
name: 'deploy',
description: 'Deploy to production',
schema: z.object({ service: z.string() }),
requiresConfirmation: true,
execute: async ({ service }) => deploy(service),
})Runtime pauses on invocation and emits
tool.awaiting-approval. Resume with chat.approve(toolCallId) or
chat.deny(toolCallId, reason).
#UI
- ToolConfirmation β drop-in React / Vue / etc.
#Patterns
- Auto-approve low risk: approve if cost under threshold; gate the rest.
- Review queue: persist
awaiting-approvalto a DB; humans approve from dashboard. - Double-sign: require two approvers; track via shared context.
#Related
Explore nearby
- PeerAgents
Everything that runs the loop β runtime, tools, skills, delegation, durable execution, topologies, background agents, HITL, self-debug.
- PeerRuntime
Execution engine for autonomous agents β runs a ReAct loop (observe, think, act) until final answer or step limit.
- PeerMulti-Agent Delegation
Coordinate multiple specialist agents from a parent agent using directed delegation.