# Human-in-the-Loop

> The Human-in-the-Loop is an approach where a person reviews or approves important actions of an AI system.

## How do I add human approval to an AI agent?

The approach where an AI system stops for human confirmation before risky actions, such as deleting data, making payments or deploying code. Balances automation with control and responsibility.

- Topic: AI Agents
- Type: approach

## Example

Wrong:

```js
async function runTool(call) {
  return tools[call.name](call.args);
}
```

Right:

```js
async function runTool(call) {
  if (RISKY_TOOLS.has(call.name)) {
    const ok = await requestApproval({ tool: call.name, args: call.args });
    if (!ok) return { error: 'Rejected by the user' };
  }
  return tools[call.name](call.args);
}
```

Approval is enforced in code and shows the exact tool and arguments, so the model cannot skip it.

## Common mistakes

- Asking for approval so often that people click yes without reading.

## Key points

- Actions that send, pay, delete or deploy wait for explicit approval.
- The approval screen shows the exact action and its arguments, not a vague summary.
- Approval is enforced in code, so the model cannot skip it.

## Interview questions

### Which agent actions need human approval?

Actions that are hard to undo or affect others: sending messages, payments, deleting data, deploying and changing permissions.

### How do I avoid approval fatigue?

Auto-approve safe, read-only actions and ask only for risky ones, so each request deserves attention.

### What should happen when a user rejects an action?

Return the rejection to the model as a tool result, so it can try another approach or stop.

## Related cards

- [Agent Permissions](https://wonderium.dev/ai/agent-permissions.md)
- [Pre-Tool Hook](https://wonderium.dev/ai/pre-tool-hook.md)
- [AI Agent](https://wonderium.dev/ai/ai-agent.md)
- [Guardrails](https://wonderium.dev/ai/guardrails.md)

---

- Level: [Artificial Intelligence](https://wonderium.dev/ai.md)
- HTML version: https://wonderium.dev/ai/human-in-the-loop
- Last updated: 2026-11-25
