Skip to main content

Human-in-the-Loop (HITL)

Agentium can pause the agent loop before executing sensitive tools and request human approval. This is useful for:
  • Destructive operations (delete file, drop database)
  • Financial actions (send payment, place order)
  • External communications (send email, post message)
  • Any tool where you want a human reviewer in the loop
HITL is fully optional. By default, all tools execute automatically. You opt in per-tool or per-agent.

Quick Start


How It Works

When a tool call is denied, the denial message is returned to the LLM as the tool result. The LLM can then respond to the user explaining why the action was not performed.

ApprovalConfig

Set on AgentConfig.approval:
'none' | 'all' | string[]
required
Which tools require approval:
  • "none" — No tools require approval (default behavior)
  • "all" — Every tool call requires approval
  • string[] — List of tool names that require approval (e.g., ["deleteUser", "sendPayment"])
(request: ApprovalRequest) => Promise<ApprovalDecision>
Callback invoked when approval is needed. Return { approved: true/false, reason?: string }. If not provided, approval operates in event-driven mode.
number
default:"300000"
Timeout in milliseconds for waiting on a human response. Auto-denied after timeout (default: 5 minutes).

Per-Tool Approval

Set requiresApproval on individual tools:

Conditional Approval

Pass a function for dynamic approval logic:

Agent-Level Policy

Set approval.policy on the agent to control which tools need approval:

Priority

Per-tool requiresApproval takes precedence over the agent-level policy:

Callback Mode

For CLI scripts or simple integrations, use onApproval:

Event-Driven Mode

For web apps (Socket.IO, REST), omit onApproval and use events:

Events


ApprovalRequest & ApprovalDecision


Timeout

If no human responds within the configured timeout (default: 5 minutes), the tool call is auto-denied with reason "Approval timed out". This prevents the agent from hanging indefinitely.

See Also