SESSION 09

Agent Teams 代理团队

能互相交谈的队友 — Teammates That Talk to Each Other

AGENT TEAM ARCHITECTURE .team/config.json agents: [lead, alice, bob] roles & permissions Lead (主线程) Agent Loop (LLM+Tools) inbox: lead.jsonl spawns & coordinates teammates Alice (队友线程) Agent Loop (LLM+Tools) inbox: alice.jsonl persistent, autonomous Bob (队友线程) Agent Loop (LLM+Tools) inbox: bob.jsonl persistent, autonomous message response .team/inbox/ (JSONL Mailboxes) lead.jsonl {"from":"alice","type":"message","body":"done"} {"from":"bob","type":"message","body":"help!"} append-only write, drain on read alice.jsonl {"from":"lead","type":"message","body":"fix auth"} {"from":"bob","type":"broadcast","body":"..."} file = mailbox, thread-safe by design bob.jsonl {"from":"lead","type":"message","body":"..."} {"from":"alice","type":"message","body":"..."} each agent drains its own mailbox LIFECYCLE COMPARISON Subagent (S04) spawn execute destroy one-shot Teammate (S09) spawn work idle work shutdown resume 5 Message Types: message broadcast shutdown_request shutdown_response plan_approval
CONCEPT 01

持久化队友 Persistent Teammates

不同于 Subagent 的一次性 spawn-execute-destroy 模式,Teammate 会一直存在,在 WORKIDLE 之间切换,直到被明确要求关闭。这意味着它们保持上下文、保持状态。

CONCEPT 02

JSONL 邮箱 Mailbox Mechanism

文件就是邮箱。每个 Agent 有自己的 .jsonl 文件,写入用 append(天然线程安全),读取用 drain(读完清空)。无需数据库,无需锁,文件系统就是消息队列。

CONCEPT 03

5 种消息类型 Message Types

通信协议精简为 5 种类型:message(点对点)、broadcast(广播)、shutdown_request / shutdown_response(关闭协商)、plan_approval(计划审批)。

试一试 Try It Out

1

"生成具有特定角色的命名队友"

"Spawn named teammates with specific roles"

2

"向整个团队广播消息"

"Broadcast messages across the team"

3

"检查单个 Agent 的收件箱"

"Check individual agent inboxes"

4

"使用 /team 命令查看名册和状态"

"Use /team command to view roster and statuses"

5

"使用 /inbox 手动检查消息"

"Use /inbox to manually inspect messages"