Skip to content

agentHost: address agent merge review feedback - #331158

Merged
Benjamin Christopher Simmonds (benibenj) merged 3 commits into
mainfrom
benibenj/agents/agent-merge-review-followups
Aug 17, 2026
Merged

agentHost: address agent merge review feedback#331158
Benjamin Christopher Simmonds (benibenj) merged 3 commits into
mainfrom
benibenj/agents/agent-merge-review-followups

Conversation

@benibenj

Copy link
Copy Markdown
Contributor

Follow-up to #331010, addressing the review comments left on that PR after it was merged.

Setting rename

The Agent Merge settings no longer carry agentHost in their ID:

chat.agentHost.agentMerge.* -> chat.agentMerge.*

Security

  • The host now owns agentMerge.controller session config. SessionConfigChanged actions coming from a client that target host-written keys are rejected, so a client cannot forge a controller state (target, enabledAt, watermark, budgets) that later makes the gate return confirmed: true and triggers a native merge. Covered by two regression tests.
  • _canRepairFork fails closed when head repository provenance is missing.
  • Refs pointing at a different GitHub host are ignored.

Correctness

  • Injected autonomy configuration is reconciled on every cycle instead of once, and keys revoked by policy are rolled back. Configuration is never widened while a turn is active.
  • The merge target is revalidated before starting a turn and again before merging; the merge step re-reads live state, config, target and top-level comments.
  • AgentMergeRepairAction is split out of AgentMergeAction so repair paths cannot express a merge.
  • Stopping the runtime cancels the controller's in-flight turn.

Prompt bounding

Review threads now carry all of their feedback comments rather than only the first, and the prompt is bounded by explicit per-section caps plus a 20k character aggregate budget.

Commands

Enable/disable commands have separate preconditions driven by a dedicated context key, and the configure quick pick exposes reset as a title button rather than a list entry.

Validation

  • npm run typecheck-client
  • npm run eslint
  • npm run valid-layers-check
  • Agent Host unit tests (308 passing)

Follow-ups to PR #331010 review comments:

- Rename settings from `chat.agentHost.agentMerge.*` to `chat.agentMerge.*`.
- Reject client writes to host-owned `agentMerge.controller` session config so a
  forged controller state cannot drive a native merge.
- Reconcile injected autonomy configuration every cycle and roll back keys that
  policy later revokes; never widen configuration while a turn is active.
- Revalidate the merge target before starting a turn and before merging, and
  refresh live state, config and top-level comments inside the merge step.
- Split `AgentMergeRepairAction` out of `AgentMergeAction` so repair paths
  cannot express a merge.
- Carry all feedback comments per review thread and bound the prompt with
  explicit caps and an aggregate character budget.
- Fail closed when fork head provenance is missing, and ignore refs from a
  different GitHub host.
- Cancel the controller turn when the runtime stops.
- Split the enable/disable command preconditions with a dedicated context key and
  make the configure quick pick's reset a title button.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 17, 2026 07:56

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

Strengthens Agent Merge security, correctness, configuration handling, and command UX following the initial controller rollout.

Changes:

  • Protects host-owned merge state and revalidates merge authorization.
  • Reconciles autonomy policy, cancels stopped repair turns, and bounds prompts.
  • Renames settings and improves Agent Merge commands.
Show a summary per file
File Description
agentMergeActions.ts Adds command state and reset button.
AGENT_HOST_SESSIONS_PROVIDER.md Updates Agent Merge documentation.
agentService.test.ts Tests client configuration authorization.
agentMergeController.test.ts Tests autonomy-policy reconciliation.
agentMerge.test.ts Tests feedback collection and bounds.
agentService.ts Guards host state and supports cancellation.
agentMergeController.ts Revalidates targets, merges, and policy.
agentMerge.ts Renames settings and bounds prompt context.
agentHostStarter.config.contribution.ts Registers renamed settings.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 9/9 changed files
  • Comments generated: 4
  • Review effort level: Balanced

Comment thread src/vs/platform/agentHost/node/agentService.ts Outdated
Comment thread src/vs/platform/agentHost/node/agentMergeController.ts Outdated
Comment thread src/vs/platform/agentHost/node/agentMergeController.ts Outdated
Comment thread src/vs/platform/agentHost/common/agentMerge.ts
…-merge-review-followups

# Conflicts:
#	src/vs/platform/agentHost/node/agentService.ts
- Preserve host-written session config across a client `SessionConfigChanged`
  with `replace: true`. Omitting `agentMerge.controller` previously cleared the
  bound target, comment watermark and attempt budgets, which bypassed the
  authorization boundary that explicit-write rejection was meant to enforce.
- Canonicalize pull request web hosts to their API host when checking that the
  credential matches. GitHub Enterprise Cloud serves `tenant.ghe.com` from
  `api.tenant.ghe.com`, so comparing the web host rejected every GHE Cloud pull
  request. The derivation now reuses `deriveGitHubEndpoints`.
- Refresh top-level comments inside `prepareMerge`, last, before the snapshot and
  token are captured. Refreshing them in the controller beforehand left a window
  across `prepareMerge`'s own authoritative refreshes in which a new maintainer
  comment could be missed; refreshing afterwards would invalidate the preparation
  generation. A comment landing after capture now invalidates the preparation.
- Migrate the legacy `chat.agentHost.agentMerge.*` setting ids to their new
  `chat.agentMerge.*` names so an explicit opt-out is not silently discarded.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@benibenj
Benjamin Christopher Simmonds (benibenj) merged commit ea32f80 into main Aug 17, 2026
44 of 45 checks passed
@benibenj
Benjamin Christopher Simmonds (benibenj) deleted the benibenj/agents/agent-merge-review-followups branch August 17, 2026 11:56
@vs-code-engineering vs-code-engineering Bot added this to the 1.135.0 milestone Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants