子代理进程树动态监督者。
使用 DynamicSupervisor 管理子代理进程的生命周期。
每个子代理对应一个独立的 CMDC.Agent 进程,崩溃不传染父 Agent。
进程树位置
CMDC.SessionServer (:one_for_one)
├── CMDC.SubAgent.Supervisor ← 此模块
│ ├── CMDC.Agent (sub-coder)
│ ├── CMDC.Agent (sub-researcher)
│ └── ...
└── CMDC.Agent (main)示例
{:ok, sup} = CMDC.SubAgent.Supervisor.start_link([])
{:ok, pid} = CMDC.SubAgent.Supervisor.start_child(sup, agent_opts)
:ok = CMDC.SubAgent.Supervisor.stop_child(sup, pid)
[pid1, pid2] = CMDC.SubAgent.Supervisor.list_children(sup)
Summary
Functions
Returns a specification to start this module under a supervisor.
返回活跃子代理数量。
列出此监督者下所有活跃子代理 pid。
在此监督者下启动一个子代理进程。
启动 SubAgent 动态监督者。
停止指定 pid 的子代理进程。
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec count(pid() | atom()) :: non_neg_integer()
返回活跃子代理数量。
列出此监督者下所有活跃子代理 pid。
@spec start_child( pid() | atom(), keyword() ) :: DynamicSupervisor.on_start_child()
在此监督者下启动一个子代理进程。
agent_opts 为传递给 CMDC.Agent.start_link/1 的选项列表,
必须包含 :session_id 字段。
返回 {:ok, pid} 或 {:error, reason}。
@spec start_link(keyword()) :: Supervisor.on_start()
启动 SubAgent 动态监督者。
停止指定 pid 的子代理进程。
进程不存在时返回 :ok(幂等)。
显式调用此函数时会 emit [:cmdc, :subagent, :spawn, :stop] telemetry 事件。
子 Agent 自然 terminate(如 :normal exit / Tool.Task 收集结果完毕)的路径
不走这里,由 Tool.Task 在收集结果时单独 emit :stop。