AI 代理工具节点(AI Agent Tool node)#
AI代理工具节点允许工作流中的根级代理调用其他代理作为工具,以简化多代理的编排。
🌐 The AI Agent Tool node allows a root-level agent in your workflow to call other agents as tools to simplify multi-agent orchestration.
主要代理(primary agent)可以监督并将工作分配给专门从事不同任务和知识的 AI 代理工具节点。这使你能够在单个工作流程中使用多个代理,而无需管理子工作流程所需的上下文和变量的复杂性。你可以将 AI 代理工具节点嵌套到多层中,以应对更复杂的多层用例。
🌐 The primary agent can supervise and delegate work to AI Agent Tool nodes that specialize in different tasks and knowledge. This allows you to use multiple agents in a single workflow without the complexity of managing context and variables that sub-workflows require. You can nest AI Agent Tool nodes into multiple layers for more complex multi-tiered use cases.
本页提供 AI 代理工具节点的参数以及更多资源的链接。
🌐 On this page, you'll find the node parameters for the AI Agent Tool node, and links to more resources.
Parameter resolution in sub-nodes
Sub-nodes behave differently to other nodes when processing multiple items using an expression.
Most nodes, including root nodes, take any number of items as input, process these items, and output the results. You can use expressions to refer to input items, and the node resolves the expression for each item in turn. For example, given an input of five name values, the expression {{ $json.name }} resolves to each name in turn.
In sub-nodes, the expression always resolves to the first item. For example, given an input of five name values, the expression {{ $json.name }} always resolves to the first name.
节点参数(Node parameters)#
使用以下参数配置 AI Agent Tool 节点:
🌐 Configure the AI Agent Tool node using these parameters:
- 描述:向大型语言模型说明该代理的目的和职责范围。一个清晰、具体的描述可以告诉父代理何时将任务委托给该代理处理。
- 提示(用户消息):向大语言模型说明要执行的操作以及需要返回的信息的提示。
- 需要特定输出格式:是否希望节点要求特定的输出格式。开启后,n8n 会提示你连接其中一个输出解析器在主代理页面描述。
- 启用备用模型:是否启用备用模型。启用后,n8n 会提示你连接一个备用聊天模型,以防主模型失败或不可用时使用。
节点选项(Node options)#
使用以下选项优化 AI 代理工具节点的行为:
🌐 Refine the AI Agent Tool node's behavior using these options:
- 系统消息:在对话开始前发送给代理的一条消息。
- 最大迭代次数:模型在停止之前生成响应的最大运行次数。
- 返回中间步骤:是否在最终输出中包含代理所采取的中间步骤。
- 自动透传二进制图片:是否应将二进制图片自动作为图片类型消息传递给代理。
- 批量处理:是否启用以下批量处理选项以进行速率限制:
- 批处理大小:要并行处理的项目数量。这有助于速率限制,但可能会影响日志输出的顺序。
- 批次间延迟:批次之间等待的毫秒数。
模板和示例(Templates and examples)#
具有 $fromAI() 的工具的动态参数(Dynamic parameters for tools with $fromAI())#
要了解如何为应用节点工具动态填充参数,请参阅 让 AI 指定工具参数 $fromAI()。
🌐 To learn how to dynamically populate parameters for app node tools, refer to Let AI specify tool parameters with $fromAI().