Problem
When a FORGE worker finishes a task and gets assigned a new ticket, the current WorkspaceManager deletes the existing worktree branch and recreates it from scratch. This destroys the previous branch and forces a full re-clone of the worktree, which is slow and loses history.
Expected Behaviour
When spawning a FORGE worker for a new task on the same slot (e.g. forge-1 gets ticket T-010 after completing T-005):
- Pull the latest
origin/main into the existing worktree.
- Create a new branch (e.g.
forge-1/T-010) from the updated origin/main.
- Reuse the existing worktree directory instead of deleting and recreating it.
This preserves previous branches (useful for audit/rollback) and is significantly faster.
Suggested Approach
- In
WorkspaceManager::create_worktree, check if the worktree directory already exists for the given pair ID.
- If it does, run
git fetch origin && git checkout origin/main && git pull instead of removing and re-creating.
- Create the new branch from the fetched
origin/main.
- Optionally keep old branches around (pruned by age or on-demand).
Related Code
crates/pair-harness/src/workspace.rs — WorkspaceManager::create_worktree / remove_worktree
crates/agent-forge/src/lib.rs — worktree lifecycle in batch handler
Problem
When a FORGE worker finishes a task and gets assigned a new ticket, the current
WorkspaceManagerdeletes the existing worktree branch and recreates it from scratch. This destroys the previous branch and forces a full re-clone of the worktree, which is slow and loses history.Expected Behaviour
When spawning a FORGE worker for a new task on the same slot (e.g.
forge-1gets ticketT-010after completingT-005):origin/maininto the existing worktree.forge-1/T-010) from the updatedorigin/main.This preserves previous branches (useful for audit/rollback) and is significantly faster.
Suggested Approach
WorkspaceManager::create_worktree, check if the worktree directory already exists for the given pair ID.git fetch origin && git checkout origin/main && git pullinstead of removing and re-creating.origin/main.Related Code
crates/pair-harness/src/workspace.rs—WorkspaceManager::create_worktree/remove_worktreecrates/agent-forge/src/lib.rs— worktree lifecycle in batch handler