How Do I Stop Two AI Agents From Doing the Same Work?
Stop multiple AI agents from duplicating work: a shared action log they check before starting, pending entries that show work in progress, and rules in AGENTS.md.
Reviewed by WaveBrain Operations TeamReviewed 5 min read
The short answer
To stop two AI agents from doing the same work, give them a shared record of what has already been done and tell them to read it before they start. With WaveBrain, agents log each action, check recent actions for the project before starting, and log long tasks as pending when they start so others can see them in progress. Put those rules in AGENTS.md so every agent follows them.
You ask Claude Code on your laptop to write release notes for version 2.4 and post them to the changelog. An hour later your Hermes bot on the server, running its daily routine, notices the new tag and does the same thing. Now the changelog has two entries for 2.4, written in slightly different words, and a subscriber email went out for each.
Neither agent did anything wrong. Each one started with a fresh context and had no way to know the other had already finished the job. The fix is to give them a shared memory of finished and in-progress work, and a habit of checking it.
How do I stop two AI agents from doing the same work?#
Make every agent write what it did to one shared log, and make every agent read that log before starting a task. WaveBrain is built for this. Agents call log_action after each action with external effects, and they call list_recent_actions or list_actions before starting to see whether the work is already done or underway.
Three habits cover most cases:
- Check recent actions for the project before starting a task.
- Log the outcome with a clear past-tense title, the project and a link.
Why do AI agents duplicate each other's work?#
Each agent session starts without knowledge of other sessions. Claude Code, Codex, Cursor and Hermes all keep their own history on their own machine, so an agent on a server can't see what an agent on your laptop did an hour ago. Scheduled agents make this worse, because a routine that runs every morning will repeat work a person or another agent already did unless something tells it otherwise.
In coding work this shows up as the same feature built twice, overlapping pull requests and merge conflicts. For agents doing operations work the cost is more visible, as with duplicate emails, two posts, or the same ad budget change applied twice.
How does checking the action log before starting help?#
It turns "has someone already done this?" into one tool call. WaveBrain's MCP server offers two read tools. list_recent_actions returns one page of the newest actions and can be filtered by project or agent, with up to 100 results. list_actions returns actions newest first with cursor pagination through next_cursor, and can be filtered by agent, session, and a since and until time range.
A Hermes bot about to write release notes can call list_recent_actions with project: "northwind/web", see "Published release notes for v2.4 to the changelog" logged by claude-code-laptop 50 minutes earlier, and skip the task. Reads only return actions inside your plan's history window, which is 7 days on the Free plan, so a weekly routine still sees last week's run.
What should I put in AGENTS.md to stop duplicate work?#
Put the logging rules and a check-first rule in the instructions file every agent reads. AGENTS.md is an open format that the agents.md site describes as "a README for agents", and it lists Codex, Cursor, Jules, Aider, VS Code and many other tools that read it. For Claude Code use CLAUDE.md, and for Hermes the profile's SOUL.md or system prompt.
The WaveBrain Setup page offers this block:
## WaveBrain
After any externally visible action (sending an invoice or email, handling a customer
request, publishing content, finalizing a document, updating a business system,
deploying, or pushing or merging code), call the WaveBrain `log_action` tool with a
short past-tense title, details of what changed and the result, the project, and a link.
Log the outcome someone would care about, not each low-level step behind it.
To see what agents already did, call `list_actions` (newest first; pass `next_cursor` back for older pages).
To make the check explicit, add a line of your own below it, such as: "Before starting a task that sends, publishes or deploys anything, call list_recent_actions for the project and skip the task if a matching action succeeded in the last 24 hours." Agents follow concrete rules with a time window more reliably than a vague "avoid duplicates".
How does an agent show it is mid-task?#
For a long action, an agent can log it with status: "pending" when it starts and log the result when it finishes. A pending entry is a signal for other agents, though, and nothing enforces it. WaveBrain doesn't lock tasks, so two agents that check the log at the same second can still both start.
Does a shared log replace git worktrees or task locks?#
No, and for coding agents you usually want both. Git worktrees, per the git docs, let one repository have multiple working trees so you can check out more than one branch at a time, which keeps parallel coding agents from editing the same files. A task queue or lock is what guarantees one owner per task. WaveBrain answers a different question, which is what has already happened and who did it, across every agent and machine.
| Method | What it prevents | Works across machines | Covers non-code work (emails, posts) |
|---|---|---|---|
| Shared action log (WaveBrain) | Repeating work that is done or in progress | Yes | Yes |
| Git worktrees or branches | Two agents editing the same files | No, per repository clone | No |
| Task queue or lock | Two agents claiming the same task | Depends on the setup | Depends on the setup |
| Rules in AGENTS.md | Agents skipping the check | Yes, if every agent reads the file | Yes |
Consistent project names matter for all of this. If one agent logs to northwind/web and another to Northwind Website, the check-first rule misses the match. Pick the names once and put them in AGENTS.md. The guide to tracking agents across machines has a naming table you can copy.
If you run more than one agent and want them to see each other's work, try WaveBrain free. Setup takes a few minutes per agent, and the how it works section shows the flow.
Frequently asked questions#
Can WaveBrain lock a task so only one agent runs it?#
No. WaveBrain records what agents report and lets them read it back, but it doesn't enforce ownership. Use a task queue or lock if you need a guarantee.
Which tool should an agent call before starting work?#
list_recent_actions filtered by project is the quickest check. Use list_actions with since when you need older pages or a specific time range.
Do agents read the log automatically?#
Only if their instructions tell them to. Add the check-first rule to AGENTS.md, CLAUDE.md or the system prompt so every agent runs it.
Can scripts check the log before running?#
Not over REST, because there is no REST read endpoint. Scripts can log with REST, and reading history happens through the MCP tools or the dashboard.
How far back can an agent look?#
As far as your plan's history window, which is 7 days on the Free plan. Pro, which is coming, keeps 90 days.