agentHost: support for client-provided tools#309672
Merged
connor4312 merged 3 commits intomainfrom Apr 14, 2026
Merged
Conversation
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.
Contributor
There was a problem hiding this comment.
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.clientToolssetting and wires renderer-side tool allowlisting + publishing intosession/activeClientChangedandsession/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
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts
Show resolved
Hide resolved
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostClientTools.test.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostClientTools.test.ts
Show resolved
Hide resolved
Contributor
Screenshot ChangesBase: Changed (9) |
roblourens
previously approved these changes
Apr 14, 2026
roblourens
approved these changes
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.