ARTICLE DETAIL

资讯详情

深耕郑州网站建设与运营推广的一线实战洞察。

RocketRide DeepAgent Subagent 节点深度解析:构建由 Deep Agent 编排的分层子智能体流水线

RocketRide DeepAgent Subagent 节点深度解析:构建由 Deep Agent 编排的分层子智能体流水线 【免费下载链接】rocketride-serverHigh-performance AI pipeline engine with a C core and 50 Python-extensible nodes. Build, debug, and scale LLM workflows with 13 model providers, 8 vector databases, and agent orchestration, all from your IDE. Includes VS Code extension, TypeScript/Python SDKs, and Docker deployment.项目地址https://gitcode.com/gh_mirrors/ro/rocketride-server点击查看免费下载DeepAgent Subagentagent_deepagent_subagent是 RocketRide 流水线引擎中一个受编排器托管的子智能体节点它不接收用户的直接提问而是挂在Deep Agent编排器节点的deepagent通道上由编排器在运行时收集其描述并构建为deepagents.SubAgent记录再通过编排器 LLM 的task工具按需委派任务。读完本文你将掌握 Subagent 的连接方式、两类配置模式Instructions / System Prompt、多编排器共享接线规则以及从describe扇出到子智能体独立 LLM/工具路由的完整底层调用链可以直接在 RocketRide 画布上搭建研究员 程序员 协调者式的分层多智能体流水线。一、节点定位什么是 DeepAgent Subagent根据节点自身的 READMESubagent 是一个managed sub-agent受托管子智能体由Deep Agent编排器通过deepagentinvoke 通道驱动编排器向所有连接的 Subagent扇出describe收集每个子智能体的名称name、描述description、系统提示词system prompt与附加指令instructions编排器把这些信息构建成deepagents.SubAgent记录并通过编排器 LLM 的task工具实现可调用没有 lanes通道线它由编排器驱动而非直接接收用户提问。从源码看Subagent 的驱动类DeepAgentSubagentDriver直接继承自编排器驱动DeepAgentDriver仅覆盖了两处行为subagent.pyclass DeepAgentSubagentDriver(DeepAgentDriver): Managed DeepAgent sub-agent driver. FRAMEWORK deepagent_subagent def describe(self, pSelf: Any) - Any: Return an IInvokeDeepagent.DescribeResponse for describe fan-out. ... ... def _run(self, *, context: AgentContext, question: Question) - AgentRunResult: Defense-in-depth: Subagent has no questions lane and cannot be run as a top-level pipeline agent. ... raise NotImplementedError( DeepAgent Subagent cannot be invoked directly; wire it into a DeepAgent via the deepagent channel. )也就是说Subagent 只有describe这一条对外能力作为顶层智能体直接运行会直接抛错——这是设计使然而不是 bug。二、与 Deep Agent 编排器的分工agent_deepagent目录下同时发布两个节点变体官方 README 做了清晰对比agent_deepagent/README.md维度Deep Agent编排器Deep Agent Subagent子智能体协议agent_deepagent://agent_deepagent_subagent://classType[agent, tool][deepagent]入口questionslane 接收任务、answerslane 返回答案无 lanes只能被编排器经deepagent通道驱动能否独立运行可以不可以能否被其他 Agent 当作工具调用可以nodeId.run_agent不可以tool.run_agent不可用角色规划、拆解任务、委派执行被委派的专项任务关键差异体现在服务声明文件 services.subagent.json 中{ title: Deep Agent Subagent, protocol: agent_deepagent_subagent://, classType: [deepagent], capabilities: [invoke], register: filter, description: [Managed Deep Agent subagent. Must be wired into a Deep Agent node via the deepagent channel., Cannot be invoked directly, has no questions lane.] }classType只含deepagent不含tool因此在 RocketRide 中它不能通过tool.run_agent被其他智能体当作工具调用capabilities只有invoke配合register: filter它只能作为过滤器式节点挂在编排器下方。而 Deep Agent 编排器本身services.agent.json 对应实现是独立可跑的智能体可独立完成单智能体任务接入 Subagent 后升级为编排器接入父级智能体时又能作为run_agent工具被调用。三种形态对应官方 README 中的三类示例流水线。三、连接ConnectionsSubagent 只有两个通道channel均与编排器完全独立Channel必填说明llm是该子智能体被委派时用于思考的 LLMtool否该子智能体可使用的工具服务声明中对应invoke: { llm: { description: LLM used by this sub-agent when delegated to, min: 1 }, tool: { description: Tools available to this sub-agent (via control-plane invoke), min: 0 } }llm通道的min: 1说明它必须接上一个 LLM 节点如llm_anthropic、llm_openai等而tool通道可空。这一点与编排器llm必填、tool可选、deepagent可选的连接规范一致agent_deepagent/README.md 的 Connections 一节。独立性是 Subagent 的核心特性子智能体的 LLM 和工具通道与编排器的不互通。当编排器委派任务给该子智能体时LLM 调用和工具调用都会被路由回这个节点自己的通道上——也就是说研究员子智能体可以配llm_anthropictool_exa_search同时编排器自己用另一套 LLM 工具。四、配置详解4.1 Always visibleDescription描述这是 Subagent 上唯一一个始终可见的配置字段也是最重要的字段Description —— 简短的专业化摘要。这是编排器读取的唯一信号用于决定何时委派任务给它。官方 README 对它的强调非常直接agent_deepagent/README.md编排器读取只有这段文字来决定把哪个任务交给哪个子智能体——它看不到子智能体的提示词、工具或 LLM保持具体、面向动作Searches the web and summarizes findings with sources 这样的描述会被路由到工作而 helper agent 这种泛泛描述永远不会被选中如果某个子智能体闲置、而编排器自己干完了所有活优先检查这个字段。服务声明中的字段定义services.subagent.jsondescription: { type: string, title: Description, default: , optional: true, description: The orchestrator reads this description to decide when to delegate to this sub-agent. Keep it specific and action-oriented, this is the only signal the orchestrator uses to pick a sub-agent., ui: { ui:widget: textarea } }4.2 Advanced ModeInstructions 与 System Prompt 二选一节点提供Normal Mode / Advanced Mode两种配置形态由布尔字段advanced_mode控制默认false模式字段说明Normal Modeinstructions逐行追加到子智能体内置默认系统提示词之后Advanced Modesystem_prompt子智能体的完整系统提示词覆盖内置默认值服务声明中advanced_mode通过conditional实现字段互斥展示services.subagent.jsonadvanced_mode: { type: boolean, title: Advanced Mode, description: When enabled, replace the Instructions list with a direct System Prompt field for full control., default: false, enum: [[false, Off], [true, On]], conditional: [ { value: false, properties: [instructions] }, { value: true, properties: [system_prompt] } ] }底层拼接逻辑在 deepagent.py 的_compose_system_promptdef _compose_system_prompt(*, base: Optional[str], instructions: Optional[List[str]], fallback: str) - str: Combine a base system prompt with trailing instruction lines. * Start with *base* (stripped); fall back to *fallback* when *base* is empty. * Append each non-empty instruction on its own line. prompt (base or ).strip() or fallback for inst in instructions or []: inst inst.strip() if inst: prompt f{prompt}\n{inst} return promptsystem_prompt为空时回退到内置默认提示词每条非空instructions会以独立行的形式追加在提示词末尾子智能体默认的 fallback 提示词是You are a helpful sub-agent. Use your tools to complete the assigned task.deepagent.py。官方建议除非内置提示词确实妨碍了你否则保持在默认模式——直接替换system_prompt会丢弃掉 Deep Agents 赖以成名的规划与状态管理行为agent_deepagent/README.md 的 Configuration 一节。五、流水线接线Pipeline wiring5.1 唯一的合法接法deepagent通道Subagent 必须被接线到Deep Agent节点的deepagent通道中示例拓扑来自官方 README 的层次化团队示例webhook → agent_deepagent → response ├─ deepagent → Deep Agent Subagent研究员llm: A, tool: tool_exa_search └─ deepagent → Deep Agent Subagent程序员llm: B, tool: tool_python / tool_github接线要点可同时连接多个编排器同一个 Subagent 可以接入多个Deep Agent节点的deepagent通道每个编排器都会在各自的层次化运行中独立地把该子智能体包含进来本节点没有questionslane无法被直接调用classType仅为[deepagent]也无法通过tool.run_agent被当作工具调用需要可独立运行、或可被其他 Agent 作为工具调用的 DeepAgent 时请使用Deep Agent节点本身而不是 Subagent。5.2 编排器侧的四步委派流程当编排器节点运行一次时deepagent.py 的_collect_subagents会完成一次完整的describe扇出通过pSelf.instance.getControllerNodeIds(deepagent)发现所有连接的 Subagent 节点 id对每个节点构造IInvokeDeepagent.Describe()并逐一invoke——每个 Subagent 的IInstance.describe处理器把自己的DescribeResponse追加到param.agents列表一次扇出收集全部描述符IInstance.py对每个描述符用AgentHostServices(d.invoke)构建子智能体自己的 LLM/工具宿主再构造deepagents.middleware.subagents.SubAgent记录并把subagents传给deepagents.create_deep_agentdeepagent.py编排器 LLM 由此获得一个task(description, subagent_type)工具它读到哪个子智能体的 Description 匹配当前子任务就调用task把工作委派过去每个子智能体运行在继承父运行元数据run_id、pipe_id、invoked_tools等的独立AgentContext中SSE 事件会回路由到同一次逻辑运行deepagent.py。值得注意的工程细节来自 deepagent.py 源码单个describe失败不致命某个 Subagent 节点 invoke 失败时只记录error(...)日志并continue整个运行继续并行委派编排器 LLM 输出复数形态{type:tool_calls,calls:[...]}时LangGraph 的异步 ToolNode 会通过asyncio.gather并发分发所有条目因此一个回合内可以并行委派给多个子智能体LLM/工具调用不串行宿主 LLM 的_agenerate与工具_arun都通过asyncio.to_thread把阻塞的引擎 RPC 桥接出事件循环并发调用不会在编排器的 loop 上排队子智能体与编排器共享工具统计子上下文显式复用父上下文的invoked_tools计数deepagent.py父运行若开启了require_tool_call守卫子智能体调用的工具同样计入。5.3 节点实例层的防御性设计Subagent 的IInstance对被直接提问做了双层防御IInstance.pydef writeQuestions(self, question: Question) - None: # Defense-in-depth. DeepAgent Subagent has no questions lane — the # engine should never reach this method through normal pipeline routing. raise RuntimeError( DeepAgent Subagent cannot be invoked directly; wire it into a DeepAgent via the deepagent channel. )引擎层driver 的_run同样抛NotImplementedError。即使有人误把消息路由到 Subagent流水线也会立即失败并给出清晰的接线指引而不是静默吞掉输入。六、子智能体如何描述自己describe 的返回结构Subagent 被扇出时返回的IInvokeDeepagent.DescribeResponse由 subagent.py 的describe()构建def describe(self, pSelf: Any) - Any: Return an IInvokeDeepagent.DescribeResponse for describe fan-out. ... from rocketlib.types import IInvokeDeepagent pipe_type pSelf.instance.pipeType node_id str(pipe_type.get(id) if isinstance(pipe_type, dict) else getattr(pipe_type, id, )) or return IInvokeDeepagent.DescribeResponse( namenode_id or str(self._iGlobal.glb.logicalType), descriptionself._description, system_promptself._system_prompt, instructionslist(self._instructions or []), node_idnode_id, invokepSelf, )其中name优先取画布上节点的 id否则回退到逻辑类型名description来自配置中的 Description 字段——这就是编排器选择委派对象的唯一依据system_prompt与instructions分别来自 Advanced Mode / Normal Mode 的配置字段在 deepagent.py 的DeepAgentDriver.__init__中从解析后的配置读取invoke持有该 Subagent 的完整IInstance引用编排器随后用它构建AgentHostServices(d.invoke)从而把子智能体的 LLM/工具调用路由回它自己的通道。IGlobal侧则负责安装依赖并实例化驱动IGlobal.py在非 CONFIG 模式下通过depends()安装父级agent_deepagent/requirements.txtdeepagents、langchain、langchain-core、pydantic然后挂载DeepAgentSubagentDriver所有用户配置字段由AgentBase.__init__统一加载。七、JSON 信封工具调用协议与 FINAL 哨兵虽然 Subagent 本身不直接对话但它继承的DeepAgentDriver使用一套与 LLM 无关的JSON envelope 协议deepagent.py理解它有助于排查子智能体运行异常单工具调用{type:tool_call,name:server.tool,args:{...}}并行工具调用{type:tool_calls,calls:[{name:...,args:{...}}, ...]}—— 这是解锁单回合并行子智能体委派的线上形态最终回答FINAL后跟纯文本设计原则是工具调用用 JSON给用户的回答不用 JSON回答是散文可能含 markdown 表格、链接如果硬塞进 JSON 字符串任何一个内部引号转义失误都会让整个信封解析失败用户就会读到协议原文而不是答案。FINAL之后的所有内容原样交付只有分隔符一个换行或一个同行空格会被移除行首的四个空格会被保留——这正是 markdown 代码块所需的缩进。协议解析有严格边界deepagent.py哨兵只在行首匹配且先于一切 JSON 解析——这样引用了FINAL字样的工具调用不会被误判为最终回答模型输出非法 JSON 时最多重试 3 次每次重试提示会点名出错字符并引用周边文本并根据尝试类型给出不同补救方向坏掉的回答被指向FINAL坏掉的工具调用被要求修复后重发同样的调用而不是改口用散文描述宽容解析器能提取第一个平衡的 JSON 对象拯救被 markdown 围栏包裹、带尾部散文或堆叠第二个多余对象的输出明确的{type:final,...}信封即使解析失败也会被抢救出正文而损坏的tool_call绝不会被抢救成回答——否则本该执行的工作会变成声称已经完成的一句话。网络无关的单元测试完整覆盖了这套协议test_final_envelope.py测试动机源自一个真实线上事故某次回答因内部未转义引号导致信封损坏用户读到了{type:final,content:...}协议原文。测试验证了哨兵免转义、final 信封抢救、重试提示命名断点、损坏工具调用拒绝抢救等全部行为是深入理解该协议的最佳读物。八、可观测性SSE thinking 事件运行过程中驱动会通过sendSSE(context, thinking, ...)持续推送进度事件deepagent.py 的_SSECallbackHandler主机工具发现数量Discovered N host tool(s)子智能体收集数量Collected N sub-agent(s)仅当存在连接时Agent 启动Starting Deep Agent...每个工具的启动 / 完成 / 错误含工具名与输入长度LLM 调用的启动 / 完成 / 错误Agent 的 thinking / done 状态切换。这些事件帮助你在 IDE 或监控面板里实时跟踪编排器与每个子智能体的执行轨迹包括编排器是否真的委派给了子智能体、子智能体调用了哪些工具。九、典型接线实操清单在 RocketRide 画布上搭建一个带专项子智能体的流水线时建议按如下清单核对放一个Deep Agent节点把它的llm通道接到一个 LLM 节点需要它联网/写码时再接tool放若干Deep Agent Subagent节点每个都必须接自己的llm通道独立可与编排器不同按需接tool把每个 Subagent 拖一条线连到编排器的deepagent通道注意不是tool、也不是questions为每个 Subagent 填写具体、面向动作的 Description如 Searches the web and summarizes findings with sources这是编排器选人的唯一依据默认保持Normal Mode用 Instructions 逐行追加行为约束只有当内置提示词确实碍事时才开启 Advanced Mode 替换 System Prompt将消息源chat / webhook 等接入编排器的questionslane把answerslane 接到输出节点response_answers等若要并行委派多个子智能体确认编排器 LLM 足够强能输出复数形态tool_calls信封——这是 LangGraph 并发分发的触发条件。参考的官方示例example.pipe展示了单智能体形态的接线chat → agent_deepagent → response_answersllm_anthropic接llm、tool_http_request接tool见 example.pipe层次化多子智能体的接法在 agent_deepagent/README.md 的 Example pipelines 一节有完整描述。十、常见问题与排查建议现象排查方向子智能体从未被委派编排器自己干完了所有活优先检查 Description是否太泛helper agent改成具体、面向动作的描述运行时报 cannot be invoked directly消息被错误路由到了 Subagent它没有questionslane必须经编排器deepagent通道驱动想把子智能体当作工具由父级 Agent 调用设计上不允许classType仅[deepagent]。改用Deep Agent节点本身它注册为[agent, tool]支持nodeId.run_agent子智能体 LLM 输出异常/回答丢失检查 JSON 信封协议工具调用须为 JSON 对象回答须以FINAL行首开头非法输出会触发最多 3 次带断点提示的重试想观察委派是否发生查看 SSEthinking事件流中的Collected N sub-agent(s)与各工具/LLM 事件核心结论DeepAgent Subagent 是 RocketRide 把 Deep Agents 框架接入流水线引擎后形成的编排器-工人分层结构中的工人角色。它没有自己的问题入口只通过deepagent通道的describe扇出向编排器自荐用唯一可见的 Description 字段决定自己被选中的概率一旦被委派它就在自己独立的 LLM/工具通道上运行与编排器互不干扰。理解它的只能被编排、不能独立跑、不能当工具三重边界是正确搭建可维护、可扩展的分层多智能体流水线的第一步。深入源码可从 subagent.py 与 deepagent.py 入手配套 test_final_envelope.py 提供了协议层的完整行为契约。赞分享【免费下载链接】rocketride-serverHigh-performance AI pipeline engine with a C core and 50 Python-extensible nodes. Build, debug, and scale LLM workflows with 13 model providers, 8 vector databases, and agent orchestration, all from your IDE. Includes VS Code extension, TypeScript/Python SDKs, and Docker deployment.项目地址https://gitcode.com/gh_mirrors/ro/rocketride-server点击查看免费下载相关推荐RocketRide Deep Agent 节点深度解析基于 Deep Agents 的规划型 Agent 与层级子代理编排RocketRide Deep Agent 节点深度解析基于 Deep Agents 的规划型 Agent 与层级子代理编排 RocketRide 的 ageAG Kit Agent Flow 架构深度解析从请求分类到多智能体编排的完整流水线AG Kit Agent Flow 架构深度解析从请求分类到多智能体编排的完整流水线 导读 AG Kit 是一个以 Google Antigravity 为主人工智能AI 技能ValueCell 核心架构深度解析Super Agent 分流、异步可重入编排器与 A2A 多智能体流水线ValueCell 核心架构深度解析Super Agent 分流、异步可重入编排器与 A2A 多智能体流水线 本文以 docs/CORE_ARCHITECTUAI Agent多智能体金融科技后端前端上一篇5分钟快速上手Maestro移动应用UI自动化测试终极指南下一篇从入门到精通sarashina2.2-tts全功能教程解锁多风格语音合成创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表