Skip to content

agentHost: support for client-provided tools#309672

Merged
connor4312 merged 3 commits intomainfrom
connor4312/ah-client-tools
Apr 14, 2026
Merged

agentHost: support for client-provided tools#309672
connor4312 merged 3 commits intomainfrom
connor4312/ah-client-tools

Conversation

@connor4312
Copy link
Copy Markdown
Member

Does a half-way cleanup of state related to the active client and supports client-provided tools -- initially the runTests tool, task tools, and problems tools.

Does a half-way cleanup of state related to the active client and
supports client-provided tools -- initially the runTests tool, task
tools, and problems tools.
Copilot AI review requested due to automatic review settings April 13, 2026 23:35
@connor4312 connor4312 self-assigned this Apr 13, 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

Adds support for “client-provided tools” in agent host sessions (initially runTests/task/problems tools) by flowing tool definitions from the renderer to the agent-host process, routing tool execution back to the owning client, and keeping session refresh logic in sync with active client changes.

Changes:

  • Introduces a new chat.agentHost.clientTools setting and wires renderer-side tool allowlisting + publishing into session/activeClientChanged and session/activeClientToolsChanged.
  • Implements client-tool execution: Copilot agent registers SDK tools that defer to the client, and the renderer executes tool calls and dispatches session/toolCallComplete.
  • Updates protocol/event plumbing to carry toolClientId, and extends agent interfaces + tests accordingly.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostClientTools.test.ts Adds unit/integration-style tests for client tool conversion and registration logic.
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts Updates test stubs to accommodate the new tools service + config setting.
src/vs/workbench/contrib/chat/common/constants.ts Adds ChatConfiguration.AgentHostClientTools.
src/vs/workbench/contrib/chat/browser/chat.contribution.ts Registers chat.agentHost.clientTools configuration with defaults.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts Publishes allowlisted client tools, executes owned client tool calls, and converts tool results to protocol.
src/vs/platform/agentHost/test/node/mockAgent.ts Adds required IAgent methods for client tools in mock agents.
src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts Updates construction to new CopilotAgentSession options object.
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts Adds client tool SDK tool registration + deferred completion handling via session/toolCallComplete.
src/vs/platform/agentHost/node/copilot/copilotAgent.ts Tracks per-session active client snapshot (plugins + tools), refreshes sessions when snapshot changes, and forwards tool completion.
src/vs/platform/agentHost/node/agentSideEffects.ts Forwards client tool definitions to agents and forwards tool completion callbacks.
src/vs/platform/agentHost/node/agentEventMapper.ts Maps toolClientId onto protocol tool call start actions.
src/vs/platform/agentHost/common/state/protocol/state.ts Minor doc cleanup around tool definition types.
src/vs/platform/agentHost/common/state/protocol/actions.ts Updates docs/annotations for client-dispatchable tool streaming content.
src/vs/platform/agentHost/common/state/protocol/action-origin.generated.ts Marks session/toolCallContentChanged as client-dispatchable and updates unions.
src/vs/platform/agentHost/common/state/protocol/.ahp-version Bumps protocol sync version.
src/vs/platform/agentHost/common/agentService.ts Extends IAgent with setClientTools and onClientToolCallComplete.

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostClientTools.test.ts:481

  • This test doesn’t exercise the production filtering logic (it re-implements allowlist filtering inline instead of observing what AgentHostSessionHandler publishes/dispatches). Consider driving the handler with a mock tools service + config and asserting the resulting dispatched activeClientChanged/activeClientToolsChanged tool definitions.
		test('excludes tools not in the allowlist', () => {
			createHandlerWithMocks(disposables, [testRunTestsTool, testRunTaskTool, testUnlistedTool], {
				clientTools: ['runTests'],
			});

			// Validate the filtering logic: only 'runTests' should match the allowlist.
			const filteredTools = [testRunTestsTool, testRunTaskTool, testUnlistedTool]
				.filter(t => t.toolReferenceName !== undefined && ['runTests'].includes(t.toolReferenceName));
			assert.strictEqual(filteredTools.length, 1);
			assert.strictEqual(filteredTools[0].toolReferenceName, 'runTests');
		});
  • Files reviewed: 16/16 changed files
  • Comments generated: 5

@connor4312 connor4312 marked this pull request as ready for review April 14, 2026 01:56
@connor4312 connor4312 enabled auto-merge April 14, 2026 01:56
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

Screenshot Changes

Base: cf7f246a Current: 848b9a0a

Changed (9)

chat/artifacts/chatArtifacts/MultiSourceExpanded/Dark
Before After
before after
chat/aiCustomizations/aiCustomizationManagementEditor/PromptsTabScrolled/Dark
Before After
before after
chat/aiCustomizations/aiCustomizationManagementEditor/McpBrowseMode/Light
Before After
before after
agentSessionsViewer/WithBadgeAndDiff/Dark
Before After
before after
agentSessionsViewer/ClaudeProvider/Dark
Before After
before after
agentSessionsViewer/FailedWithoutDuration/Light
Before After
before after
agentSessionsViewer/FailedWithoutDuration/Dark
Before After
before after
agentSessionsViewer/WithBadgeAndDiff/Light
Before After
before after
agentSessionsViewer/ClaudeProvider/Light
Before After
before after

roblourens
roblourens previously approved these changes Apr 14, 2026
@connor4312 connor4312 merged commit 4860996 into main Apr 14, 2026
26 checks passed
@connor4312 connor4312 deleted the connor4312/ah-client-tools branch April 14, 2026 03:20
@vs-code-engineering vs-code-engineering bot added this to the 1.117.0 milestone Apr 14, 2026
roblourens added a commit that referenced this pull request Apr 15, 2026
From #309672.
1. `getSessionMetadata` does indeed actually fail immediately after creating the session, this is the problem from last week
2. But we also try to store the metadata via `_storeSessionMetadata`- which fails because it uses `tryOpenDatabase` and nothing has created the db yet
3. Then we go through this path https://github.com/microsoft/vscode/blob/bfc9f24e5630cca636a68ed2707d29aee784e6fd/src/vs/platform/agentHost/node/copilot/copilotAgent.ts#L436-L440 then go through `_resumeSession` which fails because we don't have a cwd from the SDK, or from our own store.
4. And the SDK forgets its own workingDirectory unless it's passed in

Co-authored-by: Copilot <copilot@github.com>
roblourens added a commit that referenced this pull request Apr 15, 2026
…gression

 Copilot SDK
path to verify that workingDirectory is correctly preserved when the active
client changes between createSession and sendMessage. This reproduces the
regression from #309672 where setting client tools causes the session to be
recreated via _resumeSession, losing the original working directory.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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