> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xpertai.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 人机协同

人机协同（或“人在回路”）通过几种常见的用户交互模式增强代理功能。

* `Approval` 需要用户确认的行为，在调用节点前打断。
* `Editing` 需要用户输入的行为，在调用工具前打断。

## 如何配置敏感智能体和工具

通过为子智能体或工具设置敏感属性，主智能体在调用这些敏感节点之前会被打断。此时，系统会展示一个确认和编辑参数的窗口，用户可以在此窗口中查看和修改即将调用的参数。只有在用户确认并同意后，主智能体才会继续执行调用动作。这种机制确保了在关键节点上的用户参与和控制，提升了系统的安全性和灵活性。

<img src="https://mintcdn.com/xpertai/CUk-Ab9Rv7YWeJmd/public/img/ai/human-in-the-loop-sensitive.png?fit=max&auto=format&n=CUk-Ab9Rv7YWeJmd&q=85&s=062279f0a1e08cf3856f6a30a401da0c" alt="Set as sensitive" width="2444" height="1614" data-path="public/img/ai/human-in-the-loop-sensitive.png" />

在用户查看或编辑调用的参数值后，智能体会使用最新的参数值继续调用子智能体或工具。

<img src="https://mintcdn.com/xpertai/CUk-Ab9Rv7YWeJmd/public/img/ai/human-in-the-loop-approval.png?fit=max&auto=format&n=CUk-Ab9Rv7YWeJmd&q=85&s=7ba0af0eafbb3433b629aac581fe74ff" alt="Set as sensitive" width="2446" height="1608" data-path="public/img/ai/human-in-the-loop-approval.png" />

## 实现的原理

在实现人机协同的过程中，敏感节点的打断是通过 langgraph.js 中的 Breakpoints 功能来实现的。Breakpoints 允许在特定的节点上设置中断点，当智能体执行到这些节点时，系统会暂停执行并触发用户交互界面。这种机制确保了用户在关键节点上的参与，使得用户可以在执行过程中查看、编辑或确认参数。

<img src="https://mintcdn.com/xpertai/CUk-Ab9Rv7YWeJmd/public/img/ai/human-in-the-loop-edit-toolcall.png?fit=max&auto=format&n=CUk-Ab9Rv7YWeJmd&q=85&s=fef203ee76d27d49061874e9dca82df5" alt="Edit parameters of tool calls" width="1991" height="1456" data-path="public/img/ai/human-in-the-loop-edit-toolcall.png" />
