Two subagents edit overlapping files and overwrite each other. What is the best fix?
Why D is the answer
Run them one after the other, or give each its own files
Parallel work is only safe when the parts are independent. Split the work or run it in sequence. Subagents cannot see each other's context.
In detail
- Parallel work is safe only when the pieces are independent.
- Subagents cannot see each other's context, so neither knows what the other changed.
- Run them in sequence, or give each one a separate set of files.
- Plan who owns which files before you start parallel work.
Use case
An illustrative scenario, not a real incident.
Two subagents update the same configuration file in parallel, and one overwrites the other. Giving one the API files and the other the tests lets both finish cleanly. Shared files are edited one after the other.
See it in different ways
sequenceDiagram participant C as Coordinator participant S as Subagent C->>S: Task text, with everything it needs S->>S: Reads, searches and thinks in its own context S-->>C: Final summary only
flowchart TD
Q{"Do the tasks touch the same files?"}
Q -->|"No"| A0["Run in parallel"]
Q -->|"Yes"| A1["Run one after the other, or split the files"]Key point: Run in parallel only when the work does not overlap.
Why the other options are wrong
- A. Give both subagents the same system prompt so that they agree on their edits
- A shared prompt does not share what each subagent is doing right now.
- B. Raise the turn limit on both so that they have time to resolve the conflicts
- More turns give them more chances to overwrite each other.
- C. Ask both subagents to be careful about changes made by other subagents
- They cannot see each other's changes, so being careful does not help.

