Skip to content

Derive worktree branch name from first message on agent host - #315065

Merged
roblourens merged 4 commits into
mainfrom
agents/be796a2d-16df-47b0-a4a1-1cc99853564a
May 8, 2026
Merged

roblourens merged 4 commits into
mainfrom
agents/be796a2d-16df-47b0-a4a1-1cc99853564a

Conversation

@roblourens

Copy link
Copy Markdown
Member

In remote agent host worktree mode, the generated branch was just a GUID because the eager-create path never sent a branchNameHint. Rather than plumb a hint from the client, this PR derives it on the agent host from the first message itself.

Changes

  • Add getCopilotBranchNameHintFromMessage in copilotAgent.ts
  • Plumb prompt through sendMessage → _materializeProvisional → _resolveSessionWorkingDirectory so the branch is created lazily on first message with a meaningful name
  • Remove SessionConfigKey.BranchNameHint and the client-side getAgentHostBranchNameHint plumbing — the client no longer needs to compute or send a hint
  • Update tests accordingly

In remote agent host worktree mode, the generated branch was just a
GUID because the eager-create path never sent a branchNameHint. Rather
than plumb a hint from the client, derive it on the agent host from
the first message itself.

- Add getCopilotBranchNameHintFromMessage in copilotAgent.ts
- Plumb prompt through sendMessage -> _materializeProvisional ->
  _resolveSessionWorkingDirectory
- Remove SessionConfigKey.BranchNameHint and the client-side
  getAgentHostBranchNameHint plumbing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 7, 2026 17:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the remote agent host “worktree isolation” flow by deriving a deterministic branch-name hint from the first user message on the agent host, avoiding GUID-only branch names without requiring the client to compute or send a hint.

Changes:

  • Add getCopilotBranchNameHintFromMessage on the agent host and use it during provisional-session materialization to name worktree branches based on the first prompt.
  • Remove client-side branchNameHint plumbing (SessionConfigKey.BranchNameHint + handler helper/export) and adjust session config forwarding behavior/tests.
  • Update UI/config picker and tests to reflect the removed config key and new eager-create config propagation.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts Updates tests to stop expecting branchNameHint in createSession config and adds coverage for eager-create SessionConfigChanged forwarding.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts Removes client-side branch hint derivation and stops injecting BranchNameHint into session creation config.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatContribution.ts Removes re-export of the deleted getAgentHostBranchNameHint.
src/vs/sessions/contrib/chat/browser/agentHost/agentHostSessionConfigPicker.ts Stops filtering out the removed branchNameHint config key when rendering pickers.
src/vs/platform/agentHost/test/node/copilotAgent.test.ts Updates tests to reflect prompt-based branch hinting and the removal of branchNameHint in config.
src/vs/platform/agentHost/node/copilot/copilotAgent.ts Introduces prompt-to-slug branch hint derivation and plumbs prompt into provisional materialization/worktree creation.
src/vs/platform/agentHost/common/sessionConfigKeys.ts Removes SessionConfigKey.BranchNameHint.

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 1

Comment thread src/vs/platform/agentHost/node/copilot/copilotAgent.ts
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@roblourens
roblourens marked this pull request as ready for review May 7, 2026 22:48
@roblourens
roblourens enabled auto-merge (squash) May 7, 2026 22:48
@roblourens
roblourens merged commit 107576e into main May 8, 2026
26 checks passed
@roblourens
roblourens deleted the agents/be796a2d-16df-47b0-a4a1-1cc99853564a branch May 8, 2026 03:02
@vs-code-engineering vs-code-engineering Bot added this to the 1.120.0 milestone May 8, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jun 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants