Bug
In the teaching implementation of s17_autonomous_agents/code.py, a teammate can leave tasks it already owns stuck in in_progress and then exit after the 60-second IDLE timeout.
Cause
idle_poll(name, ...) only calls scan_unclaimed_tasks(). That scan accepts only tasks that are:
status == "pending"
- unowned
- dependency-ready
It never looks for tasks with status == "in_progress" and owner == name.
Therefore, after a WORK phase ends without a tool_use response (for example, the model returns ordinary text before it has called complete_task), the outer loop enters IDLE. The teammate cannot rediscover its own unfinished task, waits for IDLE_TIMEOUT = 60, sends a final summary, and exits. The task remains owned and in_progress.
Reproduction
- Create a pending task and start a teammate.
- Let the teammate claim the task but end a WORK phase before marking it complete.
- Observe that the task is still
in_progress with that teammate as owner.
- The teammate polls for 60 seconds, finds no unclaimed work, and exits instead of resuming its owned task.
Expected behavior
During IDLE, after handling inbox messages and before claiming new work, a teammate should resume one of its own in_progress tasks. It should return to WORK with that task injected into its messages, rather than timing out.
Minimal fix
Add a helper such as scan_resumable_tasks(owner) to find in_progress tasks owned by the current teammate. In idle_poll, prioritize one resumable task before scan_unclaimed_tasks() and append a message like:
{"role": "user", "content": "<resume-task>Task ...</resume-task>"}
I verified this with a regression test: when Alice owns an in_progress task and another pending task exists, idle_poll("alice", ...) returns "work", injects the owned task, and leaves the pending task unclaimed.
This is a teaching-version bug report; it is not a claim about the production Claude Code scheduler.
Bug
In the teaching implementation of
s17_autonomous_agents/code.py, a teammate can leave tasks it already owns stuck inin_progressand then exit after the 60-second IDLE timeout.Cause
idle_poll(name, ...)only callsscan_unclaimed_tasks(). That scan accepts only tasks that are:status == "pending"It never looks for tasks with
status == "in_progress"andowner == name.Therefore, after a WORK phase ends without a
tool_useresponse (for example, the model returns ordinary text before it has calledcomplete_task), the outer loop enters IDLE. The teammate cannot rediscover its own unfinished task, waits forIDLE_TIMEOUT = 60, sends a final summary, and exits. The task remains owned andin_progress.Reproduction
in_progresswith that teammate as owner.Expected behavior
During IDLE, after handling inbox messages and before claiming new work, a teammate should resume one of its own
in_progresstasks. It should return to WORK with that task injected into its messages, rather than timing out.Minimal fix
Add a helper such as
scan_resumable_tasks(owner)to findin_progresstasks owned by the current teammate. Inidle_poll, prioritize one resumable task beforescan_unclaimed_tasks()and append a message like:{"role": "user", "content": "<resume-task>Task ...</resume-task>"}I verified this with a regression test: when Alice owns an
in_progresstask and another pending task exists,idle_poll("alice", ...)returns"work", injects the owned task, and leaves the pending task unclaimed.This is a teaching-version bug report; it is not a claim about the production Claude Code scheduler.