Agent who finds work by himself
"The agent finds work itself." No humans are needed to dispatch orders, it will take the work itself from the task board.
From "being woken up" to "finding your own job"
The teammate of s09 / s10 is passive: someone needs to send a message through the mailbox before it starts to work; when it is done, it idles and is woken up again.
S11's autonomous teammate Active: It doesn't really stop when there is no work. It will scan the .tasks/ directory every 5 seconds - when it sees an unowned task, claim_task will claim it and start working on it.
Teammate lifecycle:
+-------+
| spawn |
+---+---+
|
v
+-------+
| WORK | <-- LLM tool_use loop
+---+---+
|
| stop_reason != tool_use OR tool_use("idle")
v
+-------+
| IDLE | poll every 5s, 12 times in total = 60s timeout
+---+---+
|
+--> New news in inbox? → resume WORK
|
+--> scan .tasks/, found unclaimed → claim → resume WORK
|
+--> 60s nothing waiting → status = shutdown, thread exits
Auto-claim · "Take orders" from the task board
Core functions:
def scan_unclaimed_tasks() -> list: unclaimed = [] for f in sorted(TASKS_DIR.glob("task_*.json")): task = json.loads(f.read_text()) if (task.get("status") == "pending" and not task.get("owner") and not task.get("blockedBy")): unclaimed.append(task) return unclaimed
Three filters = pending + no owner + no blockedBy. Both are indispensable.
The claim action itself has a lock (_claim_lock) to prevent two agents from grabbing the same unclaimed task at the same time - read the lock again, check whether the owner is still empty, and then write the "in_progress" mark + owner to the disk.
Simulate multiple agents to scan the task board at the same time
3 teammates are in idle state, and 3 tasks are waiting to be claimed. Click "Scan Next Round" to see who gets it first.
Identity re-injection·You still know who you are after compression
s06 mentioned that auto_compact will replace messages with summary. The autonomous agent can be easily triggered after running for hours - after compression, the model does not know its name or role.
S11’s trick: When claiming a new task, if len(messages) ≤ 3 (indicating that it has just been compressed), automatically insert the identity block in the header:
if len(messages) <= 3: messages.insert(0, { "role": "user", "content": f"<identity>You are 'alice', role: coder, team: my-team. Continue your work.</identity>", }) messages.insert(1, {"role":"assistant", "content": f"I am alice. Continuing."})
This mode is called identity reinjection - it uses an artificially constructed round of dialogue to "tell the model who it is" so that it can regain its sense of character.