跳到正文
DEV Community· Kent Alstad·· 3 小時前AI 評分51

Kent Alstad 分享以背景合併提早發現平行 Agent 分支衝突的做法

The most useful thing we built for parallel agents doesn't touch their context. It merges their branches before they do.

AI 導讀

Kent Alstad 為平行 Agent 建立 shadow merger,透過本地 git 在背景合併項目內所有開放分支,找出衝突並通知相關 worktree。同一 hook 亦會轉報其他 Agent 遇到的特定錯誤,並在編輯前提示其他即時工作階段是否正處理相同區域。首週合併前捕捉的問題數為 79;碰撞減少後,合併後修復是否下降仍未有定論。

正文

A short update from the series on evidence-based agentic development.

I run a lot of agents at once: several issues in flight, each in its own worktree, across six repositories, in more than one runtime, sometimes on more than one machine. Each agent sees only its own branch. They find out they collided when the second one tries to merge, or worse, after it has.

So we built a shadow merger. Whenever any agent's branch gets a new commit, it merges every open branch in the project together in the background, with local git only, and works out what collides: which files, which functions. When something changes, it queues a one-line notice for each affected worktree. The next time the agent there runs a command or edits a file, it gets the notice first:

your branch and #489 both change kandiforge-com/lib/search/docsSearchData.ts

It never blocks. It tells the agent while it can still do something about it.

Two more things ride on the same hook:

  • Failure relay. When one agent hits a specific failure, the next agent in the project about to run the same program hears about it within minutes: "another agent hit fatal: ambiguous argument 'origin/development' 3 minutes ago." It's the first time my agents learn from each other while they work, not after.
  • Live overlap. Before an edit, an agent learns that another live session, in any runtime, is working in the same area right now.

The count we keep is problems caught before merge: the shadow merger's notices plus the code watcher's findings on unmerged commits. Every week before these shipped, it was zero, because nothing looked. In the first week: 79. In mid-October it was tracking live overlaps such as two open branches in the same auth server file in one of our projects. Both agents already knew.

This is the opposite of what I expected a year ago. We spent most of our effort putting more knowledge into agents' context, and agents mostly ignored it. What works is watching the actual code and the actual work, and saying one specific, true thing at the moment it matters.

The outcome side, whether fixes after merge fall now that collisions are caught before, is still open: What survived has where it stands.


Talking about this at Build Stuff 2026

This is one of the write-ups behind my talk at Build Stuff in Vilnius this December, the 15th edition, under the theme The Age of Agency.

Control Your Fate at the Metal
Wednesday 2 December, 15:00, Zeta 2. 45 minutes.

If you're coming, say hello. If you're not yet, 2026SPEAKER_20 takes 20% off a ticket.

#BuildStuff15 #buildstuffconf #AgeOfAgency @buildstuffconf https://buildstuff.events

來源:DEV Community · dev.to