CMDCOrchestrator (cmdc_orchestrator v0.4.0)

Copy Markdown View Source

CMDC 多 Agent 编排引擎 — DAG 驱动的 Agent 协作。

核心概念

  • Orchestration:一个 DAG(有向无环图),定义 Agent 节点和依赖关系
  • Node:DAG 中的节点,4 种类型:agent / aggregator / router / gate
  • Edge:节点间的数据流依赖
  • Run:一次编排执行,按拓扑顺序调度节点

使用示例

dag = %CMDCOrchestrator.DAG{
  nodes: [
    %{id: "research", type: :agent, config: %{prompt: "调研 AI 趋势"}},
    %{id: "write", type: :agent, config: %{prompt: "写一篇博客"}},
    %{id: "review", type: :gate, config: %{criteria: ["准确性"]}},
  ],
  edges: [
    %{from: "research", to: "write"},
    %{from: "write", to: "review"}
  ]
}

{:ok, results} = CMDCOrchestrator.execute(dag, agent_opts)

Summary

Functions

执行无副作用 dry run。

把 WorkflowSpec 转为旧 DAG 执行结构。

校验可持久化 WorkflowSpec。

Functions

dry_run(input, opts \\ [])

@spec dry_run(
  map() | keyword() | CMDCOrchestrator.WorkflowSpec.t(),
  keyword()
) :: {:ok, map()} | {:error, map()}

执行无副作用 dry run。

execute(orchestration, agent_opts \\ [])

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

to_dag(input)

@spec to_dag(map() | keyword() | CMDCOrchestrator.WorkflowSpec.t()) ::
  {:ok, CMDCOrchestrator.DAG.t()} | {:error, term()}

把 WorkflowSpec 转为旧 DAG 执行结构。

validate_workflow(input)

校验可持久化 WorkflowSpec。