Skip to content

Agents window: let the agent start a PR review session from a pull request link (e.g. open_pr_session tool) #347221

Open

Description

Follow-up from #331567, which lists PR/issue sessions as one of the session capabilities that VS Code doesn't expose to the agent yet.

Scenario

In the Agents window, I start a session with "help me review https://github.com/owner/repo/pull/123". Today the agent can't switch its environment to that pull request. It reads the diff remotely, or it runs git fetch/gh pr checkout in whatever folder the session happens to be in. That can mix the PR with the user's local changes or with another task's worktree.

The agent should have a tool that turns this request into a proper PR review session: the PR checked out, the session linked to the PR, and the PR context attached.

What exists today

  • The UI already has New Session from Pull Request (workbench.agentSessions.newSessionFromPullRequest, in the session section's new-session menu). It creates a session with the pullRequestUrl session config. The agent host then fetches the PR into its own worktree on a pr-<number> branch (worktreeIsolation.ts, _resolvePullRequestWorkingDirectory), links the session to the PR, and attaches the PR context.
  • The agent's session tools (SessionServerToolName: create_session, set_workspace, isolate_session, move_session, …) have no way to pass a pull request. So the agent can't reach the flow above.

Proposal

Add a session server tool, for example open_pr_session (name to be decided; copilotd already shows a label for a tool with that name), that takes a PR URL (or owner/repo#number) and:

  1. Resolves the PR and the local repository for it (the current session's repository, or a known project for that repo).
  2. Creates a session from the PR, reusing the existing pullRequestUrl path, so it gets the same worktree, branch, PR link and context as the UI command. Then it either:
    • starts a new independent session with the user's prompt (like create_session), or
    • moves the current chat into the PR worktree (like isolate_session / set_workspace), so the conversation continues in place.
  3. Follows the existing confirmation flow, since it fetches and creates a worktree.

Open questions

  • New session or move the current chat? Moving keeps the "help me review" conversation; a new session matches the UI command.
  • Should there be an option to check out the PR in the current folder, without a worktree? That's riskier with uncommitted changes. The worktree should probably be the default, with in-place checkout only when the user asks for it and the folder is clean.
  • Should the same tool cover issues ("work on Improve the explorer view to match full VS design #123") or should that be a separate tool?
  • Remote and cloud hosts: what should happen when the PR's repository isn't available locally?

🤖 Authored with GitHub Copilot on behalf of Alexandru Dima (@alexdima).

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

Metadata

Metadata

Labels

agent-hostagents-windowfeature-requestpull-requests

Type

No type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions