[BUG] Agent Teams: auto-suffixed duplicate-name teammates all claim same owner-matched task, causing duplicate work and file overwrites
[BUG] Agent Teams: auto-suffixed duplicate-name teammates all claim same owner-matched task, causing duplicate work and file overwrites
Summary
When spawning multiple teammates with the same name, the system auto-suffixes them (Writer, Writer-2, Writer-3). However, all clones match tasks assigned to the base name "Writer" via the owner field and independently complete the same task. When the task instructs writing to a specific file path, agents overwrite each other's output, causing data loss.
Environment
- Claude Code version: 2.1.34
- Platform: macOS (Darwin 25.2.0)
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
Steps to Reproduce
- Create a team and a single task that instructs the agent to write its name and a timestamp to a specific file:
TeamCreate({ team_name: "test" })
TaskCreate({
subject: "Write your name to output.md",
description: "Read /path/to/output.md. If it exists, use Edit to append. If not, use Write to create. Write: '- Written by [YOUR_NAME] at [current UTC time]'"
})
TaskUpdate({ taskId: "1", owner: "Writer" })
- Spawn 3 teammates all named "Writer":
Task({ name: "Writer", team_name: "test", prompt: "Check TaskList, find your task, follow the instructions" })
Task({ name: "Writer", team_name: "test", prompt: "..." })
Task({ name: "Writer", team_name: "test", prompt: "..." })
System auto-suffixes to Writer, Writer-2, Writer-3.
- All 3 agents see the task owned by "Writer", treat it as theirs, and independently complete it — writing to the same file.
Expected Behavior
- Only the agent whose name exactly matches the
ownerfield should claim the task (Writer, not Writer-2 or Writer-3) - OR task status should be locked so that once one agent sets it to
in_progress, others skip it
Actual Behavior
Two issues:
1. All clones claim the same task. Despite having distinct names (Writer, Writer-2, Writer-3), all match the owner "Writer" and independently complete the task.
2. Concurrent writes to the same file cause data loss. All agents initially read the file as non-existent (since it doesn't exist yet), so all correctly decide to use Write (create). There is no conflict handling built in.
Timestamped results (runs 3 and 4 shown for conciseness, 4 runs total)
Run 3:
| Agent | Start | Write time | Tool used | Outcome |
|-------|-------|-----------|-----------|---------|
| Writer | 08:01:01 | 08:01:18 | Write | Lost — overwritten by Writer-3 |
| Writer-3 | 08:01:02 | 08:01:20 | Write | Survived |
| Writer-2 | 08:01:04 | 08:01:20 | Edit | Survived (re-read file before writing) |
Final file: 2/3 lines. Writer's entry lost.
Run 4:
| Agent | Start | Write time | Tool used | Outcome |
|-------|-------|-----------|-----------|---------|
| Writer | 08:02:40 | 08:02:52 | Write | Lost — overwritten by Writer-2 |
| Writer-2 | 08:02:41 | 08:02:53 | Write | Lost — overwritten by Writer-3 |
| Writer-3 | 08:02:43 | 08:02:54 | Write | Survived — last writer wins |
Final file: 1/3 lines. Writer and Writer-2 entries lost. Writer-2 even detected the race: "I wrote my line but Writer-3 appears to have overwritten the file at nearly the same time."
Summary across 4 runs
| Run | Lines surviving | Data lost |
|-----|:-:|:--|
| 1 | 3/3 | None (all happened to re-read and append) |
| 2 | 1/3 | Writer + Writer-3 entries lost |
| 3 | 2/3 | Writer entry lost |
| 4 | 1/3 | Writer + Writer-2 entries lost |
Root Cause
Task owner matching is prefix-based, not exact. Writer-2 and Writer-3 both match tasks owned by "Writer" because the owner check appears to match the base name prefix rather than the full agent name. Once multiple agents match the same task, there is no locking to prevent them from all working on it concurrently.
Additional Notes
- Agents are aware of their suffixed names (Writer-2 self-identifies as "Writer-2", Writer-3 as "Writer-3" in their output)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗