Fix registerToolDefinition tools from default chat agent being filtered out (#300529)

Tools registered via registerToolDefinition by the default chat agent
(copilot-chat) were incorrectly getting source type 'extension' instead
of ToolDataSource.Internal. This caused them to be filtered out by the
chat.extensionTools.enabled setting check in getAllToolsIncludingDisabled().

Package.json-contributed tools from the same extension correctly got
ToolDataSource.Internal via the isBuiltinTool check in
languageModelToolsContribution.ts. Apply the same logic in
$registerToolWithDefinition on the main thread.
This commit is contained in:
Bhavya U
2026-03-10 13:21:19 -07:00
committed by GitHub
parent ea9e9386aa
commit 9a1fe573bb

View File

@@ -10,6 +10,7 @@ import { ThemeIcon } from '../../../base/common/themables.js';
import { isUriComponents, URI, UriComponents } from '../../../base/common/uri.js';
import { ExtensionIdentifier } from '../../../platform/extensions/common/extensions.js';
import { ILogService } from '../../../platform/log/common/log.js';
import { IProductService } from '../../../platform/product/common/productService.js';
import { toToolSetKey } from '../../contrib/chat/common/tools/languageModelToolsContribution.js';
import { CountTokensCallback, ILanguageModelToolsService, IToolData, IToolInvocation, IToolProgressStep, IToolResult, ToolDataSource, ToolProgress, toolResultHasBuffers, ToolSet } from '../../contrib/chat/common/tools/languageModelToolsService.js';
import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';
@@ -30,6 +31,7 @@ export class MainThreadLanguageModelTools extends Disposable implements MainThre
extHostContext: IExtHostContext,
@ILanguageModelToolsService private readonly _languageModelToolsService: ILanguageModelToolsService,
@ILogService private readonly _logService: ILogService,
@IProductService private readonly _productService: IProductService,
) {
super();
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostLanguageModelTools);
@@ -118,8 +120,13 @@ export class MainThreadLanguageModelTools extends Disposable implements MainThre
}
}
// Convert source from DTO
const source = revive<ToolDataSource>(definition.source);
// Convert source from DTO, matching the isBuiltinTool logic from languageModelToolsContribution
const isBuiltinTool = this._productService.defaultChatAgent?.chatExtensionId
? ExtensionIdentifier.equals(extensionId, this._productService.defaultChatAgent.chatExtensionId)
: false;
const source: ToolDataSource = isBuiltinTool
? ToolDataSource.Internal
: revive<ToolDataSource>(definition.source);
// Create the tool data
const toolData: IToolData = {