Skip to content

Allow explicit worktree selection when agents create independent sessions #335077

Description

Feature request

Allow users to explicitly choose whether an agent-created independent session uses a new Git worktree. The create_session tool should honor that choice rather than relying only on inherited isolation.

Implemented by #335076.

Expected behavior

  • Set worktree: true only when the user explicitly requests a new worktree.
  • Set worktree: false only when the user explicitly requests working without a worktree.
  • Omit worktree when the user has not made an explicit choice, preserving existing isolation inheritance/defaults.
  • Never combine worktree with relationship: currentSession; either boolean value is rejected before creating a chat or session.
  • With worktree: false, resolve a known existing worktree folder to its project root before creating the independent session.

Verification steps

Use the Agents window with a Git project and inspect the create_session tool arguments and the resulting working directory/branch, not just the assistant summary.

  1. Explicit worktree: Ask “Start implementation in a new independent session with a new worktree.” Verify relationship: independent, worktree: true, and a newly created worktree.
  2. No worktree from an existing worktree: Start from a session already using a managed worktree and ask “Start implementation in a new independent session without a worktree.” Verify worktree: false; the new session uses the known project root, not the parent worktree, and no additional worktree is created.
  3. No explicit choice: Ask for an independent session without mentioning worktrees. Verify the agent omits worktree. For the same project, existing isolation is inherited; a different project retains the existing worktree default.
  4. Current-session work: Ask for a new chat in the current session. Verify relationship: currentSession, no worktree argument, and the existing workspace is shared.
  5. Folder fallback: Request an independent session without a worktree for a folder with no known project mapping. Verify that the supplied folder is used directly.
  6. If available, repeat step 2 for a remote project and verify that its remote URI/authority is preserved.

Unit tests additionally cover invalid boolean values and rejection of currentSession combined with either worktree: true or worktree: false.

Activity

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

Metadata

Metadata

Labels

agents-windowfeature-requestRequest for new features or functionalityinsiders-releasedPatch has been released in VS Code InsidersverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions