Signal 调度

Signal 如何驱动每一次 activation

Suzumio 从持久 signal 调度 agent。消息、等待、提交、nudge 和自定义工具都会写入 SQLite,scheduler 把 pending targeted signals 变成 Docker activations。

Runtime Objects

ObjectRuntime 角色
Project持久工作单元,包含 resolved YAML、agent roster、channels、SQLite database、artifacts 和 event timeline。
Agent配置好的参与者,包含 role、prompt、model selection、workspace、artifact directory、token 和 tool allowlist。
Message持久通信记录。Direct message 指向一个 agent 或 user;channel message fan out 到 agents。
SignalScheduler 输入和 effect ledger。Pending targeted signal 唤醒 agent;closed signal 记录 effect。
Activation一个 agent 的一次隔离 Docker 执行。Activation prompt 中包含 delivered signals。
EventAppend-style timeline entry,用于 UI、audit、debug 和 replay tooling。

Project 和 Agent 状态

Project status调度行为
initialized不自动调度。
runningScheduler 可以启动 ready agents。
submittedProject 等待用户 approval。
completed调度完成。
stopped调度禁用。
Agent status调度行为
quiet有 pending targeted signals 时可启动新 activation。
running有 active activation。P0 可 interrupt;P1 可在 tool boundary 注入;P2P3 等待。
failed上一次 activation 或 backend action 失败。
stoppedAgent 禁用。

Message 变成 Signal

messages.send 会写入 message row,append message.created event,并记录一个或多个 signals。

json
{
  "sender": "user",
  "recipient": "pm",
  "priority": "P1",
  "body": "Start the project."
}
Message targetSignal result
recipient: "pm"pm 创建一个 pending message.created signal。
channel: "#reviews"给 config 中的其他 agents 各创建一个 pending message.created signal。
recipient: "user"Closed useful effect;不唤醒 agent。

未知 recipient 和未声明 channel 会被拒绝。

Signal Shape

ts
type SignalRecord = {
  kind: string
  sourceAgent?: string
  sourceActivation?: string
  targetAgent?: string
  targetChannel?: string
  priority: "P0" | "P1" | "P2" | "P3"
  status: "pending" | "delivered" | "closed"
  usefulEffect: boolean
  payload: Record<string, unknown>
}
Status含义
pending等待在 activation start 或 tool boundary 投递给 target agent。
delivered已 append 到某次 activation 的 agent history,不会再次投递。
closed不参与调度的 audit 或 useful-effect 记录。

唤醒 agent 时创建带 targetAgent 的 pending signal。只记录 effect 时省略 targetAgenttargetChannel,创建 closed signal。

Priority Rules

Priority投递规则
P0Interrupt running target agent。当前 activation 被取消,agent 带着 P0 signal 重启。
P1尽量在下一次 tool boundary 投递;没有 boundary 时在下一次 activation start 投递。
P2Control-flow 或 continuation work。等待当前 activation 完成,并在下一次 activation start 优先于 routine backlog 投递。
P3Routine queued work。等待当前 activation 完成,并在所有 pending P2 之后投递。

Routine messages 默认使用 P3P2 用于 plan-continuation nudges、scheduler control messages,以及其他应优先于普通 backlog 的工作。P0 保留给 human stop、destructive repository conflict、secret/safety issue,或继续当前 activation 会有害的 blocker。

Activation Start

对于 running project,scheduler 会检查 agent roster。Quiet agent 有 pending targeted signals 时获得一次 activation。

  1. 按 priority 和创建时间加载该 agent 的 pending signals。
  2. 渲染 activation prompt,包含当前 delivered signals 和 tool/reporting contract。
  3. 把 prompt append 到 agent 的 SQLite history。
  4. 将这些 signals 标记为 delivered,并记录 activation id。
  5. 创建 activation row,写入只读 input.json
  6. 启动一个 Docker runner container。

Activation prompt 是新 delivered signals 对模型可见的位置。Earlier model history 用于 continuity;新的 assignments 来自 delivered signals。

Running Agent Behavior

Agent 已经 running 时,scheduler 不会为它启动第二个 activation。

Incoming signalRunning-agent 行为
P0Cancel 当前 activation,停止 backend container,带 pending P0P1 signals 重启。
P1当前 activation 继续运行。如果 runner 到达 tool boundary,则在下一次完成 tool call 后投递。
P2当前 activation 继续运行。当前 activation 完成后的下一次 activation 投递,优先于 P3
P3当前 activation 继续运行。当前 activation 完成后的下一次 activation 投递,排在 pending P2 之后。

Runner 在完成 tool call 后向 Suzumio 请求 tool-boundary signal delivery。Pending P1 signals 会在该 boundary append 到 active model context。

Useful Effects 和 Nudges

usefulEffect 记录 activation 的外部协调工作。Activation 完成时,Suzumio 按 sourceActivation 统计 useful effects。

Signal kind默认 useful effect
Pending signal to another agentYes
message.createdYes
completion.submittedYes
coordination.wait_for_signalYes
scheduler.no_effect_nudgeNo
scheduler.failed_nudgeNo
Generic closed custom signalNo,除非 custom tool 设置 usefulEffect: true

Activation 完成时没有 useful effect,scheduler.noEffectNudge 可以创建 follow-up signal。默认 nudge 启用,使用 P2,由 maxConsecutiveinitialDelayMsbackoffFactormaxDelayMs 控制。

Activation 在提交 output 前失败时,scheduler.failedNudge 可以给同一个 agent 创建 delayed retry signal。它和 runner/provider 内部 retry/backoff 是分开的;作用是复活已经进入 Suzumio failed 状态的 agent。

All-Quiet Nudge

scheduler.allQuietNudge 监听所有 agents 都是 quiet 且没有 pending signals 的 project。启用后,它会给配置的 target agent 创建 pending scheduler signal,通常是 pm

yaml
scheduler:
  allQuietNudge:
    enabled: true
    targetAgent: pm
    priority: P2
    cooldownMs: 300000

Quiet Agent Monitor

scheduler.quietAgentMonitor 监听指定 agents 是否保持 quiet 超过配置时间。它通过和 messages.send 相同的路径发送普通消息;不会创建 monitor agent。

yaml
scheduler:
  quietAgentMonitor:
    enabled: true
    rules:
      - id: worker-watch
        agent: worker-1
        recipient: pm
        sender: monitor
        priority: P2
        initialDelayMs: 1800000
        repeatDelayMs: 900000
        message: "{{agent}} has been quiet for {{quietMinutes}} minutes."

Scheduler 按 rule、agent 和 quiet timestamp 记录 monitor-send events。同一个 quiet state 中,只有超过 repeatDelayMs 后才会重复发送。

Failed Agent Monitor

scheduler.failedAgentMonitor 监听指定 agents 是否保持 failed 超过配置时间。它发送普通 monitor message,通常发给 pm,并在同一个 failed activation 仍是当前失败状态时重复提醒。

Full Tick Order

默认 scheduler 是 nonpreemptive-signalsnonpreemptive-mailbox 作为 compatibility alias 接受,运行同一个 signal-driven scheduler。

  1. 跳过非 running projects。
  2. 加载 agents。
  3. 对 running agents,只处理 pending P0 interruption signals。
  4. 对 quiet agents,如果存在 pending targeted signals,启动一个 activation。
  5. 刷新 agent list。
  6. 运行 local toolpack scheduler hooks,并传入当前 agent status 和 modelAlive state。
  7. 应用 failed-agent retry nudge rules。
  8. 应用 failed-agent monitor rules。
  9. 应用 quiet-agent monitor rules。
  10. 应用 all-quiet nudge rules。

Common Flows

FlowSignal sequence
User starts PMUser message 给 pm 创建 pending message.created;scheduler 启动 pm
PM delegatesPM 调用 messages.send 给 worker;worker 获得 pending message.created;PM 可以 wait。
Worker waitsWorker 调用 coordination.wait_for_signal;activation 带 useful effect 结束,无 polling loop。
Worker reportsWorker 调用 messages.sendpm;PM 获得 pending message.created
PM submitsPM 调用 completion.submit;project 变成 submitted 并等待 approval。