Git worktree management for isolated agent workspaces

t-539.5·WorkTask·
·
·
Parent:t-539·Created2 weeks ago·Updated2 weeks ago

Description

Edit

Add git worktree management to agentd for isolated agent workspaces.

Current state:

  • Agents work directly in /home/ben/omni/ava
  • No isolation between concurrent agents
  • Conflicts if multiple agents edit same files

Target state:

  • Each agent spawn gets its own git worktree
  • git worktree add /tmp/agentd/<run-id> HEAD
  • Agent works in isolated worktree
  • On completion: merge/cherry-pick changes back, remove worktree

Implementation: 1. Add worktree creation in spawnPiAgent:

  • git worktree add <path> <branch>
  • Set workspace to worktree path

2. Add worktree cleanup on agent completion:

  • git worktree remove <path>

3. Handle merge conflicts gracefully 4. Consider: keep worktree on failure for debugging

Configuration:

  • worktree_root: /tmp/agentd/worktrees (or configurable)
  • auto_cleanup: true/false
  • base_branch: HEAD or specific branch

Timeline (4)

🔄[human]Open → InProgress2 weeks ago
🔄[human]InProgress → Done2 weeks ago
💬[human]2 weeks ago

Added git worktree management to Omni/Agentd/Daemon.hs: create per-run worktrees under <workspace>/_/agentd/worktrees when base is a git repo, track worktree paths in RunningAgent, cleanup on success/stop, and fail spawn if worktree creation fails.