CMDCOrchestrator.Nodes.DebateNode (cmdc_orchestrator v0.3.1)

Copy Markdown View Source

Debate / Consensus 节点 —— 多个辩手 Agent 围绕 topic 辩 N 轮,最终 Judge 给出裁决。

对应 Agentic Design Patterns 第 7 章 Multi-Agent Collaboration - Debate。

节点 config 字段

字段必填默认说明
:topic来自 dep_results辩论主题;缺省时取上游输出拼串
:debaters辩手列表,每项见下表
:judgeJudge 定义,同辩手表
:max_rounds3最大辩论轮数
:consensus_fnfn _ -> false end判断是否达成共识的函数
:mode:pool辩手/judge 的 AgentNode 模式(透传给内部 AgentNode)
:system_prompt_preamble内置 debate prompt注入到每轮 user prompt 前的说明

每个 辩手 / judge 的结构:

%{
  name: "advocate_a",           # 必填,用于区分
  system_prompt: "...",          # 可选,否则继承 agent_opts
  model: "...",                  # 可选
  pool_key: {...}                # 可选,默认 {:debate, node_id, name}
}

输出形状

%{
  topic: "...",
  rounds: [
    %{
      round: 1,
      statements: %{"advocate_a" => "...", "advocate_b" => "..."}
    },
    ...
  ],
  verdict: "...",            # Judge 最终裁决文本
  consensus: true | false,   # consensus_fn 是否曾返回 true
  terminated_at_round: 1..max_rounds
}

错误

  • {:error, {:debate_failed, stage, reason}} — 某轮辩手/judge Agent 失败后立即终止

Summary

Functions

execute(map, dep_results, agent_opts, runtime)

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