CMDCOrchestrator.Nodes.RouterNode (cmdc_orchestrator v0.6.0)

Copy Markdown View Source

Router 节点 — 按策略把执行流分发到不同分支,下游节点通过 branch 边匹配。

支持策略

策略说明
"rule"顺序匹配 rules,命中第一个 pattern 即返回对应 branch
"random"branches 中均匀随机
"llm"调用 LLM 选择分支;失败 / parse 不出来 → fallback(默认 "default"

LLM 策略 config

%{
  strategy: "llm",
  branches: ["weather", "news"],
  fallback: "default",
  router_agent: %{name: "router", model: ..., system_prompt: ...},
  user_prompt: "可选的覆盖式 user prompt"
}

返回 %{route: branch, input: input, strategy: strategy}。 对应 Agentic Design Patterns 第 2 章 Routing。

Summary

Functions

execute(node, dep_results)

@spec execute(map(), map()) :: {:ok, map()}

execute(node, dep_results, agent_opts, runtime)

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