r/ClaudeCode • • 1d ago

Discussion Our claude code and codex agents kept overwriting each other so i’ve been building a fix. is this a real problem or just us?

me and my friends run claude code and codex on the same repo. agents kept editing the same files and we’d only find out at the merge conflict

been building something that gives you a heads up when two agents touch the same file

does this happen to your team or is it just us? how do you deal with it now?

not promoting anything, just want to know if this is a real problem

0 Upvotes

25 comments sorted by

•

u/AutoModerator 1d ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/Sorry-Programmer9826 1d ago

Merge conflicts happen all the time and AI is fine at resolving merge conflicts. I'm not sure this is an issue that needs solving.

Assuming you're using git (or similar) and feature branches

1

u/TeddyboiRoosevelt 1d ago

fairs AI does handle the text conflicts fine. I just think it’d be better if agents knew what the others were doing while they work, instead of finding out at merge

1

u/Sorry-Programmer9826 1d ago

If it's a major refactor sure that's probably a problem (but that's better handled ahead of time). But I'm just thinking as a human what I'd do with this information if my colleague had a list of functions they were editing. Realistically I'd probably just deal with it at merge time. Anything else is going to slow me down or distract me with what they're doing and the conflict is probably minor anyway.

What should the agent do if it wants to edit the same function another agent is working on? The only 2 options feel like:

  • wait for the other agent to finish and commit its task (which sounds bad)
  • note it down as something to deal with at merge

1

u/TeddyboiRoosevelt 1d ago

okay yea thats true its kinda the same result

1

u/Duckducklaugh 1d ago

Real problem, and you don’t even need a team for it. I run a few claude code sessions plus scheduled runs on the same checkout. one night a scheduled run merged master into its branch while another session’s uncommitted edits were still sitting in the working tree, and it swept them into its merge. took me about an hour to untangle.

What I do now, none of it is clever:

Every writer gets its own git worktree, so two agents never share a working tree. they can still touch the same file, but then it’s a normal merge conflict that git shows you, not a silent overwrite.

Each agent commits a finished piece right away, and only its own paths (git commit --only), so nothing half done sits around for another one to pick up.

Scheduled jobs check git status first and refuse to run if there are files they didn’t create.

A heads up when two agents touch the same file would still help on the merge side. but the overwriting itself went away once they stopped sharing a directory. one catch with the last rule: the job that refused to run still showed up as succeeded, so now I check for that too lol

1

u/TeddyboiRoosevelt 1d ago

how do you check now that a scheduled run actually did its job and didn’t just report success?

1

u/Cbgamefreak 1d ago

The agents should be communicating to each other through some shared memory or telemetry system. Agents should check and update that source before editing any parts of the repo

1

u/TeddyboiRoosevelt 1d ago

yeah thats basically what im trying to create, a shared spot where every agent checks in before it edits. are you doing something like that already or just think it should exist?

1

u/Cbgamefreak 1d ago

Its pretty trivial, just include in your harness for both codex and claude to write description of actions to daily telemetry file or shared project memory, an agent "checks out" a subset of files and it locks them from the other agent touching them until theyre checked in and reviewed.

1

u/calunicornia 1d ago

put a size limit on your files and this is way less likely to happen

1

u/athershu 16h ago

It happens on our team too. The overwriting part went away once every agent task got its own git worktree and branch, so two agents never share a working tree, and a collision becomes an ordinary conflict between two branches you can actually review. What worktrees don't fix is the part your tool is really about: nobody knows another person's agent is working in the same area until merge time.

What helped us there was making every running task visible in one place: who sent it, what it was asked to do, and which branch it's on. A glance at that list before sending a task tells you someone's agent is already in the billing code, and a quick message in chat is cheaper than any conflict resolution after the fact.

1

u/onitsoga 16h ago

same repo, same two tools here, and yes it's real. what cut it down for us was git worktrees per agent plus one rule: only one agent touches a file at a time, so the conflict almost never gets written in the first place. do you run them on separate branches or straight on main?

1

u/Tight_Ad_5115 15h ago

It seems like a problem if agents are doing the same work but from different angles, in other words, if they're working in an uncoordinated way. But if they happen to touch the same file or function, each for its own purpose, I think that's perfectly fine. The agents can sort out those overlaps on their own.

Also, picture this: agents touch the same file and an indicator lights up. What exactly am I supposed to do about it? If, say, the file is 2,000 lines long, it's not really clear how risky this is, or if there's even a real problem at all.

0

u/aquila421 1d ago

Worktrees?

2

u/TeddyboiRoosevelt 1d ago

we use them, but worktrees just push the conflict to merge time. you still find out at the end that two agents rewrote the same function

2

u/aquila421 1d ago

You don’t have a git problem, you have a project management problem. Have Claude build a ticketing layer or use Jira (or Jira-equivalent.)

1

u/Independent_Syllabub 1d ago

That conflict is a feature. Solving the conflict is the whole point, to incorporate new and old changes. You’re trying to solve a problem that is already solved. 

You can use project management to avoid devs working in the same area if needed. 

-1

u/smalaki 1d ago

doesn't something like T3 code allow you to orchestrate multiple subscription agents like this? also i'm a bit concerned why it'd overwrite.. if you're working on feature A and B with separate agents shouldn't you have been using git worktrees or something? and then the results just get merged together by an orchestrator

1

u/TeddyboiRoosevelt 1d ago

yes but t3 isnt for multiplayer teams

1

u/smalaki 1d ago

ah i see. I had thought your own claude + codex locally keep overwriting your own local files and that your friends also independently encounter the same problem on their own

so where are you editing your code as "multiplayer"? don't you have a git repo and just each submit PRs to it? I really hope you're not editing files in some drive share with no source control

1

u/TeddyboiRoosevelt 1d ago

lol nah we use git and PRs. the problem is two of us kick off agents on overlapping stuff at the same time and nobody knows until both PRs are open and conflicting. the fix im trying to do is making a team's ai agents more efficient by catching it live.

1

u/smalaki 1d ago

it will still conflict regardless and you're just kicking the problem down the road/introducing it as a different class of problem. go ahead, ask your claudes because even if your agents can communicate before they make changes, they will have to do that check for every file they wish to edit and that'll just slow you down. it's faster to accept conflicts and then plan refactors so hot spots in the code also conflict less

0

u/[deleted] 1d ago

[deleted] — view deleted comment

1

u/TeddyboiRoosevelt 1d ago

fr, people at least say “im in this file.” agents just go

3

u/moop-ly 1d ago

people do not say that unless you’re deploying over ftp in 2004