@ai-sdk/anthropic 4.0.53 → 4.0.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1052,12 +1052,13 @@ You can enable web search using the provider-defined web search tool:
1052
1052
  import { anthropic } from '@ai-sdk/anthropic';
1053
1053
  import { generateText } from 'ai';
1054
1054
 
1055
- const webSearchTool = anthropic.tools.webSearch_20250305({
1055
+ const webSearchTool = anthropic.tools.webSearch_20260318({
1056
1056
  maxUses: 5,
1057
+ responseInclusion: 'excluded',
1057
1058
  });
1058
1059
 
1059
1060
  const result = await generateText({
1060
- model: anthropic('claude-opus-4-20250514'),
1061
+ model: anthropic('claude-opus-5'),
1061
1062
  prompt: 'What are the latest developments in AI?',
1062
1063
  tools: {
1063
1064
  web_search: webSearchTool,
@@ -1072,6 +1073,10 @@ const result = await generateText({
1072
1073
 
1073
1074
  #### Configuration Options
1074
1075
 
1076
+ Use `webSearch_20260318` for dynamic filtering and response inclusion control.
1077
+ The older `webSearch_20260209` and `webSearch_20250305` versions remain
1078
+ available for applications that need their earlier behavior.
1079
+
1075
1080
  The web search tool supports several configuration options:
1076
1081
 
1077
1082
  - **maxUses** _number_
@@ -1090,11 +1095,17 @@ The web search tool supports several configuration options:
1090
1095
 
1091
1096
  Optional user location information to provide geographically relevant search results.
1092
1097
 
1098
+ - **responseInclusion** _'full' | 'excluded'_
1099
+
1100
+ Available with `webSearch_20260318`. Controls whether search result blocks
1101
+ consumed by a completed code execution call in the same turn are included in
1102
+ the API response. The default is `'full'`. Use `'excluded'` to omit those
1103
+ nested call/result pairs and reduce output token usage.
1104
+
1093
1105
  ```ts
1094
- const webSearchTool = anthropic.tools.webSearch_20250305({
1106
+ const webSearchTool = anthropic.tools.webSearch_20260318({
1095
1107
  maxUses: 3,
1096
1108
  allowedDomains: ['techcrunch.com', 'wired.com'],
1097
- blockedDomains: ['example-spam-site.com'],
1098
1109
  userLocation: {
1099
1110
  type: 'approximate',
1100
1111
  country: 'US',
@@ -1102,10 +1113,11 @@ const webSearchTool = anthropic.tools.webSearch_20250305({
1102
1113
  city: 'San Francisco',
1103
1114
  timezone: 'America/Los_Angeles',
1104
1115
  },
1116
+ responseInclusion: 'excluded',
1105
1117
  });
1106
1118
 
1107
1119
  const result = await generateText({
1108
- model: anthropic('claude-opus-4-20250514'),
1120
+ model: anthropic('claude-opus-5'),
1109
1121
  prompt: 'Find local news about technology',
1110
1122
  tools: {
1111
1123
  web_search: webSearchTool,
@@ -1113,6 +1125,13 @@ const result = await generateText({
1113
1125
  });
1114
1126
  ```
1115
1127
 
1128
+ <Note>
1129
+ `responseInclusion: 'excluded'` only omits results consumed by code execution
1130
+ calls that complete in the same turn. Results from direct calls and from code
1131
+ execution calls that pause before completing are always returned in full so
1132
+ they can be sent back on the next turn.
1133
+ </Note>
1134
+
1116
1135
  ### Web Fetch Tool
1117
1136
 
1118
1137
  Anthropic provides a provider-defined web fetch tool that allows Claude to retrieve content from specific URLs. This is useful when you want Claude to analyze or reference content from a particular webpage or document.
@@ -1124,11 +1143,14 @@ import { anthropic } from '@ai-sdk/anthropic';
1124
1143
  import { generateText } from 'ai';
1125
1144
 
1126
1145
  const result = await generateText({
1127
- model: anthropic('claude-sonnet-4-0'),
1146
+ model: anthropic('claude-opus-5'),
1128
1147
  prompt:
1129
1148
  'What is this page about? https://en.wikipedia.org/wiki/Maglemosian_culture',
1130
1149
  tools: {
1131
- web_fetch: anthropic.tools.webFetch_20250910({ maxUses: 1 }),
1150
+ web_fetch: anthropic.tools.webFetch_20260318({
1151
+ maxUses: 1,
1152
+ responseInclusion: 'excluded',
1153
+ }),
1132
1154
  },
1133
1155
  });
1134
1156
  ```
@@ -1473,6 +1495,19 @@ The web fetch tool supports several configuration options:
1473
1495
 
1474
1496
  The maxContentTokens parameter limits the amount of content that will be included in the context.
1475
1497
 
1498
+ - **useCache** _boolean_
1499
+
1500
+ Available with `webFetch_20260318`. Set to `false` to bypass cached content
1501
+ and fetch fresh content. The default is `true`; disabling the cache can
1502
+ increase latency.
1503
+
1504
+ - **responseInclusion** _'full' | 'excluded'_
1505
+
1506
+ Available with `webFetch_20260318`. Controls whether fetch result blocks
1507
+ consumed by a completed code execution call in the same turn are included in
1508
+ the API response. The default is `'full'`. Direct results and results from
1509
+ code execution calls that pause before completing are always returned in full.
1510
+
1476
1511
  #### Error Handling
1477
1512
 
1478
1513
  Web search errors are handled differently depending on whether you're using streaming or non-streaming:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/anthropic",
3
- "version": "4.0.53",
3
+ "version": "4.0.55",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -35,8 +35,8 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@ai-sdk/provider": "4.0.14",
39
- "@ai-sdk/provider-utils": "5.0.40"
38
+ "@ai-sdk/provider": "4.0.16",
39
+ "@ai-sdk/provider-utils": "5.0.42"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@ai-sdk/test-server": "2.0.1",
@@ -508,17 +508,22 @@ export type AnthropicTool =
508
508
  type: 'memory_20250818';
509
509
  }
510
510
  | {
511
- type: 'web_fetch_20250910' | 'web_fetch_20260209';
511
+ type: 'web_fetch_20250910' | 'web_fetch_20260209' | 'web_fetch_20260318';
512
512
  name: string;
513
513
  max_uses?: number;
514
514
  allowed_domains?: string[];
515
515
  blocked_domains?: string[];
516
516
  citations?: { enabled: boolean };
517
517
  max_content_tokens?: number;
518
+ use_cache?: boolean;
519
+ response_inclusion?: 'full' | 'excluded';
518
520
  cache_control: AnthropicCacheControl | undefined;
519
521
  }
520
522
  | {
521
- type: 'web_search_20250305' | 'web_search_20260209';
523
+ type:
524
+ | 'web_search_20250305'
525
+ | 'web_search_20260209'
526
+ | 'web_search_20260318';
522
527
  name: string;
523
528
  max_uses?: number;
524
529
  allowed_domains?: string[];
@@ -530,6 +535,7 @@ export type AnthropicTool =
530
535
  country?: string;
531
536
  timezone?: string;
532
537
  };
538
+ response_inclusion?: 'full' | 'excluded';
533
539
  cache_control: AnthropicCacheControl | undefined;
534
540
  }
535
541
  | {
@@ -465,8 +465,10 @@ export class AnthropicLanguageModel implements LanguageModelV4 {
465
465
  'anthropic.memory_20250818': 'memory',
466
466
  'anthropic.web_search_20250305': 'web_search',
467
467
  'anthropic.web_search_20260209': 'web_search',
468
+ 'anthropic.web_search_20260318': 'web_search',
468
469
  'anthropic.web_fetch_20250910': 'web_fetch',
469
470
  'anthropic.web_fetch_20260209': 'web_fetch',
471
+ 'anthropic.web_fetch_20260318': 'web_fetch',
470
472
  'anthropic.tool_search_regex_20251119': 'tool_search_tool_regex',
471
473
  'anthropic.tool_search_bm25_20251119': 'tool_search_tool_bm25',
472
474
  'anthropic.advisor_20260301': 'advisor',
@@ -1046,9 +1048,8 @@ export class AnthropicLanguageModel implements LanguageModelV4 {
1046
1048
  ...this.extractCitationDocuments(options.prompt),
1047
1049
  ];
1048
1050
 
1049
- const markCodeExecutionDynamic = hasWebTool20260209WithoutCodeExecution(
1050
- args.tools,
1051
- );
1051
+ const markCodeExecutionDynamic =
1052
+ hasDynamicFilteringWebToolWithoutCodeExecution(args.tools);
1052
1053
 
1053
1054
  const {
1054
1055
  responseHeaders,
@@ -1637,9 +1638,8 @@ export class AnthropicLanguageModel implements LanguageModelV4 {
1637
1638
  ...this.extractCitationDocuments(options.prompt),
1638
1639
  ];
1639
1640
 
1640
- const markCodeExecutionDynamic = hasWebTool20260209WithoutCodeExecution(
1641
- body.tools,
1642
- );
1641
+ const markCodeExecutionDynamic =
1642
+ hasDynamicFilteringWebToolWithoutCodeExecution(body.tools);
1643
1643
 
1644
1644
  const url = this.buildRequestUrl(true);
1645
1645
  const { responseHeaders, value: response } = await postJsonToApi({
@@ -1903,7 +1903,7 @@ export class AnthropicLanguageModel implements LanguageModelV4 {
1903
1903
  const customToolName =
1904
1904
  toolNameMapping.toCustomToolName(providerToolName);
1905
1905
 
1906
- // Tools like 'web_fetch_20260209' provide input data here.
1906
+ // Dynamic web tools provide input data here.
1907
1907
  // Other tools like 'code_execution_20260120' provide input data via deltas.
1908
1908
  // So we only use this if it's non-empty to avoid conflicts.
1909
1909
  const finalInput =
@@ -2978,21 +2978,23 @@ export function getModelCapabilities(modelId: string): {
2978
2978
  }
2979
2979
  }
2980
2980
 
2981
- export function hasWebTool20260209WithoutCodeExecution(
2981
+ export function hasDynamicFilteringWebToolWithoutCodeExecution(
2982
2982
  tools: AnthropicTool[] | undefined,
2983
2983
  ): boolean {
2984
2984
  if (!tools) {
2985
2985
  return false;
2986
2986
  }
2987
- let hasWebTool20260209 = false;
2987
+ let hasDynamicFilteringWebTool = false;
2988
2988
  let hasCodeExecutionTool = false;
2989
2989
  for (const tool of tools) {
2990
2990
  if (
2991
2991
  'type' in tool &&
2992
2992
  (tool.type === 'web_fetch_20260209' ||
2993
- tool.type === 'web_search_20260209')
2993
+ tool.type === 'web_fetch_20260318' ||
2994
+ tool.type === 'web_search_20260209' ||
2995
+ tool.type === 'web_search_20260318')
2994
2996
  ) {
2995
- hasWebTool20260209 = true;
2997
+ hasDynamicFilteringWebTool = true;
2996
2998
  continue;
2997
2999
  }
2998
3000
  if (
@@ -3005,7 +3007,7 @@ export function hasWebTool20260209WithoutCodeExecution(
3005
3007
  break;
3006
3008
  }
3007
3009
  }
3008
- return hasWebTool20260209 && !hasCodeExecutionTool;
3010
+ return hasDynamicFilteringWebTool && !hasCodeExecutionTool;
3009
3011
  }
3010
3012
 
3011
3013
  function resolveAnthropicReasoningConfig({
@@ -7,8 +7,10 @@ import type { AnthropicTool, AnthropicToolChoice } from './anthropic-api';
7
7
  import { CacheControlValidator } from './get-cache-control';
8
8
  import { advisor_20260301ArgsSchema } from './tool/advisor_20260301';
9
9
  import { textEditor_20250728ArgsSchema } from './tool/text-editor_20250728';
10
+ import { webSearch_20260318ArgsSchema } from './tool/web-search_20260318';
10
11
  import { webSearch_20260209ArgsSchema } from './tool/web-search_20260209';
11
12
  import { webSearch_20250305ArgsSchema } from './tool/web-search_20250305';
13
+ import { webFetch_20260318ArgsSchema } from './tool/web-fetch-20260318';
12
14
  import { webFetch_20260209ArgsSchema } from './tool/web-fetch-20260209';
13
15
  import { webFetch_20250910ArgsSchema } from './tool/web-fetch-20250910';
14
16
  import { validateTypes } from '@ai-sdk/provider-utils';
@@ -297,6 +299,25 @@ export async function prepareTools({
297
299
  });
298
300
  break;
299
301
  }
302
+ case 'anthropic.web_fetch_20260318': {
303
+ const args = await validateTypes({
304
+ value: tool.args,
305
+ schema: webFetch_20260318ArgsSchema,
306
+ });
307
+ anthropicTools.push({
308
+ type: 'web_fetch_20260318',
309
+ name: 'web_fetch',
310
+ max_uses: args.maxUses,
311
+ allowed_domains: args.allowedDomains,
312
+ blocked_domains: args.blockedDomains,
313
+ citations: args.citations,
314
+ max_content_tokens: args.maxContentTokens,
315
+ use_cache: args.useCache,
316
+ response_inclusion: args.responseInclusion,
317
+ cache_control: undefined,
318
+ });
319
+ break;
320
+ }
300
321
  case 'anthropic.web_search_20250305': {
301
322
  const args = await validateTypes({
302
323
  value: tool.args,
@@ -330,6 +351,23 @@ export async function prepareTools({
330
351
  });
331
352
  break;
332
353
  }
354
+ case 'anthropic.web_search_20260318': {
355
+ const args = await validateTypes({
356
+ value: tool.args,
357
+ schema: webSearch_20260318ArgsSchema,
358
+ });
359
+ anthropicTools.push({
360
+ type: 'web_search_20260318',
361
+ name: 'web_search',
362
+ max_uses: args.maxUses,
363
+ allowed_domains: args.allowedDomains,
364
+ blocked_domains: args.blockedDomains,
365
+ user_location: args.userLocation,
366
+ response_inclusion: args.responseInclusion,
367
+ cache_control: undefined,
368
+ });
369
+ break;
370
+ }
333
371
 
334
372
  case 'anthropic.tool_search_regex_20251119': {
335
373
  anthropicTools.push({
@@ -14,8 +14,10 @@ import { textEditor_20250429 } from './tool/text-editor_20250429';
14
14
  import { textEditor_20250728 } from './tool/text-editor_20250728';
15
15
  import { toolSearchBm25_20251119 } from './tool/tool-search-bm25_20251119';
16
16
  import { toolSearchRegex_20251119 } from './tool/tool-search-regex_20251119';
17
+ import { webFetch_20260318 } from './tool/web-fetch-20260318';
17
18
  import { webFetch_20260209 } from './tool/web-fetch-20260209';
18
19
  import { webFetch_20250910 } from './tool/web-fetch-20250910';
20
+ import { webSearch_20260318 } from './tool/web-search_20260318';
19
21
  import { webSearch_20260209 } from './tool/web-search_20260209';
20
22
  import { webSearch_20250305 } from './tool/web-search_20250305';
21
23
 
@@ -219,6 +221,19 @@ export const anthropicTools = {
219
221
  */
220
222
  webFetch_20260209,
221
223
 
224
+ /**
225
+ * Creates a web fetch tool that gives Claude direct access to real-time web content.
226
+ *
227
+ * @param maxUses - The max_uses parameter limits the number of web fetches performed
228
+ * @param allowedDomains - Only fetch from these domains
229
+ * @param blockedDomains - Never fetch from these domains
230
+ * @param citations - Unlike web search where citations are always enabled, citations are optional for web fetch. Set "citations": {"enabled": true} to enable Claude to cite specific passages from fetched documents.
231
+ * @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
232
+ * @param useCache - Whether cached content may be returned. Set to false to fetch fresh content.
233
+ * @param responseInclusion - Whether result blocks consumed by completed code execution calls are returned. Defaults to "full".
234
+ */
235
+ webFetch_20260318,
236
+
222
237
  /**
223
238
  * Creates a web search tool that gives Claude direct access to real-time web content.
224
239
  *
@@ -239,6 +254,17 @@ export const anthropicTools = {
239
254
  */
240
255
  webSearch_20260209,
241
256
 
257
+ /**
258
+ * Creates a web search tool that gives Claude direct access to real-time web content.
259
+ *
260
+ * @param maxUses - Maximum number of web searches Claude can perform during the conversation.
261
+ * @param allowedDomains - Optional list of domains that Claude is allowed to search.
262
+ * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
263
+ * @param userLocation - Optional user location information to provide geographically relevant search results.
264
+ * @param responseInclusion - Whether result blocks consumed by completed code execution calls are returned. Defaults to "full".
265
+ */
266
+ webSearch_20260318,
267
+
242
268
  /**
243
269
  * Creates a tool search tool that uses regex patterns to find tools.
244
270
  *
@@ -1007,7 +1007,8 @@ export async function convertToAnthropicPrompt({
1007
1007
  }
1008
1008
 
1009
1009
  // to distinguish between code execution 20250522, 20250825,
1010
- // and encrypted results (from web_fetch_20260209/web_search_20260209 injection),
1010
+ // and encrypted results from implicitly provisioned code
1011
+ // execution for dynamic web tools,
1011
1012
  // we check the type property in output.value
1012
1013
  if (output.value.type === 'code_execution_result') {
1013
1014
  // code execution 20250522
@@ -1140,9 +1141,9 @@ export async function convertToAnthropicPrompt({
1140
1141
  break;
1141
1142
  }
1142
1143
 
1143
- // ideally we'd switch schema based on the tool version (e.g.
1144
- // web_fetch_20260209 vs web_fetch_20250910), but since both
1145
- // versions share an identical output schema, we use one here.
1144
+ // ideally we'd switch schema based on the tool version, but
1145
+ // all supported versions share an identical output schema,
1146
+ // so we use one here.
1146
1147
  const webFetchOutput = await validateTypes({
1147
1148
  value: output.value,
1148
1149
  schema: webFetch_20250910OutputSchema,
@@ -1205,9 +1206,9 @@ export async function convertToAnthropicPrompt({
1205
1206
  break;
1206
1207
  }
1207
1208
 
1208
- // ideally we'd switch schema based on the tool version (e.g.
1209
- // web_search_20260209 vs web_search_20250305), but since both
1210
- // versions share an identical output schema, we use one here.
1209
+ // ideally we'd switch schema based on the tool version, but
1210
+ // all supported versions share an identical output schema,
1211
+ // so we use one here.
1211
1212
  const webSearchOutput = await validateTypes({
1212
1213
  value: output.value,
1213
1214
  schema: webSearch_20250305OutputSchema,
@@ -0,0 +1,159 @@
1
+ import {
2
+ createProviderExecutedToolFactory,
3
+ lazySchema,
4
+ zodSchema,
5
+ } from '@ai-sdk/provider-utils';
6
+ import { z } from 'zod/v4';
7
+
8
+ export const webFetch_20260318ArgsSchema = lazySchema(() =>
9
+ zodSchema(
10
+ z.object({
11
+ maxUses: z.number().optional(),
12
+ allowedDomains: z.array(z.string()).optional(),
13
+ blockedDomains: z.array(z.string()).optional(),
14
+ citations: z.object({ enabled: z.boolean() }).optional(),
15
+ maxContentTokens: z.number().optional(),
16
+ useCache: z.boolean().optional(),
17
+ responseInclusion: z.enum(['full', 'excluded']).optional(),
18
+ }),
19
+ ),
20
+ );
21
+
22
+ export const webFetch_20260318OutputSchema = lazySchema(() =>
23
+ zodSchema(
24
+ z.object({
25
+ type: z.literal('web_fetch_result'),
26
+ url: z.string(),
27
+ content: z.object({
28
+ type: z.literal('document'),
29
+ title: z.string().nullable(),
30
+ citations: z.object({ enabled: z.boolean() }).optional(),
31
+ source: z.union([
32
+ z.object({
33
+ type: z.literal('base64'),
34
+ mediaType: z.literal('application/pdf'),
35
+ data: z.string(),
36
+ }),
37
+ z.object({
38
+ type: z.literal('text'),
39
+ mediaType: z.literal('text/plain'),
40
+ data: z.string(),
41
+ }),
42
+ ]),
43
+ }),
44
+ retrievedAt: z.string().nullable(),
45
+ }),
46
+ ),
47
+ );
48
+
49
+ const webFetch_20260318InputSchema = lazySchema(() =>
50
+ zodSchema(
51
+ z.object({
52
+ url: z.string(),
53
+ }),
54
+ ),
55
+ );
56
+
57
+ const factory = createProviderExecutedToolFactory<
58
+ {
59
+ /**
60
+ * The URL to fetch.
61
+ */
62
+ url: string;
63
+ },
64
+ {
65
+ type: 'web_fetch_result';
66
+
67
+ /**
68
+ * Fetched content URL
69
+ */
70
+ url: string;
71
+
72
+ /**
73
+ * Fetched content.
74
+ */
75
+ content: {
76
+ type: 'document';
77
+
78
+ /**
79
+ * Title of the document
80
+ */
81
+ title: string | null;
82
+
83
+ /**
84
+ * Citation configuration for the document
85
+ */
86
+ citations?: { enabled: boolean };
87
+
88
+ source:
89
+ | {
90
+ type: 'base64';
91
+ mediaType: 'application/pdf';
92
+ data: string;
93
+ }
94
+ | {
95
+ type: 'text';
96
+ mediaType: 'text/plain';
97
+ data: string;
98
+ };
99
+ };
100
+
101
+ /**
102
+ * ISO 8601 timestamp when the content was retrieved
103
+ */
104
+ retrievedAt: string | null;
105
+ },
106
+ {
107
+ /**
108
+ * The maxUses parameter limits the number of web fetches performed
109
+ */
110
+ maxUses?: number;
111
+
112
+ /**
113
+ * Only fetch from these domains
114
+ */
115
+ allowedDomains?: string[];
116
+
117
+ /**
118
+ * Never fetch from these domains
119
+ */
120
+ blockedDomains?: string[];
121
+
122
+ /**
123
+ * Unlike web search where citations are always enabled, citations are optional for
124
+ * web fetch. Set "citations": {"enabled": true} to enable Claude to cite specific passages
125
+ * from fetched documents.
126
+ */
127
+ citations?: {
128
+ enabled: boolean;
129
+ };
130
+
131
+ /**
132
+ * The maxContentTokens parameter limits the amount of content that will be included in the context.
133
+ */
134
+ maxContentTokens?: number;
135
+
136
+ /**
137
+ * Whether cached content may be returned. Set to `false` to fetch fresh
138
+ * content. Defaults to `true`.
139
+ */
140
+ useCache?: boolean;
141
+
142
+ /**
143
+ * Controls whether web fetch result blocks consumed by completed code
144
+ * execution calls are included in the response. Defaults to `full`.
145
+ */
146
+ responseInclusion?: 'full' | 'excluded';
147
+ }
148
+ >({
149
+ id: 'anthropic.web_fetch_20260318',
150
+ inputSchema: webFetch_20260318InputSchema,
151
+ outputSchema: webFetch_20260318OutputSchema,
152
+ supportsDeferredResults: true,
153
+ });
154
+
155
+ export const webFetch_20260318 = (
156
+ args: Parameters<typeof factory>[0] = {}, // default
157
+ ) => {
158
+ return factory(args);
159
+ };
@@ -0,0 +1,143 @@
1
+ import {
2
+ createProviderExecutedToolFactory,
3
+ lazySchema,
4
+ zodSchema,
5
+ } from '@ai-sdk/provider-utils';
6
+ import { z } from 'zod/v4';
7
+
8
+ export const webSearch_20260318ArgsSchema = lazySchema(() =>
9
+ zodSchema(
10
+ z.object({
11
+ maxUses: z.number().optional(),
12
+ allowedDomains: z.array(z.string()).optional(),
13
+ blockedDomains: z.array(z.string()).optional(),
14
+ userLocation: z
15
+ .object({
16
+ type: z.literal('approximate'),
17
+ city: z.string().optional(),
18
+ region: z.string().optional(),
19
+ country: z.string().optional(),
20
+ timezone: z.string().optional(),
21
+ })
22
+ .optional(),
23
+ responseInclusion: z.enum(['full', 'excluded']).optional(),
24
+ }),
25
+ ),
26
+ );
27
+
28
+ export const webSearch_20260318OutputSchema = lazySchema(() =>
29
+ zodSchema(
30
+ z.array(
31
+ z.object({
32
+ url: z.string(),
33
+ title: z.string().nullable(),
34
+ pageAge: z.string().nullable(),
35
+ encryptedContent: z.string(),
36
+ type: z.literal('web_search_result'),
37
+ }),
38
+ ),
39
+ ),
40
+ );
41
+
42
+ const webSearch_20260318InputSchema = lazySchema(() =>
43
+ zodSchema(
44
+ z.object({
45
+ query: z.string(),
46
+ }),
47
+ ),
48
+ );
49
+
50
+ const factory = createProviderExecutedToolFactory<
51
+ {
52
+ /**
53
+ * The search query to execute.
54
+ */
55
+ query: string;
56
+ },
57
+ Array<{
58
+ type: 'web_search_result';
59
+
60
+ /**
61
+ * The URL of the source page.
62
+ */
63
+ url: string;
64
+
65
+ /**
66
+ * The title of the source page.
67
+ */
68
+ title: string | null;
69
+
70
+ /**
71
+ * When the site was last updated
72
+ */
73
+ pageAge: string | null;
74
+
75
+ /**
76
+ * Encrypted content that must be passed back in multi-turn conversations for citations
77
+ */
78
+ encryptedContent: string;
79
+ }>,
80
+ {
81
+ /**
82
+ * Maximum number of web searches Claude can perform during the conversation.
83
+ */
84
+ maxUses?: number;
85
+
86
+ /**
87
+ * Optional list of domains that Claude is allowed to search.
88
+ */
89
+ allowedDomains?: string[];
90
+
91
+ /**
92
+ * Optional list of domains that Claude should avoid when searching.
93
+ */
94
+ blockedDomains?: string[];
95
+
96
+ /**
97
+ * Optional user location information to provide geographically relevant search results.
98
+ */
99
+ userLocation?: {
100
+ /**
101
+ * The type of location (must be approximate)
102
+ */
103
+ type: 'approximate';
104
+
105
+ /**
106
+ * The city name
107
+ */
108
+ city?: string;
109
+
110
+ /**
111
+ * The region or state
112
+ */
113
+ region?: string;
114
+
115
+ /**
116
+ * The country
117
+ */
118
+ country?: string;
119
+
120
+ /**
121
+ * The IANA timezone ID.
122
+ */
123
+ timezone?: string;
124
+ };
125
+
126
+ /**
127
+ * Controls whether web search result blocks consumed by completed code
128
+ * execution calls are included in the response. Defaults to `full`.
129
+ */
130
+ responseInclusion?: 'full' | 'excluded';
131
+ }
132
+ >({
133
+ id: 'anthropic.web_search_20260318',
134
+ inputSchema: webSearch_20260318InputSchema,
135
+ outputSchema: webSearch_20260318OutputSchema,
136
+ supportsDeferredResults: true,
137
+ });
138
+
139
+ export const webSearch_20260318 = (
140
+ args: Parameters<typeof factory>[0] = {}, // default
141
+ ) => {
142
+ return factory(args);
143
+ };