How to Prevent Coding Agents From Duplicating Work
A developer on a team using Claude Code, Cursor and Codex found that one agent had spent 40 minutes solving a problem another agent had solved the day before. The second session hadn't seen that earlier result.
Two agents can work on separate branches and arrive at the same answer. Git tracks changes to files, so a clean merge may give the reviewer no warning that both sessions did the same job.
To prevent coding agents from duplicating work, make the intended outcome and its owner visible before starting a task. When work moves to another session, send the existing result and say what remains to be done. The next agent starts with what's done and works on the gap.
It happens when you open a fresh session and ask it to look into a problem the team discussed yesterday. You may remember the topic without knowing an agent already found an answer. The new session won't know either unless someone brings that result along.

Two clean branches can solve the same problem
Each worktree gives an agent its own working copy. Separate working copies keep uncommitted changes apart when agents edit at the same time. They don't show whether another agent has already started the feature.
A merge conflict exposes overlapping file changes. Two agents pursuing the same outcome may produce a clean merge. The result is sometimes two helpers for the same calculation. Both can pass their tests.
Our guide to multiple AI agents editing the same repository covers shared interfaces and merge order. Duplicate tasks start before either branch is ready to merge.
Compare the outcome before assigning another task
Task titles can mislead. “Billing totals” and “invoice summary” sound different until both descriptions point to the same screen and calculation. We'd compare the expected result instead. What changes for the user, and what will the agent hand back?
We want a task record to show the outcome and its owner, with the current state and a link to the work. A short sentence about what is outside that task helps when two requests are close. We'd start with the goal before listing files. Files may change as the agent investigates. The goal gives the person assigning the next task a steadier point of comparison.
The shared list also needs a way to handle simultaneous claims. In Claude Code agent teams, the lead and teammates use a shared task list, and the documented claim operation uses file locking to prevent two teammates claiming the same task at once. The lock covers that team's task list. A separate Cursor or Codex session needs another place to find the assignment.
A claim isn't the same as a finished result. When an agent stops or gets blocked, the record should say so and point to what it left behind. Otherwise another agent sees an owner and has no way to tell whether the work is still moving.
Make the earlier decision findable
In one public repository test, coding agents created a design-system file, but two omitted its entry from the document list later agents were expected to read. The file existed. Its list entry didn't.
We'd name the design decisions that apply to the interface change. A filename alone leaves the next agent to work out why it matters.
Reviews also record why a team set aside an earlier approach. We'd carry that reason forward when it affects the next job. Then the next agent knows why it was dropped and what evidence would change that decision.
For work that pauses between sessions, keeping context across coding agent sessions covers where to store the handoff and how to pick it up again.
Decide when overlap is useful
Sometimes two agents should investigate the same question. Independent reviews can catch different mistakes, and competing solutions can be worth comparing when the direction is genuinely uncertain. The difference is that someone chose the overlap and knows who will compare the results.
For routine implementation, we'd give one agent the change and the other a focused review. The reviewer might check whether the patch covers the reported failure. That gives the second agent a specific question to answer. Two complete fixes would leave someone comparing both patches and deciding which work to keep. A review finds gaps in the first patch without creating that extra choice.
Anthropic found a similar problem in its research system. A broad request about semiconductor shortages led two subagents to repeat searches about current supply chains, while another explored the earlier automotive shortage. The team improved delegation by specifying each subagent's objective and boundaries. Coding tasks need the same care when two briefs describe the same goal.
What to hand from one coding agent to another
The next tool doesn't automatically receive the original session's context. For a handoff between Claude Code, Cursor and Codex, we'd put the result somewhere the receiving session can read it. An issue, a pull request or a shared task file can hold the handoff.
Say Claude Code has prepared a patch and the next request goes to Codex for review. We'd start with a link to the commit and a short explanation of the change. The reviewer checks the reported failure against that patch.
The earlier session's test results inform that review. A failed check or an unresolved question belongs in the same handoff, so the reviewer knows what still needs attention. The full transcript can stay behind.

Before that review, Codex needs to be able to open the repository and branch. A link alone won't put the files in its reach. Then we'd ask it to describe what it found in the patch and what remains before it makes changes.
Keep the decision where people and agents can see it
We use Alook as a multi agent collaboration workspace where people and agents share conversations. Open the thread and the request, the agent's answer and the follow-up appear together. Whoever joins later can read the discussion behind the decision.
We make the next request explicit in that conversation, linking the current work and saying what needs checking. A bare “look into this” invites another round of the same research, even with the earlier discussion in view.
The developer's 40-minute repeat began with an answer in one session and another agent working without it. A link to the earlier result puts yesterday's answer in front of the second agent. The next 40 minutes could go to checking the fix or handling the part that remains.
FAQ
Do worktrees stop agents from duplicating work?
Worktrees separate working copies. The assignment still needs to distinguish each agent's goal, even when its files are isolated.
What if two agents claim a task at the same time?
Use an assignment mechanism that handles concurrent claims, or have one coordinator assign the work. A plain shared note depends on participants checking it before they start. It won't stop two agents from claiming the same task at the same moment.
Should two agents ever work on the same issue?
Yes. Independent reviews are one reason to revisit the same patch. The second agent has a separate question to answer, and someone compares its findings with the original work.
What should happen when an agent stops mid-task?
Update the status and link the current changes, checks and unresolved questions. The next agent can assess what remains before continuing.