CMDCOrchestrator.Nodes.HierarchyNode (cmdc_orchestrator v0.4.0)

Copy Markdown View Source

Hierarchy 节点 —— Manager-Workers-Synthesizer 三段式协作。

对应 Agentic Design Patterns 第 7 章 Multi-Agent Collaboration - Hierarchy 模式:上层 Manager 分解任务 → 下层 Workers 并行执行 → 可选 Synthesizer 汇总。

节点 config 字段

字段必填默认说明
:goal来自 dep_results总体目标;缺省时取上游输出拼串
:managernilManager Agent 定义;nil 时跳过 manager,直接用 goal 切分
:split_fn按换行切分把 manager 输出(或 goal)切成 subtask list
:tasksnil手动指定 subtask 列表,优先级高于 split_fn
:workersWorker 定义列表(数量必须 ≥ 1)
:worker_assign:round_robin任务到 worker 的分配策略::round_robin | :pairwise(一 task 一 worker,余数给第一个)
:synthesizernilSynthesizer Agent;nil 时直接返回 worker_outputs 不汇总
:max_parallellength(workers)并行度

输出

%{
  goal: "...",
  subtasks: ["...", ...],
  assignments: %{"worker_name" => ["task1", ...]},
  worker_outputs: %{"worker_name" => "...", ...},
  synthesis: "..." | nil
}

错误

  • {:error, {:hierarchy_failed, :manager, reason}}
  • {:error, {:hierarchy_failed, {:worker, name}, reason}}
  • {:error, {:hierarchy_failed, :synthesizer, reason}}
  • {:error, {:hierarchy_failed, :no_subtasks}}

Summary

Functions

execute(map, dep_results, agent_opts, runtime)

@spec execute(map(), map(), keyword(), CMDCOrchestrator.Runtime.t() | nil) ::
  {:ok, map()} | {:error, term()}