QA Interview Hub · Knowledge base · Quizzes · Українська

Product Engineering › Orchestrating agents

Merging the results of parallel agents and resolving conflicts

Merge parallel agents' results one at a time and run the tests after each merge. Git sees only textual conflicts, while a semantic one (a renamed function and a new call to the old name) shows up only in tests. Reduce conflicts in advance: one owner per file, shared places with one executor, the contract in both briefs. Constant conflicts mean dependent parts, so re-split the work.

Agentic development · Orchestration

Two agent branches are green separately. After the merge CI is red. Where do you look?

Parallel agents returned two branches. The first renamed the function getUser to fetchUser, the second added a new getUser call in another file. Git merged them with no conflicts because the lines do not overlap. Each branch is green on its own. Together the code does not build. Parallel agents return separate edits and they must be combined into one working change. How to separate files between agents is in the article on the brief and isolation. Here: what to do with the results.

How it works and why. Git checks whether the same lines were changed, not whether behaviour is consistent. So conflicts come in two kinds. A textual one is visible at once: both branches changed the same place. A semantic one git does not see: each branch is green alone and together they fail. Examples: two agents added a migration with the same number, renamed a function that another's code calls, used different formats of one field, added the same test identifiers. So checking the branches alone is not enough.

Two kinds of conflict

Textual

Git shows it at once

Both branches changed the same place. Visible during the merge, resolved by hand or by an agent.

Semantic

Git is silent

Branches merged cleanly but break together: a rename, a migration number, a field format. Visible only through tests.

Figure 1. The more dangerous one is the one invisible during the merge.

Prevention beats cure.

  • split the work so that each file has one owner;
  • give shared places (a route registry, a dependency lock file, a catalogue of test identifiers, generated files) to one executor or leave them to the main session at the end;
  • if one part depends on another, agree on the contract first (field names, formats, signatures) and write it into both briefs.

Merge order.

  1. Merge one branch at a time, starting from the smallest or the one the others depend on.
  2. Before each merge bring the branch up to the current base.
  3. After each merge run the tests, not only at the end: then you see which exact change broke the integration.
  4. Regenerate generated files with the command instead of merging them by hand.
  5. At the end a full run in a clean environment.

Example: finding who broke it. After merging two branches the build fails. If both were merged together with a single run, you would have to guess. Step by step:

git switch main
git merge agent/rename-user        # green run
npm run build && npm test          # ok

git merge agent/new-endpoint
npm run build                      # error: getUser does not exist

Now it is clear what broke at the second merge: the new endpoint branch calls the old name. The fix is small (update the call) and the cause became visible. If results contradict in behaviour (different interpretations of a requirement), that is a question for a human: what is right is being decided here, not how to merge text.

Who resolves conflicts. A simple textual conflict can be handled by the main session or by one agent given both briefs and a final criterion. A semantic one is found by tests after each merge. Behavioural disputes go to a human.

Checking reports. Each agent's report is compared with its diff: did it touch files outside its limits, did it remove tests. Reports of "all passed" are verified by what the main session runs, not repeated.

Merge order

1. Branch on a fresh baserebase or merge main2. Merge one branchfrom the smaller to the dependent3. Build and testsafter every merge4. Repeat for the nexta failure shows on a specific branch5. A full runa clean environment, the full suite
Figure 2. A test after each merge answers "which branch broke it".

Limits and alternatives. If conflicts occur every time, the parts were dependent. Then re-split the work or run it sequentially instead of perfecting the merge. For branches that touch only different directories the ordinary order is enough. For dependent changes a stack of branches is more convenient, where each builds on the previous one and merging goes from the bottom up.

Common mistakes.

  • Checking only separate branches: a semantic conflict is invisible until they are joined.
  • Merging everything at once and running tests once: the failure cannot be tied to a branch.
  • Merging generated files by hand: the result differs from what the command would give.
  • Letting agents resolve contradictory requirements: that is a human decision.

Check yourself

Two agent branches merged without conflicts but the build failed. Why did git not warn and how do you find the cause?

Answer

Git compares changed lines, not code consistency, so a semantic conflict (a renamed function and a new call of the old name) stays unnoticed. The cause is found by merging one branch at a time and running the build and tests after each.

Conflicts in parallel agent branches repeat every time. What does it mean and what do you change?

Answer

The parts of the work were dependent. Change the split (each file has an owner, shared places go to one executor) or run the work sequentially instead of improving the merge process.

In an interview. Junior: I merge parallel branches one at a time and run tests after each merge. I compare an agent's report with its diff. Middle/Senior: I distinguish a textual conflict, which git sees, from a semantic one, visible only through tests. I reduce them in advance: file owners, shared files with one executor, a contract in the briefs. If conflicts are constant, that signals a wrong split and I re-split or run sequentially. A contradiction of requirements is decided by a human, not by agents.

More articles in this chapter