Skip to main content
AdvancedCollaboration & OpsEst. Time: 30-60 min

Multi-Agent Collaboration & Parallel Workers

Coordinate multiple concurrent AI sessions across isolated git worktrees with kernel mutex fencing and zero collision.

The Problem

Running multiple AI agents concurrently on the same directory causes devastating file overwrites, conflicting git index states, and corrupted sessions.

Who It Is For

Advanced engineering teams dispatching multiple parallel AI agents for rapid feature delivery.

Prerequisites & Tools

Prerequisites Checklist:
  • Git repository
  • DevWorkflow 2.1+ with kernel mutex support
Tool / CommandTypeRole in Tutorial
start_taskmcpAcquires OS kernel mutex capability on target worktree
checkpoint_taskmcpSave progress checkpoint before context switch
handoff_taskmcpTransfer active task state to another machine or agent
resume_sessionmcpAdopt existing workflow state safely

Example Task Contract

Exact start_task payload representing this workflow in DevWorkflow local-first governance.

AI Tool Call: start_task payload
{
  "description": "Dispatch parallel worker to implement analytics pipeline in dedicated git worktree",
  "type": "feature",
  "plan": [
    "Create isolated worktree at ../worker-analytics",
    "Bind session to worktree and acquire process lock",
    "Implement data aggregation service and unit tests",
    "Commit changes and prepare PR for review"
  ],
  "definitionOfDone": [
    "Worktree runs without file collision with main tree",
    "Kernel mutex capability acquired and held during session",
    "Branch merged cleanly into main upon review"
  ]
}

Step-by-Step Tutorial Workflow

Follow these sequential actions with validated copyable commands and expected outputs.

1

Create Isolated Git Worktree

Always run parallel agents in distinct worktrees to provide complete file isolation.

Copyable Command
Terminal Command
git worktree add ../my-project-worker-2 feat/analytics-pipeline
Expected Terminal Output
Preparing worktree (new branch 'feat/analytics-pipeline')
HEAD is now at a1b2c3d chore: initial commit
2

Fenced Task Registration

Each agent starts its task in its designated worktree path. DevWorkflow's kernel mutex prevents collision.

Code / Tool Payload
Execution Payload
// Agent 2 Tool Call: start_task
{
  "description": "Build analytics export pipeline",
  "projectDir": "/path/to/my-project-worker-2",
  "type": "feature"
}
3

Checkpoint & Handoff

If you need to switch tasks, call checkpoint_task. The state is serialized atomically into SQLite.

Code / Tool Payload
Execution Payload
// AI Tool Call: checkpoint_task
{
  "summary": "Completed schema migration; ready for API endpoint implementation"
}

Verification Steps

Verify that your work genuinely satisfies the task contract before closing.

Run `git worktree list` to inspect active trees
Run `devwf list` to view concurrent active agent sessions

Limitations & Troubleshooting

Issue: Agent refuses task with 'Project ownership lost'
Resolution: Do not force. Verify whether another agent process holds the lock, or adopt the session via `resume_session { adopt: sessionKey }`.