◉ANTIGRAVITY LABJP
Articles/Agents & Manager
◈ Agents & Manager/2026-07-24Advanced

Leasing Runtime Environments to Parallel Agents: Port Ranges, DB Schemas, and Dev Servers, One Per Agent

When Antigravity 2.0 runs agents truly in parallel, they collide on the same port, database, and dev server. Here is a lease-based design that hands each agent its own isolated environment, with implementation and measured numbers.

Antigravity394Parallel AgentsEnvironment IsolationDesign Patterns5PostgreSQL

✦ Premium Article

I once handed three agents three different parts of the same Next.js app at the same time.

One took the UI components, one took the API routes, one took a schema migration. Run them in parallel on the Antigravity 2.0 desktop and, on paper, that is three times faster.

It went the other way. All three tried to grab localhost:3000 and threw EADDRINUSE in a loop. The migrations fought over the same database and stalled on locks. One agent's test wiped the seed data another agent depended on. Measured against the wall clock, the parallel run came out about 1.4x slower than doing the work serially. Parallelism that made things slower — an odd sight.

The cause was not compute. It was shared, stateful side effects: the port, the dev server, the database, the migration, the file watcher. There is only one of each, and three agents reached for them at once. True parallel execution surfaces every single-instance resource without mercy.

This article lays out the answer I arrived at while running several personal apps side by side as an indie developer: lease one runtime environment to each agent, with the implementation to back it.

What "parallelism that isn't faster" actually is

Parallel-agent failures nearly always land in one of four layers.

LayerWhat collidesSymptom
NetworkMultiple dev servers fight for one portEADDRINUSE :::3000
DatabaseSame tables/rows rewritten; migrations raceLock waits, deadlocks, data loss
FilesystemConcurrent writes to lockfiles, build output, cacheCorrupt pnpm-lock.yaml, half-built artifacts
OS resourcesinotify watches and file descriptors exhaustedENOSPC (watch limit), unresponsive HMR

The shared structure is always "several actors touch a single-instance resource with no arbitration." When one human develops alone, this never surfaces, because you don't start two dev servers at once. The moment agents go parallel, that hidden assumption breaks.

So the fix is not to make the agents smarter. It is to split the environment: give each agent one runtime that overlaps with no other. That is the idea behind a lease.

What a lease actually hands over

A lease is a bundle of non-overlapping resources loaned to an agent for a while. As a minimum, I fold five things into a single lease.

ResourceHow it's assignedCollision it removes
Port rangeDeterministic offset from the agent indexContention over dev server, API, DB proxy
DB schemaA dedicated schema cloned from a templateRow corruption, migration races
Working directoryA separate git worktreeFile, lockfile, and artifact clashes
Env fileAn .env.agent written with the lease valuesMixed-up configuration
Lease IDA unique key that anchors reclamationResource leaks after a crash

The key is deriving all of this deterministically from the agent index. Grabbing a random free port looks clever, but for reasons below it is harder to operate in parallel.

✦

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
✦An allocator that leases a dedicated port range, DB schema, and dev server to each agent, including how the lease is reclaimed
✦Why schema-per-agent provisions faster than database-per-agent (about 80ms vs 900ms), and how to skip migrations by cloning a pre-migrated template
✦The counter-intuitive reason a deterministic port beats a random free port in parallel operation
✦A wall-clock comparison of the same three tasks run serially, naively in parallel, and with leases (18m 40s / 26m 10s / 8m 05s), and how to read where the returns flatten
✦What LIKE INCLUDING ALL quietly drops (foreign keys are not copied, and serial defaults keep pointing at the template sequence), plus the SQL that verifies a clone by constraint count
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 $10 for lifetime access
View Membership →

Related Articles

◈ Agents & Manager2026-10-16
Before Handing an Agent a .zip: Dropping .git Cut 29 MB to 15 MB, and 28 Secret Warnings Turned Out to Be Noise
Antigravity app v2.23.0 lets you attach a .zip. I packed my own repository to count what .git weighs and how many secret-scan warnings are false alarms, and I leave the full Python script that excludes, scans, and writes a manifest.
◈ Agents & Manager2026-10-14
When the App Reads an API Response by Position, I Put a Gate in Front of the Upload So Shipped Versions Don't Crash at Launch
A client that reads a server list by index, as a wallpaper app does, leaves old shipped versions in the wild for a long time. Deleting or reordering a field can crash them at launch. This note shows an append-only check and a hash ledger that freezes shipped version directories, with the output from actually running them.
◈ Agents & Manager2026-10-14
I Expected Agent PRs to Wait Longer Than Human PRs, but 246 Public Pull Requests Showed the Opposite
A count of 246 July-August 2026 PRs in dotnet/runtime, comparing time to the first human reaction on agent-opened PRs and human-opened PRs. Includes the measurement script and a stale-PR check for solo projects.