委派系统(Delegation)

wesgine 支持 Agent 将子任务委派给子 Agent 执行。


delegate_task 工具

模型通过 delegate_task 工具发起委派:

{
  "name": "delegate_task",
  "arguments": {
    "goal": "分析合同条款",
    "agent_id": "agent-legal",
    "context": "附加上下文..."
  }
}

治理分类

delegate_task 归类为 ZoneRed(INV-GOV-03):


Actor 传播

委派子 Run 必须传播 Actor(2026-08-29 修复):

父 Run (actor="alice")
  ↓ delegate_task
子 Run (actor="alice")  ← 继承父 Actor

实现

internal/agent/tool.go 把 tc.Actor 同时写进:

runner.go 在子 actor 为空时从 parentParams.Actor 继承。

修复前的缺陷

子 Run 的 Actor 字段为空:


CycleDetect 覆盖

委派子 Run 可以使用更严格的 CycleDetect 阈值:

AppRunRequest{
    CycleDetectOverride: &CycleDetectConfig{
        ActionTermThreshold:        40,
        IdenticalCallTermThreshold: 5,
    },
}

编排

Run 协调

internal/orchestration/ 负责 Run 编排和委派管理:

最大深度

通过 CellSpec 或 CycleDetectConfig 限制委派深度,防止无限递归。


观测

委派子 Run 在观测面可见:

GET /cells/{id}/observe/runs

子 Run 通过 tags 关联到父 Run,且遵循 Actor 边界(INV-OBS-10)。


相关文档