◉ANTIGRAVITY LABJP
Articles/Agents & Manager
◈ Agents & Manager/2026-05-01Advanced

When Parallel Antigravity Agents Fight Over the Same File — Preventing Conflicts and Surviving Real-World Race Conditions

Running Antigravity agents in parallel surfaces five concrete kinds of conflict and three classic race conditions. This guide walks through each one with reproducible failures and the locking, optimistic, and queue-based fixes I actually run in production.

antigravity461agents144concurrency3parallel-execution7conflict-resolution

✦ Premium Article

The first week I ran agents in parallel, I broke a build at midnight. Three Antigravity agents were each working on separate features. All three modified package.json. The last write erased what the other two had added — git history showed three clean PRs, but the actual package.json only carried one of the three new dependencies.

The real difficulty of running agents in parallel is that you can no longer trace, with the human eye, who touched what at which moment. This article is a structured account of the failures I hit while taking Antigravity parallelism seriously, organized by the kind of conflict, with reproductions and the fixes that hold up in production. If you are at the stage of believing "more agents will be faster," this is the moment to read it.

Five resources where parallel agents collide

After a week of operating in parallel, the conflicts converge onto roughly five hot spots:

  1. Writes to the same file — package.json, tsconfig.json, lockfiles, shared schemas.
  2. Commits to the same branch — when two or more agents diverge from the same parent, the late one falls into rebase hell.
  3. Shared caches and build artifacts — .next/, node_modules/.cache/, dist/ — one agent reads while another writes.
  4. External API rate limits — three agents calling Gemini or Stripe with the same key cascade into 429s.
  5. Working directories and tempfiles — /tmp/ collisions, log file appends, SQLite WAL contention.

The first thing to internalize: do not design for "conflicts might happen." Design for conflicts will happen. The probability scales with the number of agents and time. Even a one-percent collision rate, run a hundred times a day, will fail at least once.

A reproducible minimum: the package.json race

Let me show the most common failure shape in a form you can paste into Node and run. Two parallel "read-then-write" operations easily produce a state where the last writer erases the earlier one.

// reproduce/package-race.ts
import { readFile, writeFile } from "node:fs/promises";
 
async function addDep(name: string, version: string) {
  const pkg = JSON.parse(await readFile("package.json", "utf8"));
  pkg.dependencies = pkg.dependencies ?? {};
  pkg.dependencies[name] = version;
  // Pretend the agent is "thinking"
  await new Promise((r) => setTimeout(r, 200));
  await writeFile("package.json", JSON.stringify(pkg, null, 2) + "\n");
}
 
await Promise.all([
  addDep("zod", "^3.23.0"),
  addDep("date-fns", "^3.6.0"),
  addDep("nanoid", "^5.0.0"),
]);

Run it and only the last write survives. The reads overlapped, so each writer overwrote a stale snapshot.

Parallel agent execution is structurally identical to this code. The only difference is that the "thinking" phase is seconds or minutes, not 200 milliseconds. The longer window makes collisions more likely, not less.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦The five resources parallel agents collide over, and how to decide between pessimistic locks, optimistic locks, and queues for each
✦A worktree-based partitioning design where each agent declares its write scope and a script verifies it before push
✦How far v2.3.0 message queuing and v2.2.1 unified permissions actually go as conflict prevention
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Antigravity Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $15 for lifetime access
View Membership →

Related Articles

◈ Agents & Manager2026-09-04
Snapshot Your Agents' Effective Scope So You Notice the Day a Default Changes
Antigravity 1.1.25 made Markdown-defined custom agents inherit the surrounding skills, rules, and subagents by default. Here is the snapshot-and-diff routine I now use to check whether an agent I meant to keep narrow quietly got wider after an update.
◈ Agents & Manager2026-08-21
Why I Check Description Overlap Before Turning On inheritCustomizations
CLI 1.1.14 collapsed markdown agent inheritance into a single inheritCustomizations switch. Here is what happened when I actually inventoried the 47 skills in my workspace and decided the switch on description overlap rather than on context size.
◈ Agents & Manager2026-05-27
Record & Replay for Antigravity Agents
How to deterministically replay a failed Antigravity Agent run offline, drawn from a month of running it across four production sites. Covers boundary recording, R2 + KV storage costs, PII masking, and a working TypeScript harness.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links