@ai-sdk/anthropic 3.0.100 → 3.0.102

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 3.0.102
4
+
5
+ ### Patch Changes
6
+
7
+ - b4c4426: feat (provider/anthropic): support fallbacks 'default' mode, which routes safety classifier refusals to Anthropic's recommended fallback model (adds the server-side-fallback-2026-07-01 beta automatically)
8
+ - b4c4426: feat (provider/anthropic): support mid-conversation tool changes via the toolChanges system message provider option, emitting tool_addition/tool_removal content blocks and the mid-conversation-tool-changes-2026-07-01 beta
9
+ - b4c4426: feat (provider/anthropic): add claude-opus-5 model id with frontier-tier capabilities (128k output tokens, structured output, adaptive thinking, xhigh effort, sampling parameter rejection, thinking-disabled only at effort high or below)
10
+
11
+ ## 3.0.101
12
+
13
+ ### Patch Changes
14
+
15
+ - 0608dca: fix (provider/anthropic): use current-generation capability defaults for unrecognized Claude model IDs while retaining conservative defaults for legacy Claude and non-Claude models.
16
+
3
17
  ## 3.0.100
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -184,7 +184,20 @@ interface AnthropicMessageMetadata {
184
184
  } | null;
185
185
  }
186
186
 
187
- type AnthropicMessagesModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | 'claude-opus-4-8' | 'claude-fable-5' | 'claude-sonnet-5' | (string & {});
187
+ type AnthropicMessagesModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-fable-5' | 'claude-sonnet-5' | (string & {});
188
+ /**
189
+ * Anthropic provider options for system messages.
190
+ */
191
+ declare const anthropicSystemMessageProviderOptions: z.ZodObject<{
192
+ toolChanges: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
193
+ type: z.ZodLiteral<"tool_addition">;
194
+ toolName: z.ZodString;
195
+ }, z.core.$strip>, z.ZodObject<{
196
+ type: z.ZodLiteral<"tool_removal">;
197
+ toolName: z.ZodString;
198
+ }, z.core.$strip>]>>>;
199
+ }, z.core.$strip>;
200
+ type AnthropicSystemMessageProviderOptions = z.infer<typeof anthropicSystemMessageProviderOptions>;
188
201
  declare const anthropicLanguageModelOptions: z.ZodObject<{
189
202
  sendReasoning: z.ZodOptional<z.ZodBoolean>;
190
203
  structuredOutputMode: z.ZodOptional<z.ZodEnum<{
@@ -251,7 +264,7 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
251
264
  us: "us";
252
265
  global: "global";
253
266
  }>>;
254
- fallbacks: z.ZodOptional<z.ZodArray<z.ZodObject<{
267
+ fallbacks: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"default">, z.ZodArray<z.ZodObject<{
255
268
  model: z.ZodString;
256
269
  max_tokens: z.ZodOptional<z.ZodNumber>;
257
270
  thinking: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -260,7 +273,7 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
260
273
  fast: "fast";
261
274
  standard: "standard";
262
275
  }>>;
263
- }, z.core.$strip>>>;
276
+ }, z.core.$strip>>]>>;
264
277
  anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
265
278
  contextManagement: z.ZodOptional<z.ZodObject<{
266
279
  edits: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -1224,4 +1237,4 @@ declare function forwardAnthropicContainerIdFromLastStep({ steps, }: {
1224
1237
 
1225
1238
  declare const VERSION: string;
1226
1239
 
1227
- export { type AnthropicLanguageModelOptions, type AnthropicMessageMetadata, type AnthropicProvider, type AnthropicLanguageModelOptions as AnthropicProviderOptions, type AnthropicProviderSettings, type AnthropicToolOptions, type AnthropicUsageIteration, VERSION, anthropic, createAnthropic, forwardAnthropicContainerIdFromLastStep };
1240
+ export { type AnthropicLanguageModelOptions, type AnthropicMessageMetadata, type AnthropicProvider, type AnthropicLanguageModelOptions as AnthropicProviderOptions, type AnthropicProviderSettings, type AnthropicSystemMessageProviderOptions, type AnthropicToolOptions, type AnthropicUsageIteration, VERSION, anthropic, createAnthropic, forwardAnthropicContainerIdFromLastStep };
package/dist/index.d.ts CHANGED
@@ -184,7 +184,20 @@ interface AnthropicMessageMetadata {
184
184
  } | null;
185
185
  }
186
186
 
187
- type AnthropicMessagesModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | 'claude-opus-4-8' | 'claude-fable-5' | 'claude-sonnet-5' | (string & {});
187
+ type AnthropicMessagesModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-fable-5' | 'claude-sonnet-5' | (string & {});
188
+ /**
189
+ * Anthropic provider options for system messages.
190
+ */
191
+ declare const anthropicSystemMessageProviderOptions: z.ZodObject<{
192
+ toolChanges: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
193
+ type: z.ZodLiteral<"tool_addition">;
194
+ toolName: z.ZodString;
195
+ }, z.core.$strip>, z.ZodObject<{
196
+ type: z.ZodLiteral<"tool_removal">;
197
+ toolName: z.ZodString;
198
+ }, z.core.$strip>]>>>;
199
+ }, z.core.$strip>;
200
+ type AnthropicSystemMessageProviderOptions = z.infer<typeof anthropicSystemMessageProviderOptions>;
188
201
  declare const anthropicLanguageModelOptions: z.ZodObject<{
189
202
  sendReasoning: z.ZodOptional<z.ZodBoolean>;
190
203
  structuredOutputMode: z.ZodOptional<z.ZodEnum<{
@@ -251,7 +264,7 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
251
264
  us: "us";
252
265
  global: "global";
253
266
  }>>;
254
- fallbacks: z.ZodOptional<z.ZodArray<z.ZodObject<{
267
+ fallbacks: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"default">, z.ZodArray<z.ZodObject<{
255
268
  model: z.ZodString;
256
269
  max_tokens: z.ZodOptional<z.ZodNumber>;
257
270
  thinking: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -260,7 +273,7 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
260
273
  fast: "fast";
261
274
  standard: "standard";
262
275
  }>>;
263
- }, z.core.$strip>>>;
276
+ }, z.core.$strip>>]>>;
264
277
  anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
265
278
  contextManagement: z.ZodOptional<z.ZodObject<{
266
279
  edits: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -1224,4 +1237,4 @@ declare function forwardAnthropicContainerIdFromLastStep({ steps, }: {
1224
1237
 
1225
1238
  declare const VERSION: string;
1226
1239
 
1227
- export { type AnthropicLanguageModelOptions, type AnthropicMessageMetadata, type AnthropicProvider, type AnthropicLanguageModelOptions as AnthropicProviderOptions, type AnthropicProviderSettings, type AnthropicToolOptions, type AnthropicUsageIteration, VERSION, anthropic, createAnthropic, forwardAnthropicContainerIdFromLastStep };
1240
+ export { type AnthropicLanguageModelOptions, type AnthropicMessageMetadata, type AnthropicProvider, type AnthropicLanguageModelOptions as AnthropicProviderOptions, type AnthropicProviderSettings, type AnthropicSystemMessageProviderOptions, type AnthropicToolOptions, type AnthropicUsageIteration, VERSION, anthropic, createAnthropic, forwardAnthropicContainerIdFromLastStep };
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ var import_provider4 = require("@ai-sdk/provider");
32
32
  var import_provider_utils26 = require("@ai-sdk/provider-utils");
33
33
 
34
34
  // src/version.ts
35
- var VERSION = true ? "3.0.100" : "0.0.0-test";
35
+ var VERSION = true ? "3.0.102" : "0.0.0-test";
36
36
 
37
37
  // src/anthropic-messages-language-model.ts
38
38
  var import_provider3 = require("@ai-sdk/provider");
@@ -894,6 +894,34 @@ var anthropicFilePartProviderOptions = import_v43.z.object({
894
894
  */
895
895
  context: import_v43.z.string().optional()
896
896
  });
897
+ var anthropicSystemMessageProviderOptions = import_v43.z.object({
898
+ /**
899
+ * Mid-conversation tool changes. Adds or removes tools from the
900
+ * conversation's tool set between turns without invalidating the prompt
901
+ * cache.
902
+ *
903
+ * Only supported on system messages that appear mid-conversation (not the
904
+ * initial system prompt). A system message carrying tool changes must come
905
+ * right before an assistant message or at the end of the messages.
906
+ *
907
+ * Tools referenced by a `tool_addition` must be declared in the `tools`
908
+ * option (typically with `deferLoading: true` so they are not loaded until
909
+ * the addition surfaces them). The required
910
+ * `mid-conversation-tool-changes-2026-07-01` beta is added automatically.
911
+ */
912
+ toolChanges: import_v43.z.array(
913
+ import_v43.z.discriminatedUnion("type", [
914
+ import_v43.z.object({
915
+ type: import_v43.z.literal("tool_addition"),
916
+ toolName: import_v43.z.string()
917
+ }),
918
+ import_v43.z.object({
919
+ type: import_v43.z.literal("tool_removal"),
920
+ toolName: import_v43.z.string()
921
+ })
922
+ ])
923
+ ).optional()
924
+ });
897
925
  var anthropicLanguageModelOptions = import_v43.z.object({
898
926
  /**
899
927
  * Whether to send reasoning to the model.
@@ -1033,30 +1061,35 @@ var anthropicLanguageModelOptions = import_v43.z.object({
1033
1061
  */
1034
1062
  inferenceGeo: import_v43.z.enum(["us", "global"]).optional(),
1035
1063
  /**
1036
- * Server-side fallback chain.
1064
+ * Server-side fallback configuration.
1037
1065
  *
1038
1066
  * When the primary model's safety classifiers block a turn, the API
1039
- * automatically retries it on the next model in the chain, server-side. A
1040
- * `content-filter` finish reason means the entire chain refused.
1067
+ * automatically retries it server-side on a fallback model. A
1068
+ * `content-filter` finish reason means the fallback(s) refused as well.
1041
1069
  *
1042
- * Each entry is merged into the request as a direct request to that entry's
1043
- * model, so it must be formatted accordingly: `model` is required, and an
1044
- * entry may additionally override `max_tokens`, `thinking`, `output_config`,
1045
- * and `speed` for that attempt only (`speed` additionally requires the speed
1046
- * beta). The value is passed through to the API as-is.
1047
- *
1048
- * The required `server-side-fallback-2026-06-01` beta is added automatically
1049
- * when this option is set.
1070
+ * - `'default'` (recommended): the API routes the retry to Anthropic's
1071
+ * recommended fallback model based on the refusal category. Requires the
1072
+ * `server-side-fallback-2026-07-01` beta, which is added automatically.
1073
+ * - Array form: an explicit fallback chain. Each entry is merged into the
1074
+ * request as a direct request to that entry's model, so it must be
1075
+ * formatted accordingly: `model` is required, and an entry may
1076
+ * additionally override `max_tokens`, `thinking`, `output_config`, and
1077
+ * `speed` for that attempt only (`speed` additionally requires the speed
1078
+ * beta). The value is passed through to the API as-is, and the
1079
+ * `server-side-fallback-2026-06-01` beta is added automatically.
1050
1080
  */
1051
- fallbacks: import_v43.z.array(
1052
- import_v43.z.object({
1053
- model: import_v43.z.string(),
1054
- max_tokens: import_v43.z.number().int().optional(),
1055
- thinking: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).optional(),
1056
- output_config: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).optional(),
1057
- speed: import_v43.z.enum(["fast", "standard"]).optional()
1058
- })
1059
- ).optional(),
1081
+ fallbacks: import_v43.z.union([
1082
+ import_v43.z.literal("default"),
1083
+ import_v43.z.array(
1084
+ import_v43.z.object({
1085
+ model: import_v43.z.string(),
1086
+ max_tokens: import_v43.z.number().int().optional(),
1087
+ thinking: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).optional(),
1088
+ output_config: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).optional(),
1089
+ speed: import_v43.z.enum(["fast", "standard"]).optional()
1090
+ })
1091
+ )
1092
+ ]).optional(),
1060
1093
  /**
1061
1094
  * A set of beta features to enable.
1062
1095
  * Allow a provider to receive the full `betas` set if it needs it.
@@ -2214,7 +2247,7 @@ async function convertToAnthropicMessagesPrompt({
2214
2247
  cacheControlValidator,
2215
2248
  toolNameMapping
2216
2249
  }) {
2217
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
2250
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
2218
2251
  const betas = /* @__PURE__ */ new Set();
2219
2252
  const blocks = groupIntoBlocks(prompt);
2220
2253
  const validator = cacheControlValidator || new CacheControlValidator();
@@ -2246,19 +2279,52 @@ async function convertToAnthropicMessagesPrompt({
2246
2279
  const type = block.type;
2247
2280
  switch (type) {
2248
2281
  case "system": {
2249
- const content = block.messages.map(({ content: content2, providerOptions }) => ({
2250
- type: "text",
2251
- text: content2,
2252
- cache_control: validator.getCacheControl(providerOptions, {
2253
- type: "system message",
2254
- canCache: true
2255
- })
2256
- }));
2257
- if (system == null) {
2258
- system = content;
2282
+ const content = [];
2283
+ let toolChangeCount = 0;
2284
+ for (const { content: text, providerOptions } of block.messages) {
2285
+ const systemMessageOptions = await (0, import_provider_utils14.parseProviderOptions)({
2286
+ provider: "anthropic",
2287
+ providerOptions,
2288
+ schema: anthropicSystemMessageProviderOptions
2289
+ });
2290
+ const toolChanges = (_a = systemMessageOptions == null ? void 0 : systemMessageOptions.toolChanges) != null ? _a : [];
2291
+ if (text !== "" || toolChanges.length === 0) {
2292
+ content.push({
2293
+ type: "text",
2294
+ text,
2295
+ cache_control: validator.getCacheControl(providerOptions, {
2296
+ type: "system message",
2297
+ canCache: true
2298
+ })
2299
+ });
2300
+ }
2301
+ for (const toolChange of toolChanges) {
2302
+ toolChangeCount++;
2303
+ content.push({
2304
+ type: toolChange.type,
2305
+ tool: {
2306
+ type: "tool_reference",
2307
+ name: toolNameMapping.toProviderToolName(toolChange.toolName)
2308
+ }
2309
+ });
2310
+ }
2311
+ }
2312
+ if (i === 0 || system == null && toolChangeCount === 0) {
2313
+ if (toolChangeCount > 0) {
2314
+ warnings.push({
2315
+ type: "other",
2316
+ message: "tool changes on the initial system message are not supported by Anthropic. Configure the initial tool set via the tools option instead. The tool changes have been ignored."
2317
+ });
2318
+ }
2319
+ system = content.filter(
2320
+ (part) => part.type === "text"
2321
+ );
2259
2322
  } else {
2260
2323
  messages.push({ role: "system", content });
2261
2324
  betas.add("mid-conversation-system-2026-04-07");
2325
+ if (toolChangeCount > 0) {
2326
+ betas.add("mid-conversation-tool-changes-2026-07-01");
2327
+ }
2262
2328
  }
2263
2329
  break;
2264
2330
  }
@@ -2271,10 +2337,10 @@ async function convertToAnthropicMessagesPrompt({
2271
2337
  for (let j = 0; j < content.length; j++) {
2272
2338
  const part = content[j];
2273
2339
  const isLastPart = j === content.length - 1;
2274
- const cacheControl = (_a = validator.getCacheControl(part.providerOptions, {
2340
+ const cacheControl = (_b = validator.getCacheControl(part.providerOptions, {
2275
2341
  type: "user message part",
2276
2342
  canCache: true
2277
- })) != null ? _a : isLastPart ? validator.getCacheControl(message.providerOptions, {
2343
+ })) != null ? _b : isLastPart ? validator.getCacheControl(message.providerOptions, {
2278
2344
  type: "user message",
2279
2345
  canCache: true
2280
2346
  }) : void 0;
@@ -2319,7 +2385,7 @@ async function convertToAnthropicMessagesPrompt({
2319
2385
  media_type: "application/pdf",
2320
2386
  data: (0, import_provider_utils14.convertToBase64)(part.data)
2321
2387
  },
2322
- title: (_b = metadata.title) != null ? _b : part.filename,
2388
+ title: (_c = metadata.title) != null ? _c : part.filename,
2323
2389
  ...metadata.context && { context: metadata.context },
2324
2390
  ...enableCitations && {
2325
2391
  citations: { enabled: true }
@@ -2343,7 +2409,7 @@ async function convertToAnthropicMessagesPrompt({
2343
2409
  media_type: "text/plain",
2344
2410
  data: convertToString(part.data)
2345
2411
  },
2346
- title: (_c = metadata.title) != null ? _c : part.filename,
2412
+ title: (_d = metadata.title) != null ? _d : part.filename,
2347
2413
  ...metadata.context && { context: metadata.context },
2348
2414
  ...enableCitations && {
2349
2415
  citations: { enabled: true }
@@ -2368,17 +2434,17 @@ async function convertToAnthropicMessagesPrompt({
2368
2434
  continue;
2369
2435
  }
2370
2436
  const output = part.output;
2371
- const outputProviderOptions = "providerOptions" in output ? output.providerOptions : output.type === "content" ? (_d = output.value.find(
2437
+ const outputProviderOptions = "providerOptions" in output ? output.providerOptions : output.type === "content" ? (_e = output.value.find(
2372
2438
  (contentPart) => contentPart.providerOptions != null
2373
- )) == null ? void 0 : _d.providerOptions : void 0;
2439
+ )) == null ? void 0 : _e.providerOptions : void 0;
2374
2440
  const isLastPart = i2 === content.length - 1;
2375
- const cacheControl = (_f = (_e = validator.getCacheControl(part.providerOptions, {
2441
+ const cacheControl = (_g = (_f = validator.getCacheControl(part.providerOptions, {
2376
2442
  type: "tool result part",
2377
2443
  canCache: true
2378
- })) != null ? _e : validator.getCacheControl(outputProviderOptions, {
2444
+ })) != null ? _f : validator.getCacheControl(outputProviderOptions, {
2379
2445
  type: "tool result output",
2380
2446
  canCache: true
2381
- })) != null ? _f : isLastPart ? validator.getCacheControl(message.providerOptions, {
2447
+ })) != null ? _g : isLastPart ? validator.getCacheControl(message.providerOptions, {
2382
2448
  type: "tool result message",
2383
2449
  canCache: true
2384
2450
  }) : void 0;
@@ -2468,7 +2534,7 @@ async function convertToAnthropicMessagesPrompt({
2468
2534
  contentValue = output.value;
2469
2535
  break;
2470
2536
  case "execution-denied":
2471
- contentValue = (_g = output.reason) != null ? _g : "Tool call execution denied.";
2537
+ contentValue = (_h = output.reason) != null ? _h : "Tool call execution denied.";
2472
2538
  break;
2473
2539
  case "json":
2474
2540
  case "error-json":
@@ -2505,16 +2571,16 @@ async function convertToAnthropicMessagesPrompt({
2505
2571
  for (let k = 0; k < content.length; k++) {
2506
2572
  const part = content[k];
2507
2573
  const isLastContentPart = k === content.length - 1;
2508
- const cacheControl = (_h = validator.getCacheControl(part.providerOptions, {
2574
+ const cacheControl = (_i = validator.getCacheControl(part.providerOptions, {
2509
2575
  type: "assistant message part",
2510
2576
  canCache: true
2511
- })) != null ? _h : isLastContentPart ? validator.getCacheControl(message.providerOptions, {
2577
+ })) != null ? _i : isLastContentPart ? validator.getCacheControl(message.providerOptions, {
2512
2578
  type: "assistant message",
2513
2579
  canCache: true
2514
2580
  }) : void 0;
2515
2581
  switch (part.type) {
2516
2582
  case "text": {
2517
- const textMetadata = (_i = part.providerOptions) == null ? void 0 : _i.anthropic;
2583
+ const textMetadata = (_j = part.providerOptions) == null ? void 0 : _j.anthropic;
2518
2584
  if ((textMetadata == null ? void 0 : textMetadata.type) === "compaction") {
2519
2585
  anthropicContent.push({
2520
2586
  type: "compaction",
@@ -2590,10 +2656,10 @@ async function convertToAnthropicMessagesPrompt({
2590
2656
  const providerToolName = toolNameMapping.toProviderToolName(
2591
2657
  part.toolName
2592
2658
  );
2593
- const isMcpToolUse = ((_k = (_j = part.providerOptions) == null ? void 0 : _j.anthropic) == null ? void 0 : _k.type) === "mcp-tool-use";
2659
+ const isMcpToolUse = ((_l = (_k = part.providerOptions) == null ? void 0 : _k.anthropic) == null ? void 0 : _l.type) === "mcp-tool-use";
2594
2660
  if (isMcpToolUse) {
2595
2661
  mcpToolUseIds.add(part.toolCallId);
2596
- const serverName = (_m = (_l = part.providerOptions) == null ? void 0 : _l.anthropic) == null ? void 0 : _m.serverName;
2662
+ const serverName = (_n = (_m = part.providerOptions) == null ? void 0 : _m.anthropic) == null ? void 0 : _n.serverName;
2597
2663
  if (serverName == null || typeof serverName !== "string") {
2598
2664
  warnings.push({
2599
2665
  type: "other",
@@ -2669,7 +2735,7 @@ async function convertToAnthropicMessagesPrompt({
2669
2735
  }
2670
2736
  break;
2671
2737
  }
2672
- const callerOptions = (_n = part.providerOptions) == null ? void 0 : _n.anthropic;
2738
+ const callerOptions = (_o = part.providerOptions) == null ? void 0 : _o.anthropic;
2673
2739
  const caller = (callerOptions == null ? void 0 : callerOptions.caller) ? (callerOptions.caller.type === "code_execution_20250825" || callerOptions.caller.type === "code_execution_20260120") && callerOptions.caller.toolId ? {
2674
2740
  type: callerOptions.caller.type,
2675
2741
  tool_id: callerOptions.caller.toolId
@@ -2722,7 +2788,7 @@ async function convertToAnthropicMessagesPrompt({
2722
2788
  tool_use_id: part.toolCallId,
2723
2789
  content: {
2724
2790
  type: "code_execution_tool_result_error",
2725
- error_code: (_o = errorInfo.errorCode) != null ? _o : "unknown"
2791
+ error_code: (_p = errorInfo.errorCode) != null ? _p : "unknown"
2726
2792
  },
2727
2793
  cache_control: cacheControl
2728
2794
  });
@@ -2733,7 +2799,7 @@ async function convertToAnthropicMessagesPrompt({
2733
2799
  cache_control: cacheControl,
2734
2800
  content: {
2735
2801
  type: "bash_code_execution_tool_result_error",
2736
- error_code: (_p = errorInfo.errorCode) != null ? _p : "unknown"
2802
+ error_code: (_q = errorInfo.errorCode) != null ? _q : "unknown"
2737
2803
  }
2738
2804
  });
2739
2805
  }
@@ -2766,7 +2832,7 @@ async function convertToAnthropicMessagesPrompt({
2766
2832
  stdout: codeExecutionOutput.stdout,
2767
2833
  stderr: codeExecutionOutput.stderr,
2768
2834
  return_code: codeExecutionOutput.return_code,
2769
- content: (_q = codeExecutionOutput.content) != null ? _q : []
2835
+ content: (_r = codeExecutionOutput.content) != null ? _r : []
2770
2836
  },
2771
2837
  cache_control: cacheControl
2772
2838
  });
@@ -2784,7 +2850,7 @@ async function convertToAnthropicMessagesPrompt({
2784
2850
  encrypted_stdout: codeExecutionOutput.encrypted_stdout,
2785
2851
  stderr: codeExecutionOutput.stderr,
2786
2852
  return_code: codeExecutionOutput.return_code,
2787
- content: (_r = codeExecutionOutput.content) != null ? _r : []
2853
+ content: (_s = codeExecutionOutput.content) != null ? _s : []
2788
2854
  },
2789
2855
  cache_control: cacheControl
2790
2856
  });
@@ -2803,7 +2869,7 @@ async function convertToAnthropicMessagesPrompt({
2803
2869
  stdout: codeExecutionOutput.stdout,
2804
2870
  stderr: codeExecutionOutput.stderr,
2805
2871
  return_code: codeExecutionOutput.return_code,
2806
- content: (_s = codeExecutionOutput.content) != null ? _s : []
2872
+ content: (_t = codeExecutionOutput.content) != null ? _t : []
2807
2873
  },
2808
2874
  cache_control: cacheControl
2809
2875
  });
@@ -2833,7 +2899,7 @@ async function convertToAnthropicMessagesPrompt({
2833
2899
  tool_use_id: part.toolCallId,
2834
2900
  content: {
2835
2901
  type: "web_fetch_tool_result_error",
2836
- error_code: (_t = (await extractErrorValue(output.value)).errorCode) != null ? _t : "unavailable"
2902
+ error_code: (_u = (await extractErrorValue(output.value)).errorCode) != null ? _u : "unavailable"
2837
2903
  },
2838
2904
  cache_control: cacheControl
2839
2905
  });
@@ -2880,7 +2946,7 @@ async function convertToAnthropicMessagesPrompt({
2880
2946
  tool_use_id: part.toolCallId,
2881
2947
  content: {
2882
2948
  type: "web_search_tool_result_error",
2883
- error_code: (_u = (await extractErrorValue(output.value)).errorCode) != null ? _u : "unavailable"
2949
+ error_code: (_v = (await extractErrorValue(output.value)).errorCode) != null ? _v : "unavailable"
2884
2950
  },
2885
2951
  cache_control: cacheControl
2886
2952
  });
@@ -3338,7 +3404,7 @@ var AnthropicMessagesLanguageModel = class {
3338
3404
  providerOptions,
3339
3405
  stream
3340
3406
  }) {
3341
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
3407
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
3342
3408
  const warnings = [];
3343
3409
  if (frequencyPenalty != null) {
3344
3410
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -3394,6 +3460,7 @@ var AnthropicMessagesLanguageModel = class {
3394
3460
  maxOutputTokens: maxOutputTokensForModel,
3395
3461
  supportsStructuredOutput: modelSupportsStructuredOutput,
3396
3462
  rejectsSamplingParameters,
3463
+ rejectsThinkingDisabledAboveHighEffort,
3397
3464
  isKnownModel
3398
3465
  } = getModelCapabilities(this.modelId);
3399
3466
  if (!isKnownModel && maxOutputTokens == null) {
@@ -3429,7 +3496,7 @@ var AnthropicMessagesLanguageModel = class {
3429
3496
  topP = void 0;
3430
3497
  }
3431
3498
  }
3432
- const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
3499
+ const isAnthropicModel = isKnownModel || this.modelId.includes("claude-");
3433
3500
  const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
3434
3501
  const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
3435
3502
  const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
@@ -3480,11 +3547,19 @@ var AnthropicMessagesLanguageModel = class {
3480
3547
  cacheControlValidator,
3481
3548
  toolNameMapping
3482
3549
  });
3483
- const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
3550
+ if (rejectsThinkingDisabledAboveHighEffort && ((_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type) === "disabled" && (anthropicOptions.effort === "xhigh" || anthropicOptions.effort === "max")) {
3551
+ warnings.push({
3552
+ type: "unsupported",
3553
+ feature: "providerOptions.anthropic.effort",
3554
+ details: `effort '${anthropicOptions.effort}' is not supported by ${this.modelId} when thinking is disabled. The effort has been lowered to 'high'.`
3555
+ });
3556
+ anthropicOptions.effort = "high";
3557
+ }
3558
+ const thinkingType = (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.type;
3484
3559
  const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
3485
3560
  const sendThinking = isThinking || thinkingType === "disabled";
3486
- let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
3487
- const thinkingDisplay = thinkingType === "adaptive" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.display : void 0;
3561
+ let thinkingBudget = thinkingType === "enabled" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.budgetTokens : void 0;
3562
+ const thinkingDisplay = thinkingType === "adaptive" ? (_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.display : void 0;
3488
3563
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
3489
3564
  const baseArgs = {
3490
3565
  // model id:
@@ -3531,13 +3606,13 @@ var AnthropicMessagesLanguageModel = class {
3531
3606
  ...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
3532
3607
  inference_geo: anthropicOptions.inferenceGeo
3533
3608
  },
3534
- ...(anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) && anthropicOptions.fallbacks.length > 0 && {
3609
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) != null && (anthropicOptions.fallbacks === "default" || anthropicOptions.fallbacks.length > 0) && {
3535
3610
  fallbacks: anthropicOptions.fallbacks
3536
3611
  },
3537
3612
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
3538
3613
  cache_control: anthropicOptions.cacheControl
3539
3614
  },
3540
- ...((_h = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _h.userId) != null && {
3615
+ ...((_i = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _i.userId) != null && {
3541
3616
  metadata: { user_id: anthropicOptions.metadata.userId }
3542
3617
  },
3543
3618
  // mcp servers:
@@ -3710,10 +3785,12 @@ var AnthropicMessagesLanguageModel = class {
3710
3785
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
3711
3786
  betas.add("fast-mode-2026-02-01");
3712
3787
  }
3713
- if ((anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) && anthropicOptions.fallbacks.length > 0) {
3788
+ if ((anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) === "default") {
3789
+ betas.add("server-side-fallback-2026-07-01");
3790
+ } else if ((anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) && anthropicOptions.fallbacks.length > 0) {
3714
3791
  betas.add("server-side-fallback-2026-06-01");
3715
3792
  }
3716
- const defaultEagerInputStreaming = stream && ((_i = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _i : true);
3793
+ const defaultEagerInputStreaming = stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true);
3717
3794
  const {
3718
3795
  tools: anthropicTools2,
3719
3796
  toolChoice: anthropicToolChoice,
@@ -3752,7 +3829,7 @@ var AnthropicMessagesLanguageModel = class {
3752
3829
  ...betas,
3753
3830
  ...toolsBetas,
3754
3831
  ...userSuppliedBetas,
3755
- ...(_j = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _j : []
3832
+ ...(_k = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _k : []
3756
3833
  ]),
3757
3834
  usesJsonResponseTool: jsonResponseTool != null,
3758
3835
  toolNameMapping,
@@ -5198,11 +5275,20 @@ var AnthropicMessagesLanguageModel = class {
5198
5275
  }
5199
5276
  };
5200
5277
  function getModelCapabilities(modelId) {
5201
- if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-fable-5") || modelId.includes("claude-sonnet-5")) {
5278
+ if (modelId.includes("claude-opus-5")) {
5202
5279
  return {
5203
5280
  maxOutputTokens: 128e3,
5204
5281
  supportsStructuredOutput: true,
5205
5282
  rejectsSamplingParameters: true,
5283
+ rejectsThinkingDisabledAboveHighEffort: true,
5284
+ isKnownModel: true
5285
+ };
5286
+ } else if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-fable-5") || modelId.includes("claude-sonnet-5")) {
5287
+ return {
5288
+ maxOutputTokens: 128e3,
5289
+ supportsStructuredOutput: true,
5290
+ rejectsSamplingParameters: true,
5291
+ rejectsThinkingDisabledAboveHighEffort: false,
5206
5292
  isKnownModel: true
5207
5293
  };
5208
5294
  } else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
@@ -5210,6 +5296,7 @@ function getModelCapabilities(modelId) {
5210
5296
  maxOutputTokens: 128e3,
5211
5297
  supportsStructuredOutput: true,
5212
5298
  rejectsSamplingParameters: false,
5299
+ rejectsThinkingDisabledAboveHighEffort: false,
5213
5300
  isKnownModel: true
5214
5301
  };
5215
5302
  } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
@@ -5217,6 +5304,7 @@ function getModelCapabilities(modelId) {
5217
5304
  maxOutputTokens: 64e3,
5218
5305
  supportsStructuredOutput: true,
5219
5306
  rejectsSamplingParameters: false,
5307
+ rejectsThinkingDisabledAboveHighEffort: false,
5220
5308
  isKnownModel: true
5221
5309
  };
5222
5310
  } else if (modelId.includes("claude-opus-4-1")) {
@@ -5224,6 +5312,7 @@ function getModelCapabilities(modelId) {
5224
5312
  maxOutputTokens: 32e3,
5225
5313
  supportsStructuredOutput: true,
5226
5314
  rejectsSamplingParameters: false,
5315
+ rejectsThinkingDisabledAboveHighEffort: false,
5227
5316
  isKnownModel: true
5228
5317
  };
5229
5318
  } else if (modelId.includes("claude-sonnet-4-")) {
@@ -5231,6 +5320,7 @@ function getModelCapabilities(modelId) {
5231
5320
  maxOutputTokens: 64e3,
5232
5321
  supportsStructuredOutput: false,
5233
5322
  rejectsSamplingParameters: false,
5323
+ rejectsThinkingDisabledAboveHighEffort: false,
5234
5324
  isKnownModel: true
5235
5325
  };
5236
5326
  } else if (modelId.includes("claude-opus-4-")) {
@@ -5238,6 +5328,7 @@ function getModelCapabilities(modelId) {
5238
5328
  maxOutputTokens: 32e3,
5239
5329
  supportsStructuredOutput: false,
5240
5330
  rejectsSamplingParameters: false,
5331
+ rejectsThinkingDisabledAboveHighEffort: false,
5241
5332
  isKnownModel: true
5242
5333
  };
5243
5334
  } else if (modelId.includes("claude-3-haiku")) {
@@ -5245,13 +5336,31 @@ function getModelCapabilities(modelId) {
5245
5336
  maxOutputTokens: 4096,
5246
5337
  supportsStructuredOutput: false,
5247
5338
  rejectsSamplingParameters: false,
5339
+ rejectsThinkingDisabledAboveHighEffort: false,
5248
5340
  isKnownModel: true
5249
5341
  };
5342
+ } else if (/claude-(?:instant(?:-|$)|v?2(?=$|[-.:])|3(?=$|[-.]))/.test(modelId)) {
5343
+ return {
5344
+ maxOutputTokens: 4096,
5345
+ supportsStructuredOutput: false,
5346
+ rejectsSamplingParameters: false,
5347
+ rejectsThinkingDisabledAboveHighEffort: false,
5348
+ isKnownModel: false
5349
+ };
5350
+ } else if (modelId.includes("claude-")) {
5351
+ return {
5352
+ maxOutputTokens: 128e3,
5353
+ supportsStructuredOutput: true,
5354
+ rejectsSamplingParameters: true,
5355
+ rejectsThinkingDisabledAboveHighEffort: true,
5356
+ isKnownModel: false
5357
+ };
5250
5358
  } else {
5251
5359
  return {
5252
5360
  maxOutputTokens: 4096,
5253
5361
  supportsStructuredOutput: false,
5254
5362
  rejectsSamplingParameters: false,
5363
+ rejectsThinkingDisabledAboveHighEffort: false,
5255
5364
  isKnownModel: false
5256
5365
  };
5257
5366
  }