loc bengaluru, ist | local --:-- srijanshukla18@gmail.com →
[post]/tech/nfs-to-git-agent-bus

syncing two AI agents across machines with Git instead of a shared mount

/ 4 min read· ai

A shared mount looked like the cleanest way to make two agent instances talk across machines. A 30 minute directory cache made it unreliable, so Git became the bus instead.

I have two separate agent instances running on two different machines. I wanted them to stay in sync with each other - not real-time chat, just low-frequency operational sync:

  • pass task notes back and forth
  • keep my USER.md preferences/profile synced across both machines
  • sync my custom skills folder
  • without standing up Redis, Kafka, or some custom message broker

(And before anyone asks “why not ACP?” - ACP is for local editor-to-agent IPC on one machine, it doesn’t do cross-machine state sync.)

Since I already had an S3 bucket mounted on both machines via rclone mount (from my S3 on macOS setup), my first thought was: hey, both machines already see this folder, let’s just use a shared directory as a file-based message bus!

bus/
  inbox-a/
  inbox-b/
  archive-a/
  archive-b/
  PROTOCOL.txt

Super simple protocol:

  • Machine A drops a JSON file into inbox-b/
  • Machine B reads inbox-b/, does the work, and moves the JSON file to archive-b/

Looked great on paper.

Why the shared mount failed

Remember that --dir-cache-time 30m flag I put on my rclone mount so Finder wouldn’t lag? Yeah, that came back to bite me here.

Because it’s an object-store mount with directory caching (not a real POSIX filesystem), I kept hitting this exact sequence:

  1. Machine A writes a message into inbox-b/
  2. Machine B runs ls inbox-b/ and sees an empty folder
  3. I check S3 directly - the file is 100% there
  4. Machine B still thinks the folder is empty because its local FUSE directory cache hasn’t expired yet

Even though my sync job only ran everyfew hours, a 30-minute stale directory cache meant you could never trust ls. Did the other agent not send an ack yet, or is FUSE lying to me?

I briefly thought about setting up a proper NFS share over Tailscale or AWS EFS, and immediately decided against it. Who wants to babysit stuck NFS mounts across laptops that sleep and wake up on different Wi-Fi networks?

The fix: just use Git as the bus

Switched the whole thing from a mounted folder to a tiny private Git repo:

bus-repo/
  inbox-a/
  inbox-b/
  archive-a/
  archive-b/
  user-sync/
    USER.md
  README.md

Now the agent cron job does this:

  1. git pull
  2. Read everything in its inbox
  3. Move processed messages to archive/
  4. git add -A && git commit && git push
  5. Write any outbound messages to the other agent’s inbox
  6. git add -A && git commit && git push

Also kept two separate repos so things stay clean:

  • skills repo -> actual SKILL.md files and scripts
  • bus repo -> inbox/archive JSON messages (pull-skills, ack, profile-updated, heartbeat) + USER.md

Merging USER.md with the model instead of git merge

One nice trick for USER.md: since both agents can learn new preferences about me independently, a standard line-by-line git merge on prose notes is annoying and creates dumb merge conflicts.

Instead, when USER.md changes, the sync job does an in-model merge:

  1. Read remote USER.md and local USER.md
  2. Combine the facts and deduplicate
  3. Write out the clean merged USER.md and commit

Why Git works way better here

With the FUSE mount, everything was guesswork - is the file actually written? Is the directory listing cached?

With Git, if git pull succeeded, you have the exact state of the bus at that commit SHA, plus a full git log audit trail of when every message was sent and archived. For low-frequency sync between agents across machines, git pull / git push beats a shared network mount every time.