[BUG] Agent teams: task with unresolved 'Blocked by' can be claimed; TaskCompleted fires on every teammate idle
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (two closely related agent-teams task-list defects found in one probe)
- [x] I am using the latest version of Claude Code available to me
What's Wrong?
Two task-list defects in in-process agent teams:
1. Task dependencies are not enforced on claim. A teammate claimed a task whose blocker was still in progress, and the claim succeeded:
TaskUpdate(owner +status: in_progress) on task #3 returnedUpdated task #3 owner, status.TaskGeton #3 then showedStatus: in_progress … Blocked by: #1, while #1 was stillin_progress.
The agent-teams docs say: "a pending task with unresolved dependencies cannot be claimed until those dependencies are completed."
2. TaskCompleted fires on every teammate idle, not only when a task is completed. Each time a teammate went idle, TaskCompleted fired once for every in-progress task that teammate owned, followed by TeammateIdle. Task #1 produced two TaskCompleted events before the teammate actually marked it completed. When TaskUpdate later set status: completed, no separate event fired. The hook input has no field showing whether the event came from a real completion or from an idle turn end. A hook therefore can't treat the event as "task done" (for example, to release resources the task held).
What Should Happen?
- Claiming a task that has unresolved
Blocked bydependencies is refused, as documented. - Either
TaskCompletedfires only when a task actually transitions to completed, or its input carries a field saying what triggered it (TaskUpdateversus a teammate's finishing or idle turn), so hooks can tell the two apart.
Error Messages/Logs
# Hook input log (PreToolUse/TaskCreated/TaskCompleted/TeammateIdle), abridged, agent_ids shortened
12:43:54 TaskCreated task_id=1
12:43:55 TaskCreated task_id=2
12:43:56 TaskCreated task_id=3 # 3 blocked by 1
12:44:24 TaskCompleted task_id=1 teammate=probe-a # probe-a idle, task 1 still in progress
12:44:24 TeammateIdle teammate=probe-a
12:44:27 TaskCompleted task_id=1 teammate=probe-a # again, still in progress
12:44:27 TeammateIdle teammate=probe-a
12:44:31 TaskCompleted task_id=2 teammate=probe-b
12:44:31 TaskCompleted task_id=3 teammate=probe-b # task 3 claimed while blocker 1 in progress
12:44:31 TeammateIdle teammate=probe-b
Steps to Reproduce
- Launch with
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 CLAUDE_CODE_ENABLE_TODO_TOOLS=1 claude. The second variable is needed on Opus 5.5 to get the Task tools. - Register a trivial logging hook on
TaskCreated,TaskCompletedandTeammateIdlethat appends the stdin JSON to a file. - As lead, create T1, T2, and T3 with T3 blocked by T1.
- Spawn two in-process teammates (
workersubagent type, Haiku). Tell teammate A to claim T1, then wait for a message from B before completing it. Tell teammate B to claim T3 immediately. - Observe that B's claim of T3 succeeds while T1 is in progress, and that
TaskCompletedfor T1 fires every time A goes idle.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.296 (Claude Code)
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
Other
Additional Information
- Lead on Opus 5.5; teammates on Haiku 5.5;
teammateMode: auto, which fell back to in-process (Windows Terminal, WSL2, bash). - The lead and both teammates had the Task tools.
- Other observations from the same run, possibly related: claiming a task by setting
ownersends that owner atask_assignmentmessage that appears to come from itself; and aSendMessageto a teammate still starting up fails withNo agent named '…' is reachable.