Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3230,6 +3230,67 @@
"onExp"
]
},
"github.copilot.chat.anthropic.tools.websearch.maxUses": {
"type": "number",
"default": 5,
"markdownDescription": "%github.copilot.config.anthropic.tools.websearch.maxUses%",
"minimum": 1,
"maximum": 20,
"tags": [
"experimental"
]
},
"github.copilot.chat.anthropic.tools.websearch.allowedDomains": {
"type": "array",
"default": [],
"markdownDescription": "%github.copilot.config.anthropic.tools.websearch.allowedDomains%",
"items": {
"type": "string"
},
"tags": [
"experimental"
]
},
"github.copilot.chat.anthropic.tools.websearch.blockedDomains": {
"type": "array",
"default": [],
"markdownDescription": "%github.copilot.config.anthropic.tools.websearch.blockedDomains%",
"items": {
"type": "string"
},
"tags": [
"experimental"
]
},
"github.copilot.chat.anthropic.tools.websearch.userLocation": {
"type": [
"object",
"null"
],
"default": null,
"markdownDescription": "%github.copilot.config.anthropic.tools.websearch.userLocation%",
"properties": {
"city": {
"type": "string",
"description": "City name (e.g., 'San Francisco')"
},
"region": {
"type": "string",
"description": "State or region (e.g., 'California')"
},
"country": {
"type": "string",
"description": "ISO country code (e.g., 'US')"
},
"timezone": {
"type": "string",
"description": "IANA timezone identifier (e.g., 'America/Los_Angeles')"
}
},
"tags": [
"experimental"
]
},
"github.copilot.chat.tools.memory.enabled": {
"type": "boolean",
"default": false,
Expand Down
4 changes: 4 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@
"github.copilot.config.anthropic.thinking.enabled": "Enable extended thinking for Anthropic models that support it. \n\n **Note**: This is an experimental feature only supported in BYOK Anthropic models.",
"github.copilot.config.anthropic.thinking.maxTokens": "Maximum number of tokens to allocate for extended thinking in Anthropic models. Valid range is 1,024 to 32,000 tokens. Always capped at (max output tokens - 1).\n\n**Note**: This is an experimental feature only supported in BYOK Anthropic models.",
"github.copilot.config.anthropic.tools.websearch.enabled": "Enable Anthropic's native web search tool for BYOK Claude models. When enabled, allows Claude to search the web for current information. \n\n**Note**: This is an experimental feature only available for BYOK Anthropic Claude models.",
"github.copilot.config.anthropic.tools.websearch.maxUses": "Maximum number of web searches allowed per request. Valid range is 1 to 20. Prevents excessive API calls within a single interaction. If Claude exceeds this limit, the response returns an error.",
"github.copilot.config.anthropic.tools.websearch.allowedDomains": "List of domains to restrict web search results to (e.g., `[\"example.com\", \"docs.example.com\"]`). Domains should not include the HTTP/HTTPS scheme. Subdomains are automatically included. Cannot be used together with blocked domains.",
"github.copilot.config.anthropic.tools.websearch.blockedDomains": "List of domains to exclude from web search results (e.g., `[\"untrustedsource.com\"]`). Domains should not include the HTTP/HTTPS scheme. Subdomains are automatically excluded. Cannot be used together with allowed domains.",
"github.copilot.config.anthropic.tools.websearch.userLocation": "User location for personalizing web search results based on geographic context. All fields (city, region, country, timezone) are optional. Example: `{\"city\": \"San Francisco\", \"region\": \"California\", \"country\": \"US\", \"timezone\": \"America/Los_Angeles\"}`",
"github.copilot.config.tools.memory.enabled": "Enable memory tool to allow models to store and retrieve information across conversations. \n\n**Note**: This is an experimental feature.",
"github.copilot.config.completionsFetcher": "Sets the fetcher used for the inline completions.",
"github.copilot.config.nesFetcher": "Sets the fetcher used for the next edit suggestions.",
Expand Down
30 changes: 27 additions & 3 deletions src/extension/byok/vscode-node/anthropicProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,35 @@ export class AnthropicLMProvider implements BYOKModelProvider<LanguageModelChatI
// We need to do this because there is no local web_search tool definition we can replace.
const webSearchEnabled = this._configurationService.getExperimentBasedConfig(ConfigKey.AnthropicWebSearchToolEnabled, this._experimentationService);
if (webSearchEnabled && !tools.some(tool => tool.name === 'web_search')) {
tools.push({
const maxUses = this._configurationService.getConfig(ConfigKey.AnthropicWebSearchMaxUses);
const allowedDomains = this._configurationService.getConfig(ConfigKey.AnthropicWebSearchAllowedDomains);
const blockedDomains = this._configurationService.getConfig(ConfigKey.AnthropicWebSearchBlockedDomains);
const userLocation = this._configurationService.getConfig(ConfigKey.AnthropicWebSearchUserLocation);

const webSearchTool: Anthropic.Beta.BetaWebSearchTool20250305 = {
name: 'web_search',
type: 'web_search_20250305',
max_uses: 5
});
max_uses: maxUses
};

// Add domain filtering if configured
// Cannot use both allowed and blocked domains simultaneously
if (allowedDomains && allowedDomains.length > 0) {
webSearchTool.allowed_domains = allowedDomains;
} else if (blockedDomains && blockedDomains.length > 0) {
webSearchTool.blocked_domains = blockedDomains;
}

// Add user location if configured
// Note: All fields are optional according to Anthropic docs
if (userLocation && (userLocation.city || userLocation.region || userLocation.country || userLocation.timezone)) {
webSearchTool.user_location = {
type: 'approximate',
...userLocation
};
}

tools.push(webSearchTool);
}

const thinkingEnabled = this._enableThinking(model.id);
Expand Down
13 changes: 13 additions & 0 deletions src/platform/configuration/common/configurationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,19 @@ export namespace ConfigKey {
export const MaxAnthropicThinkingTokens = defineSetting<number | null>('chat.anthropic.thinking.maxTokens', null);
/** Enable Anthropic web search tool for BYOK Claude models */
export const AnthropicWebSearchToolEnabled = defineExpSetting<boolean>('chat.anthropic.tools.websearch.enabled', false);
/** Maximum number of web searches allowed per request */
export const AnthropicWebSearchMaxUses = defineSetting<number>('chat.anthropic.tools.websearch.maxUses', 5);
/** List of domains to restrict web search results to */
export const AnthropicWebSearchAllowedDomains = defineSetting<string[]>('chat.anthropic.tools.websearch.allowedDomains', []);
/** List of domains to exclude from web search results */
export const AnthropicWebSearchBlockedDomains = defineSetting<string[]>('chat.anthropic.tools.websearch.blockedDomains', []);
/** User location for personalizing web search results */
export const AnthropicWebSearchUserLocation = defineSetting<{
city?: string;
region?: string;
country?: string;
timezone?: string;
} | null>('chat.anthropic.tools.websearch.userLocation', null);
/** Enable memory tool */
export const MemoryToolEnabled = defineExpSetting<boolean>('chat.tools.memory.enabled', false);

Expand Down
Loading