-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
Automatic git worktree management for agent tasks #100534
Copy link
Copy link
Closed
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.maintainerMaintainer-authored PRMaintainer-authored PR
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.maintainerMaintainer-authored PRMaintainer-authored PR
Type
Fields
Priority
None yet
Problem
OpenClaw has no managed way to run agent tasks in isolated git checkouts. Agents work directly in the user's checkout, so parallel tasks on one repo collide, and any temporary checkouts an operator creates by hand are never cleaned up. Every major coding-agent product (Claude Code, OpenAI Codex, Cursor, Copilot, Hermes) has converged on automatic git-worktree management: per-task worktrees, declarative provisioning of gitignored files, and automatic loss-proof cleanup. Workboard already models
workspace.kind: "worktree"on automation cards, but nothing materializes it.Proposed solution
Core managed-worktree service with the industry-standard lifecycle, adapted to OpenClaw's architecture rules (SQLite-first state, additive gateway protocol, plugin-SDK seams):
<state-dir>/worktrees/<repo-fingerprint>/<name>, branchopenclaw/<name>per task, based off the fetched remote default branch (offline fallback to localHEAD)..worktreeinclude(same semantics as Claude Code/Codex — copy selected gitignored+untracked files), plus an optional executable.openclaw/worktree-setup.shrepo hook.openclaw pid=<pid>) so GC can distinguish live, dead, and foreign owners.refs/openclaw/snapshots/<id>; restore rebuilds the branch at the original commit with the snapshot content as uncommitted working state.worktrees.*gateway RPC,openclaw worktreesCLI, Control UI page, plugin-SDK facade, and Workboard materialization ofkind: "worktree"cards.Non-goals: managing foreign worktrees (
~/.codex/worktrees,.claude/worktrees), new config keys, apply-to-main merge-back, port/env isolation.