Skip to content

agentHost: rationalize settings a bit#312015

Open
connor4312 wants to merge 6 commits intomainfrom
connor4312/ah-session-settings-2
Open

agentHost: rationalize settings a bit#312015
connor4312 wants to merge 6 commits intomainfrom
connor4312/ah-session-settings-2

Conversation

@connor4312
Copy link
Copy Markdown
Member

In advance of host-level settings, replaces our ad-hoc setting handling with a IAgentConfigurationService. This handles inheritance correctly. We also have a 'schema builder' now that allows for better type safety as we produce and consume schema.

  • New IAgentConfigurationService with getEffectiveValue, getEffectiveWorkingDirectory, and updateSessionConfig. Owns the inheritance chain so every consumer composes layers identically.
  • New schema builder (schemaProperty<T> / createSchema) with phantom TypeScript types + derived runtime validators. assertValid throws a ProtocolError(InvalidParams) annotated with the offending dotted path (e.g. permissions.allow[2]); validate is the boolean form; values() validates at write sites; validateOrDefault() sanitizes untrusted input at protocol boundaries.
  • platformSessionSchema centralizes the autoApprove + permissions property descriptors that copilotAgent.resolveSessionConfig previously duplicated; agents compose via ...platformSessionSchema .definition.
  • getEffectiveValue validates each layer against a caller-supplied schema and falls through when a layer's value is malformed, logging the path-annotated reason.
  • Wire DI through AgentService (local InstantiationService scope) so AgentSideEffects and SessionPermissionManager resolve ILogService and IAgentConfigurationService via DI rather than plain-class plumbing.
  • copilotAgent.resolveSessionConfig collapses to a single schema construction + validateOrDefault call; duplicated schema literals removed.
  • Tests: 33 new unit tests covering schema validation, path-annotated errors, validateOrDefault, and the full precedence chain in AgentConfigurationService

- Unrelated: fix local agent host being broken on main following
  some overnight cleanups
- Register a JSON schema for agent session settings (only when they're
  open since it has a perf cost)
- When there are multiple custom approval buttons, show them in a
  dropdown similar to other tool calls.
In advance of host-level settings, replaces our ad-hoc setting handling
with a IAgentConfigurationService. This handles inheritance correctly.
We also have a 'schema builder' now that allows for better type safety
as we produce and consume schema.

- New `IAgentConfigurationService` with `getEffectiveValue`,
  `getEffectiveWorkingDirectory`, and `updateSessionConfig`. Owns the
  inheritance chain so every consumer composes layers identically.
- New schema builder (`schemaProperty<T>` / `createSchema`) with phantom
  TypeScript types + derived runtime validators. `assertValid` throws a
  `ProtocolError(InvalidParams)` annotated with the offending dotted
  path (e.g. `permissions.allow[2]`); `validate` is the boolean form;
  `values()` validates at write sites; `validateOrDefault()` sanitizes
  untrusted input at protocol boundaries.
- `platformSessionSchema` centralizes the `autoApprove` + `permissions`
  property descriptors that `copilotAgent.resolveSessionConfig`
  previously duplicated; agents compose via `...platformSessionSchema
  .definition`.
- `getEffectiveValue` validates each layer against a caller-supplied
  schema and falls through when a layer's value is malformed, logging
  the path-annotated reason.
- Wire DI through `AgentService` (local `InstantiationService` scope) so
  `AgentSideEffects` and `SessionPermissionManager` resolve `ILogService`
  and `IAgentConfigurationService` via DI rather than plain-class plumbing.
- `copilotAgent.resolveSessionConfig` collapses to a single schema
  construction + `validateOrDefault` call; duplicated schema literals
  removed.
- Tests: 33 new unit tests covering schema validation, path-annotated
  errors, `validateOrDefault`, and the full precedence chain in
  `AgentConfigurationService`
Copilot AI review requested due to automatic review settings April 22, 2026 21:38
@connor4312 connor4312 enabled auto-merge April 22, 2026 21:38
@connor4312 connor4312 self-assigned this Apr 22, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 refactors agent-host session configuration handling by introducing a dedicated IAgentConfigurationService (with correct inheritance across session → parent subagent → host), adds a typed schema builder with runtime validation, and centralizes well-known session config keys to reduce duplication across platform + Copilot agent code.

Changes:

  • Add IAgentConfigurationService + schema builder utilities (createSchema / schemaProperty) and centralize platform-owned config schema (platformSessionSchema).
  • Replace ad-hoc stringly-typed config keys (e.g. branchNameHint/autoApprove/permissions) with SessionConfigKey.
  • Add JSON schema registration for agent-session-settings://... files (lazy registration + refresh/dispose) and expand unit tests.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts Update branch name hint expectation to use SessionConfigKey.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/abstractToolConfirmationSubPart.ts Refactor tool confirmation custom option button building with protocol option kinds/groups.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts Pass branch name hint using SessionConfigKey.BranchNameHint.
src/vs/sessions/contrib/chat/browser/agentHost/agentHostSessionConfigPicker.ts Switch well-known config property comparisons to SessionConfigKey.
src/vs/sessions/contrib/chat/browser/agentHost/agentHostPermissionPickerDelegate.ts Remove local auto-approve constants; use centralized keys/values.
src/vs/sessions/contrib/agentHost/test/browser/agentSessionSettingsFileSystemProvider.test.ts Add schema registration tests and update harness to support provider/session events.
src/vs/sessions/contrib/agentHost/browser/localAgentHost.contribution.ts Ensure agent-host chat + terminal contributions are registered in the Sessions app.
src/vs/sessions/contrib/agentHost/browser/agentSessionSettingsFileSystemProvider.ts Add schema conversion + lazy per-session schema registration/refresh/disposal.
src/vs/sessions/contrib/agentHost/browser/agentSessionSettings.contribution.ts Wire schema registrar into the settings FS provider registration.
src/vs/platform/agentHost/test/node/agentSideEffects.test.ts Update tests to construct AgentSideEffects via DI scope including IAgentConfigurationService.
src/vs/platform/agentHost/test/node/agentConfigurationService.test.ts New tests for effective config inheritance and session config patching.
src/vs/platform/agentHost/test/common/agentHostSchema.test.ts New tests for schema validation, path-annotated errors, and defaults sanitization.
src/vs/platform/agentHost/node/sessionPermissions.ts Route permission/auto-approve logic through IAgentConfigurationService + platformSessionSchema.
src/vs/platform/agentHost/node/copilot/copilotAgent.ts Replace duplicated schema literals with composed typed schema + validateOrDefault; use SessionConfigKey.
src/vs/platform/agentHost/node/agentSideEffects.ts Create SessionPermissionManager via DI and stop manual plumbing of config/log dependencies.
src/vs/platform/agentHost/node/agentService.ts Introduce local instantiation scope providing IAgentConfigurationService to downstream components.
src/vs/platform/agentHost/node/agentConfigurationService.ts New IAgentConfigurationService implementation providing inheritance-aware reads and session patch writes.
src/vs/platform/agentHost/common/sessionConfigKeys.ts New centralized constants for well-known session config keys + known auto-approve values.
src/vs/platform/agentHost/common/agentService.ts Remove legacy AgentHostSessionConfigBranchNameHintKey constant.
src/vs/platform/agentHost/common/agentHostSchema.ts New schema builder utilities + platform-owned session config schema definitions.

Copilot's findings

  • Files reviewed: 20/20 changed files
  • Comments generated: 4

@github-actions
Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 1f9cd94d Current: 2c5c516c

Changed (2)

chat/aiCustomizations/aiCustomizationManagementEditor/McpBrowseMode/Light
Before After
before after
agentSessionsViewer/CompletedUnread/Dark
Before After
before after

@connor4312 connor4312 force-pushed the connor4312/ah-session-settings-2 branch from 3eb81bf to 9636727 Compare April 22, 2026 22:20
roblourens
roblourens previously approved these changes Apr 22, 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.

4 participants