How I Keep Parallel Agents From Colliding

  • AIAgents
  • ClaudeCode
  • Codex
  • DevSecOps
  • Homelab

Problem

I run Claude Code and Codex sessions across several projects. Each session can lose context when it ends. Two sessions can also change the same file while each believes it is working independently. I need a record of who is working, what they changed, and what the next session should pick up.

Two incidents made those requirements concrete. Two Claude sessions edited the same LiveCue files, and one overwrote the other’s practice-mode work. I merged the work back and stopped concurrent edits to the same files. In a separate session, a scan test ran in my homelab repository instead of a throwaway repository and staged 221 files. I used an index backup and a verified script to undo the staging.

Those incidents are my account of what happened. The controls I describe below address the collisions and test isolation; they do not prove every future session will follow the intended workflow.

First attempt

I started with a shared rulebook and Brain, my shared memory service. Claude Code and Codex can retrieve project context and leave handoffs. Hooks track context and plan usage, prompt a wrap-up near the limit, and keep the session open until a handoff is saved.

I also tried an existing agent view. During my use it showed only one active session. That made it hard to account for all the work I had running. The Command Center grew from that gap: I wanted a local registry I could inspect, along with candidates for project matches that I could review myself.

What I built

The file lease code tracks sessions and individual file claims. When a session claims a file, another session’s conflicting write is denied while the claim remains active. The lease code checks for a clean file after a grace period, an explicit release, an ended or inactive session, wrap-up, or an owner-authorized takeover. If Git cannot establish a file’s state, the code treats it as dirty rather than ending a claim on a guess.

That matters for the LiveCue failure. Two agents can work in the same repository on different files, while the gate has a specific file claim to check. A lease still depends on the gate receiving the relevant operation and identifying the affected file. I review the resulting changes and resolve any conflict that reaches me.

The Command Center records projects, sessions, checkpoints, tasks, and agent lifecycle events. Its documented dashboard is read-only and listens on loopback. Uncertain session-to-project matches remain candidates until I confirm or reject them. The registry can preserve an explicit checkpoint and produce a continuation prompt from recorded state.

Its command-line interface makes the workflow visible:

cc.cli candidates
cc.cli handoff PROJECT_ID
brain lease show

The candidate command lists matches for review, the handoff command generates continuation context for a project, and the lease command shows file claims. The Command Center README documents invocation through its isolated Python environment, so the exact launch command depends on the installation. These views are evidence to examine, not a guarantee that every active agent has registered itself.

The model side has an authenticated gateway in front of the local MLX and Ollama runtimes. Profiles limit which clients can reach a model and whether tools are available. The project record says model output never confirms, approves, or executes an action. I keep that approval boundary with the human operator.

How I check the boundaries

I check the lease view before assigning overlapping work. If a file is claimed, I coordinate a release or an explicit takeover before another session edits it. I check candidate matches before accepting them, then read the checkpoint or handoff rather than assuming a session label identifies the right project.

For repository tests, I use a temporary repository created with mktemp. The staged-files incident showed why a scan test needs a disposable target and why an index backup matters before recovery. I do not treat a successful test in a temporary repository as authorization to stage or change the working repository.

The dashboard and registry are useful for reviewing recorded state. The broader observability view, local-model orchestration, and security redesign are described as work in progress in my original post. I keep those planned pieces distinct from the current registry.

Comparison to existing tools

I tried an existing agent view first and saw only one of my active sessions. The Command Center provides my own registry and candidate review, but I have not established that it detects every agent or replaces a general observability platform.

I still use existing tools for model routing, dashboards, and telemetry where they fit. The custom pieces connect the information I need and preserve the approval and file-ownership boundaries I chose.

Lessons

A shared instruction is useful when it has a mechanism behind it. A lease gives the gate a file claim to check; an isolated test repository gives a scan somewhere safe to make changes. Both came from failures I had to recover from.

I also keep uncertainty visible. A session-to-project match stays a candidate until I review it. A handoff records the next step, while the registry records the work it has actually seen. That gives the next session a starting point I can inspect.

Back to posts