Skip to content

delegate_task (and t3_worktree_handoff) in non-Git multi-repo projects: children get zero repos above 8 tracked repos and ignore parent TaskFolder selection & branch #46638

Done

Description

@axatbhardwaj

Summary

In a non-Git umbrella project with multiple tracked Git repositories (e.g., 12–15 child repos), calling delegate_task with isolation: "worktree" (or t3_worktree_handoff) cannot select repositories and does not inherit the parent thread's TaskFolder selection or branch:

  • 9+ tracked repos → silently 0 repo worktrees: Even when the parent thread is already in a TaskFolder with e.g. 2 explicitly selected repos, an isolated child gets a TaskFolder with zero repository worktrees (only symlinks to plain files, with all tracked repo directories skipped) and no error.
  • 1–8 tracked repos → all repos checked out: Even when the parent only selected 2 repos (or the child only needs 1), every delegate_task(isolation: "worktree") creates worktrees for all tracked repos up to 8.
  • Parent branch/commits are ignored: Non-Git delegation sets baseRef: "HEAD", which resolves each repo to its own local default branch rather than the parent TaskFolder's branch/commits.

Follow-up to #42254 (merged PR #42261 fixed the parent-commit error on non-Git roots, leaving repository selection above 8 unfinished).


Root Cause (verified on main @ 85471b3681)

  1. TASK_FOLDER_DEFAULT_REPOSITORIES_MAX = 8 defaults to [] above 8:
  2. delegate_task has no repositories parameter and ignores the parent TaskFolder:
  3. Parent branch/commits are not carried forward on non-Git roots:
  4. t3_worktree_handoff has the same omission:

Proposed Behavior

Repository selection (primary):

  1. Add optional repositories (Array<{ path: string }>) to delegate_task and t3_worktree_handoff, reusing the existing workspaceStrategy.repositories shape from t3_thread_launch.
  2. Inherit parent TaskFolder selection by default: When a parent thread is already in a TaskFolder and delegate_task(isolation: "worktree") omits repositories, inherit the parent TaskFolder's recorded repositoryPath entries instead of falling back to the all-or-nothing project default.
  3. Fail fast instead of creating a 0-repo TaskFolder: When a project tracks Git repos (e.g. >8) and plan() resolves to 0 repositories with no custom layout, return an actionable invalid_request error explaining the 8-repo default threshold and the repositories parameter.

Base branch/commit resolution (distinct from selection):
4. Carry forward the parent TaskFolder's branch/commit for inherited/matching repos instead of always passing baseRef: "HEAD", matching #42536 / PR #42546 for Git-root projects.

(Optional follow-ups: expose TaskFolders.addRepository via MCP for adding a repo mid-thread, and allow t3_worktree_list to target a tracked repo instead of returning isRepo: false, refs: [] on non-Git roots.)


Current Workarounds

  • Use t3_thread_launch with workspaceStrategy.repositories (creates a top-level thread, not a delegated child).
  • Keep dedicated single-repo projects for repos that use delegate_task(isolation: "worktree").
  • Use isolation: "shared".

Related Issues

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