Skip to content

delegate_task isolation "worktree" from a Git repo inside Scratch gives children an empty non-git folder #45050

Backlog

Description

@kosovojs

What happened

A Claude thread in Scratch ("No project") was working in a Git repo it had created in its own Scratch subfolder (~/.t3/scratch/2026-11-28-…-7acaa2cb, branch master). It started 12 child agents with delegate_task and isolation: "worktree". Every child was handed a "worktree" like ~/.t3/worktrees/scratch/t3-938fbbbb-…: a plain non-git folder that mirrors the Scratch root and doesn't contain the parent's repo. The children found no code and stopped without changes. T3 showed no error.

The agent couldn't recover through T3:

  • It registered the repo as a new project and retried with target.projectId. All 12 attempts were refused: A local task runs in this thread's project. Omit target.projectId, or pass target.environmentId to run it in that environment's project.
  • A thread can't be moved to another project.

It only got past this by running git worktree add itself and re-delegating with isolation: "shared" inside those folders.

Diagnosis

OrchestratorMcpService.ts:3029-3060 (delegate_task):

  1. The first branch checks threadLaunch.isNonGitProject(parent.thread.projectId). Scratch's root (~/.t3/scratch) isn't a Git repository, so this is true, and the strategy becomes { type: "worktree", baseRef: "HEAD" }. That's the plain-folder path: a new task folder is built from the project root, and only repositories the project tracks get a worktree (TaskFolders.plan, ThreadLaunchService.ts:459). The parent's repo is a subfolder the project doesn't track, and the parent's worktreePath is never looked at, so the child gets an empty mirror folder.
  2. The second branch already has a guard for exactly this case. Its comment says "a parent checkout in another repository (such as a Git folder inside Scratch) would hand it a commit it cannot find", and it fails with a clear message pointing to isolation: "shared". But a Scratch parent always takes the first branch, so the guard never runs for the case it describes.

Suggested direction: when parent.thread.worktreePath is a Git checkout, create the child worktree from that checkout's repository. If that isn't wanted, at least run the existing guard before the plain-folder branch, so the agent gets a clear refusal instead of an empty folder.

Steps to reproduce

  1. Start a thread in Scratch ("No project").
  2. In the thread's Scratch folder: git init, then commit a file.
  3. Have the agent call delegate_task with isolation: "worktree".
  4. The child's cwd is ~/.t3/worktrees/scratch/t3-…: not a Git repo, and the committed file isn't there.
  5. Optionally, t3_project_create the repo folder and retry delegate_task with target.projectId: it's refused with invalid_request.

Version

0.1.14-nightly.20261128.5385 (local service). The code paths cited are current main (c1cce2e).

Environment

  • Linux x64 (Fedora), T3 as a systemd user service (t3 serve), web client - Parent: Claude (claude-opus-5-5) via Claude Agent SDK; children: Codex (gpt-6.1-sol)

Evidence

Parent thread `projection_threads` payload: `branch: "master"`, `worktreePath: "~/.t3/scratch/2026-11-28-…-7acaa2cb"`. Project: `"No project"`, `workspace_root: "~/.t3/scratch"`.

Child "Sol unit 1": `branch: "t3/938fbbbb"`, `worktreePath: "~/.t3/worktrees/scratch/t3-938fbbbb-…"`:

$ git -C ~/.t3/worktrees/scratch/t3-938fbbbb-… rev-parse --show-toplevel
fatal: not a git repository (or any parent up to mount point /)
$ ls ~/.t3/worktrees/scratch/t3-938fbbbb-…
2026-10-21-…  2026-10-23-…  …   # other Scratch session folders; the parent's repo folder is missing

Retry with `target.projectId` (×12, 14:01:10–14:02:29 UTC):

{"_tag":"OrchestratorMcpFailure","code":"invalid_request","message":"A local task runs in this thread's project. Omit target.projectId, or pass target.environmentId to run it in that environment's project."}

48 such folders have built up in `~/.t3/worktrees/scratch` (18 MB).

Related issues

Fix applied or workaround

The agent ran git worktree add -b unit/<n> <repo>-wt/<n> master itself for each unit and re-delegated with isolation: "shared", telling each child its folder. Alternative: add the repo as a project and start the coordinator thread there instead of in Scratch.

Filed by

Claude Opus 5.5 (claude-opus-5-5) in Claude Code, via t3 triage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    via-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions