@ai-sdk/amazon-bedrock 5.0.113 → 5.0.115

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.
@@ -4,7 +4,7 @@ let _ai_sdk_provider = require("@ai-sdk/provider");
4
4
  let _ai_sdk_provider_utils = require("@ai-sdk/provider-utils");
5
5
  let aws4fetch = require("aws4fetch");
6
6
  //#region src/version.ts
7
- const VERSION = "5.0.113";
7
+ const VERSION = "5.0.115";
8
8
  //#endregion
9
9
  //#region src/amazon-bedrock-sigv4-fetch.ts
10
10
  /**
@@ -3,7 +3,7 @@ import { InvalidArgumentError, NoSuchModelError } from "@ai-sdk/provider";
3
3
  import { combineHeaders, getRuntimeEnvironmentUserAgent, isValidHostnamePart, loadOptionalSetting, loadSetting, normalizeHeaders, withUserAgentSuffix, withoutTrailingSlash } from "@ai-sdk/provider-utils";
4
4
  import { AwsV4Signer } from "aws4fetch";
5
5
  //#region src/version.ts
6
- const VERSION = "5.0.113";
6
+ const VERSION = "5.0.115";
7
7
  //#endregion
8
8
  //#region src/amazon-bedrock-sigv4-fetch.ts
9
9
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/amazon-bedrock",
3
- "version": "5.0.113",
3
+ "version": "5.0.115",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -41,10 +41,10 @@
41
41
  }
42
42
  },
43
43
  "dependencies": {
44
- "@ai-sdk/anthropic": "4.0.78",
45
- "@ai-sdk/openai": "4.0.91",
46
- "@ai-sdk/provider": "4.0.26",
47
- "@ai-sdk/provider-utils": "5.0.58",
44
+ "@ai-sdk/anthropic": "4.0.79",
45
+ "@ai-sdk/openai": "4.0.93",
46
+ "@ai-sdk/provider": "4.0.27",
47
+ "@ai-sdk/provider-utils": "5.0.59",
48
48
  "@smithy/eventstream-codec": "^4.3.3",
49
49
  "@smithy/util-utf8": "^4.3.3",
50
50
  "aws4fetch": "^1.0.20"
@@ -17,37 +17,31 @@ export function isAnthropicModel({
17
17
  );
18
18
  }
19
19
 
20
+ // Bedrock validates its own Messages schema. New Claude generations currently
21
+ // reject native structured output and strict tools, so only known supported
22
+ // Claude models receive those fields. Non-Claude models and opaque inference
23
+ // profile IDs retain their existing behavior.
20
24
  export function supportsStrictTools(modelId: string): boolean {
21
- return !matchesModel(modelId, MODELS_WITHOUT_STRICT_TOOL_SUPPORT);
25
+ return (
26
+ !modelId.includes('claude-') ||
27
+ LEGACY_CLAUDE_PATTERN.test(modelId) ||
28
+ MODELS_WITH_STRICT_TOOL_SUPPORT.some(pattern => pattern.test(modelId))
29
+ );
22
30
  }
23
31
 
24
32
  export function supportsNativeStructuredOutput(modelId: string): boolean {
25
- return !matchesModel(
26
- modelId,
27
- MODELS_WITHOUT_RELIABLE_NATIVE_STRUCTURED_OUTPUT,
33
+ return (
34
+ supportsStrictTools(modelId) &&
35
+ !/claude-(?:sonnet-4-6|haiku-4-5)(?=[-.:]|$)/.test(modelId)
28
36
  );
29
37
  }
30
38
 
31
- // Bedrock validates against its own copy of the Messages schema, which rejects
32
- // `output_config.format` and tool `strict` for the newest Claude models
33
- const MODELS_WITHOUT_STRICT_TOOL_SUPPORT = [
34
- 'claude-opus-4-7',
35
- 'claude-opus-4-8',
36
- 'claude-opus-5',
37
- 'claude-fable-5',
38
- 'claude-sonnet-5',
39
- 'claude-haiku-5-5',
40
- ];
39
+ const LEGACY_CLAUDE_PATTERN = /claude-(?:instant|v?2|3)(?=[-.:]|$)/;
41
40
 
42
- // Native structured output is unreliable for additional models even though
43
- // their strict tool support remains available. Sonnet 4.6 can fail to adhere
44
- // to complex schemas, while Haiku 4.5 support varies between Bedrock accounts.
45
- const MODELS_WITHOUT_RELIABLE_NATIVE_STRUCTURED_OUTPUT = [
46
- ...MODELS_WITHOUT_STRICT_TOOL_SUPPORT,
47
- 'claude-sonnet-4-6',
48
- 'claude-haiku-4-5',
41
+ const MODELS_WITH_STRICT_TOOL_SUPPORT = [
42
+ // Original Claude 4 IDs include a release date instead of a minor version.
43
+ /claude-(?:opus|sonnet)-4(?:-\d{8})?(?:-v\d+)?(?=[:.]|$)/,
44
+ /claude-opus-4-(?:1|5|6)(?=[-.:]|$)/,
45
+ /claude-sonnet-4-(?:5|6)(?=[-.:]|$)/,
46
+ /claude-haiku-4-5(?=[-.:]|$)/,
49
47
  ];
50
-
51
- function matchesModel(modelId: string, models: string[]): boolean {
52
- return models.some(model => modelId.includes(model));
53
- }
@@ -178,6 +178,7 @@ export class AmazonBedrockChatLanguageModel implements LanguageModelV4 {
178
178
  supportsStructuredOutput: modelSupportsStructuredOutput,
179
179
  rejectsSamplingParameters,
180
180
  rejectsForcedToolUse,
181
+ isKnownModel,
181
182
  } = getModelCapabilities(this.modelId);
182
183
 
183
184
  if (frequencyPenalty != null) {
@@ -341,6 +342,10 @@ export class AmazonBedrockChatLanguageModel implements LanguageModelV4 {
341
342
  responseFormat?.type === 'json' &&
342
343
  responseFormat.schema != null &&
343
344
  (rejectsForcedToolUse ||
345
+ (this.modelId.includes('claude-') &&
346
+ (!isKnownModel || !modelSupportsStructuredOutput) &&
347
+ !supportsNativeStructuredOutput(this.modelId) &&
348
+ structuredOutputMode !== 'jsonTool') ||
344
349
  (structuredOutputMode !== 'jsonTool' &&
345
350
  !supportsStrictTools(this.modelId) &&
346
351
  tools != null &&