SESSION 11

Autonomous Agents 自主代理

Agent 自己找活干 — Agents That Find Their Own Work

AUTONOMOUS AGENT LIFECYCLE STATE MACHINE SPAWN initialize start WORK LLM calls + tool execution tool_use no tool_use stop_reason=end_turn IDLE every 5s, up to 60s timeout 1. check inbox has msg? 2. scan .tasks/ unclaimed? 3. timeout 60s no activity poll 5s resume (inbox msg) resume (task claimed) timeout SHUTDOWN cleanup & exit Auto-Claim Flow 自动认领流程 scan filter claim execute filter: status=pending, no owner, no blockedBy Identity Re-injection 身份重注入 When context is compacted (short), re-inject: "You are {name}, role: {role}. Your inbox: {inbox_path}. Current task: {task_id}" inject on compact
CONCEPT 01

自主 = 轮询 Autonomous = Polling

自主性的本质就是 IDLE 循环。Agent 不等待指令,而是每 5s 主动检查收件箱和任务板。超过 60s 无活动则自动关闭,节省资源。

CONCEPT 02

自动认领 Auto-Claim

扫描 .tasks/ 目录,过滤条件:status=pending、无 owner、无 blockedBy。找到匹配任务后写入自己的 agent_id 完成认领,然后执行。

CONCEPT 03

身份重注入 Identity Re-injection

当上下文被压缩(compact)后,Agent 可能忘记自己是谁。此时需要重新注入身份信息:名字、角色、收件箱路径、当前任务 ID。这样 Agent 能无缝继续工作。

试一试 Try It Out

1

"创建多个任务,生成 Agent 观察它们自我分配工作"

"Create multiple tasks and spawn agents to watch them self-assign work"

2

"生成单个 Agent 独立发现任务"

"Spawn individual agents to discover tasks independently"

3

"测试基于依赖关系的任务排序"

"Test dependency-based task ordering"

4

"使用 /tasks 查看所有权状态"

"Use /tasks to view ownership status"

5

"使用 /team 监控 Agent 活动状态"

"Use /team to monitor agent activity states"