Skip to content

Commit f1b3a9a

Browse files
AliceLJYclaude
andcommitted
docs(skills): warn against task.owner for agent existence checks (#64)
Leader agents writing monitor scripts were inferring "agent joined the team" from `task.owner`, which is declarative and set at task-create time — a failed `clawteam spawn` leaves the owner unchanged, so the monitor sees a false positive, skips respawn, and blocks every task that depends on that agent. Add a "Checking If an Agent Has Joined" section to both skill copies (`.agents/skills/` and `skills/`) that: - Calls out the anti-pattern with a concrete bash example - Shows the correct pattern using `team.members` (backed by the spawn registry + `is_agent_alive()`) - Includes a rule-of-thumb table contrasting declarative vs. live signals Closes #64 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent dbf380d commit f1b3a9a

2 files changed

Lines changed: 86 additions & 0 deletions

File tree

.agents/skills/clawteam/references/workflows.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,46 @@ clawteam --json board overview | jq '.[] | "\(.name): \(.pendingMessages) pendin
205205
# Get team member names
206206
clawteam --json team status dev-team | jq -r '.members[].name'
207207
```
208+
209+
### Checking If an Agent Has Joined
210+
211+
When a leader agent spawns a worker and then polls to confirm it joined, the
212+
correct signal is the team's `members` list — **not** a task's `owner` field.
213+
214+
#### ❌ Anti-pattern: relying on task.owner
215+
216+
```bash
217+
# WRONG — task.owner is declarative, set at task-create time regardless of spawn outcome
218+
OWNER=$(clawteam --json task get dev-team "$task_id" | jq -r '.owner')
219+
if [[ -n "$OWNER" ]]; then
220+
echo "Agent joined" # false positive: owner is set even when spawn failed
221+
fi
222+
```
223+
224+
A task's `owner` is written when the task is **created** (via `-o`). It declares
225+
"who *should* do this work", not "who *actually joined the team*". A failed
226+
`clawteam spawn` leaves the task's owner untouched, so monitor loops that poll
227+
`task.owner` falsely see "already joined", skip the respawn, and block every
228+
task that depends on that agent.
229+
230+
#### ✅ Correct pattern: check team.members
231+
232+
```bash
233+
# `team.members` is backed by the spawn registry + is_agent_alive() — dead or
234+
# never-joined agents are NOT listed here.
235+
MEMBERS=$(clawteam --json team status dev-team | jq -r '.members[].name')
236+
237+
if ! grep -qw "db-designer" <<< "$MEMBERS"; then
238+
clawteam spawn tmux claude --team dev-team --agent-name db-designer \
239+
--task "Design user schema"
240+
fi
241+
```
242+
243+
**Rule of thumb:**
244+
245+
| Signal | Answers |
246+
|--------|---------|
247+
| `task.owner` | "Who *should* do this?" (declarative, write-once at create time) |
248+
| `team.members` | "Who *is actually here*?" (live, backed by spawn registry) |
249+
250+
Only `team.members` is a reliable existence check in coordination loops.

skills/clawteam/references/workflows.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,46 @@ clawteam --json board overview | jq '.[] | "\(.name): \(.pendingMessages) pendin
205205
# Get team member names
206206
clawteam --json team status dev-team | jq -r '.members[].name'
207207
```
208+
209+
### Checking If an Agent Has Joined
210+
211+
When a leader agent spawns a worker and then polls to confirm it joined, the
212+
correct signal is the team's `members` list — **not** a task's `owner` field.
213+
214+
#### ❌ Anti-pattern: relying on task.owner
215+
216+
```bash
217+
# WRONG — task.owner is declarative, set at task-create time regardless of spawn outcome
218+
OWNER=$(clawteam --json task get dev-team "$task_id" | jq -r '.owner')
219+
if [[ -n "$OWNER" ]]; then
220+
echo "Agent joined" # false positive: owner is set even when spawn failed
221+
fi
222+
```
223+
224+
A task's `owner` is written when the task is **created** (via `-o`). It declares
225+
"who *should* do this work", not "who *actually joined the team*". A failed
226+
`clawteam spawn` leaves the task's owner untouched, so monitor loops that poll
227+
`task.owner` falsely see "already joined", skip the respawn, and block every
228+
task that depends on that agent.
229+
230+
#### ✅ Correct pattern: check team.members
231+
232+
```bash
233+
# `team.members` is backed by the spawn registry + is_agent_alive() — dead or
234+
# never-joined agents are NOT listed here.
235+
MEMBERS=$(clawteam --json team status dev-team | jq -r '.members[].name')
236+
237+
if ! grep -qw "db-designer" <<< "$MEMBERS"; then
238+
clawteam spawn tmux claude --team dev-team --agent-name db-designer \
239+
--task "Design user schema"
240+
fi
241+
```
242+
243+
**Rule of thumb:**
244+
245+
| Signal | Answers |
246+
|--------|---------|
247+
| `task.owner` | "Who *should* do this?" (declarative, write-once at create time) |
248+
| `team.members` | "Who *is actually here*?" (live, backed by spawn registry) |
249+
250+
Only `team.members` is a reliable existence check in coordination loops.

0 commit comments

Comments
 (0)