Skip to content

[Bug]: delegate_task worktree children start a project's other repositories from their default branch, not the parent's branch #42536

Done

Description

@fanbuz

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Have two Git repositories, a and b, each with default branch main and a branch release that is ahead of main.
  2. Add a as a project and add b to it under Settings → Projects → Repositories. Check out release in both.
  3. In a thread of a (project checkout, on release), have the agent call delegate_task with isolation: "worktree".
  4. In the child's workspace, compare the start of each worktree: git -C <task folder>/a log -1 and git -C <task folder>/b log -1.

Expected behavior

b starts from release. docs/user/multi-repo-projects.md says:

Each repository starts from the thread's base branch where it has a branch of that name, and from its own default branch otherwise.

Actual behavior

a starts from the parent's commit on release, but b starts from main. Nothing in the delegate_task result or the child's context says so, so a child working across both repositories can build on mismatched code without noticing.

I saw this in a project with one main repository and four added ones. One added repository had a local branch with the same name as the branch checked out in the main repository, and that branch was also checked out there. Its child worktree was still created from its default branch (the reflog says Created from master).

The cause, from reading main at 2514a5c:

  • OrchestratorMcpService.ts resolves the parent's HEAD and sends only the SHA: workspaceStrategy = { type: "worktree", baseRef: base.commitSha, startFromOrigin: false }.
  • ThreadLaunchService.ts passes that on as baseBranch: input.workspaceStrategy.baseRef.
  • repositoryStart in TaskFolders.ts looks for refs/heads/<wanted> or refs/remotes/origin/<wanted> in each other repository. A SHA of a is never a branch name in b, so it always falls back to the default branch.

So the same-name rule cannot apply to a delegated child, whichever branch the parent is on.

From the same code (read, not reproduced): repositoryStart gets repository.path, the project's own copy of b. If the parent is itself a worktree thread with commits in its worktree of b, the child gets the parent's commit of a but not the parent's commits of b.

Possible directions:

  • Keep the parent's branch name next to the SHA, so the documented rule works. When the parent has its own worktree of b, start from that worktree's HEAD, as a already does.
  • Return each repository's path and base ref in the delegate_task result, so a fallback to the default branch is visible.

Impact

Minor bug or occasional failure

Version or commit

0.1.12-nightly.20261124.5209. The same code is on main @ 2514a5c.

Environment

macOS 27.2.1 (arm64), T3 Code desktop (Nightly). Parent thread on Claude, child on Codex. The base is chosen by the server, so the provider should not matter.

Workaround

Use t3_thread_launch with a branch name as baseRef, which the same-name rule can match. That thread is not a child and does not wake the caller. Otherwise, check every repository's base before the child starts work.

Related issues


Investigated and drafted by Claude Opus 5.5 in T3 Code. Filed at the account owner's request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions