s10
团队协议
协作Shared Communication Rules
317 LOC12 个工具TypeScriptrequest_id correlation for two protocols
One request-response pattern drives all team negotiation
s01 > s02 > s03 > s04 > s05 > s06 | s07 > s08 > s09 > [ s10 ] s11 > s12
"队友之间要有统一的沟通规矩" -- 一个 request-response 模式驱动所有协商。
Harness 层: 协议 -- 模型之间的结构化握手。
问题
s09 中队友能干活能通信, 但缺少结构化协调:
关机: 直接杀线程会留下写了一半的文件和过期的 config.json。需要握手 -- 领导请求, 队友批准 (收尾退出) 或拒绝 (继续干)。
计划审批: 领导说 "重构认证模块", 队友立刻开干。高风险变更应该先过审。
两者结构一样: 一方发带唯一 ID 的请求, 另一方引用同一 ID 响应。
解决方案
Shutdown Protocol Plan Approval Protocol
================== ======================
Lead Teammate Teammate Lead
| | | |
|--shutdown_req-->| |--plan_req------>|
| {req_id:"abc"} | | {req_id:"xyz"} |
| | | |
|<--shutdown_resp-| |<--plan_resp-----|
| {req_id:"abc", | | {req_id:"xyz", |
| approve:true} | | approve:true} |
Shared FSM:
[pending] --approve--> [approved]
[pending] --reject---> [rejected]
Trackers:
shutdown_requests = {req_id: {target, status}}
plan_requests = {req_id: {from, plan, status}}
工作原理
- 领导生成 request_id, 通过收件箱发起关机请求。
function handleShutdownRequest(teammate: string) {
const requestId = randomUUID().slice(0, 8);
shutdownRequests[requestId] = { target: teammate, status: "pending" };
BUS.send("lead", teammate, "Please shut down gracefully.", "shutdown_request", { request_id: requestId });
}
- 队友收到请求后, 用 approve/reject 响应。
if (toolName === "shutdown_response") {
shutdownRequests[requestId].status = input.approve ? "approved" : "rejected";
BUS.send(sender, "lead", String(input.reason ?? ""), "shutdown_response", {
request_id: requestId,
approve: Boolean(input.approve),
});
}
- 计划审批遵循完全相同的模式。队友提交计划 (生成 request_id), 领导审查 (引用同一个 request_id)。
function handlePlanReview(requestId: string, approve: boolean, feedback = "") {
const request = planRequests[requestId];
request.status = approve ? "approved" : "rejected";
BUS.send("lead", request.from, feedback, "plan_approval_response", {
request_id: requestId,
approve,
});
}
一个 FSM, 两种用途。同样的 pending -> approved | rejected 状态机可以套用到任何请求-响应协议上。
相对 s09 的变更
| 组件 | 之前 (s09) | 之后 (s10) |
|---|---|---|
| Tools | 9 | 12 (+shutdown_req/resp +plan) |
| 关机 | 仅自然退出 | 请求-响应握手 |
| 计划门控 | 无 | 提交/审查与审批 |
| 关联 | 无 | 每个请求一个 request_id |
| FSM | 无 | pending -> approved/rejected |
试一试
cd learn-claude-code
cd agents-ts
npm install
npm run s10
试试这些 prompt:
Spawn alice as a coder. Then request her shutdown.List teammates to see alice's status after shutdown approvalSpawn bob with a risky refactoring task. Review and reject his plan.Spawn charlie, have him submit a plan, then approve it.- 输入
/team监控状态