Learn
How do you keep two agents from doing the same task?
Let the agents take tasks from a shared list where only one agent can hold a task at a time. The agent that takes a task marks it as taken in the same step, and the next agent that tries gets a refusal and picks another task.
Last reviewed on .
How Claude Code does it
In Claude Code's agent teams, the work is coordinated through a shared task list. Tasks have three states: pending, in progress and completed.
According to the documentation, file locking is used when a task is claimed, to prevent several teammates from claiming the same task at the same time.
The documentation also covers file conflicts: two teammates editing the same file overwrite each other, and the work should be split so that each teammate owns its own files.
How AgentRoots does it
Tasks are changed with task_update and one of these actions:
- claim: takes the task. Only one session can hold the task.
- release: releases the task.
- block: marks the task as blocked, with a note on why.
- done: finishes the task.
- cancel: cancels the task.
A task can be reserved for a specific session when it is created, with the field to in task_create. The operation task_list shows open, claimed and blocked tasks, so that a session sees what others already hold.
Search before the work starts
Duplicate work also happens when something was already solved in an earlier session. In AgentRoots a session searches roots and nuggets with search before it solves something that may have been solved before.
Related questions
What is a coordinator agent?
A coordinator agent is an agent session that splits a piece of work into tasks, assigns them to other sessions and combines the results. In Claude Code's agent teams the role is called team lead. The working sessions each have their own context window and report back.
Read the answerHow do you get multiple Claude Code sessions to work together?
The sessions need to share tasks, messages and knowledge. Claude Code has its own features for this: subagents, which work within one session, and agent teams, where one session leads several others. Sessions that you start yourself in different projects or on different computers can be connected to a shared service over MCP.
Read the answer