Skip to content

Commit 2381567

Browse files
Backport: fix(vertex): throw warning when strict: true for vertexAnthropic (#13492)
This is an automated backport of #13353 to the release-v6.0 branch. FYI @aayush-kapoor Co-authored-by: Aayush Kapoor <83492835+aayush-kapoor@users.noreply.github.com>
1 parent afeaec0 commit 2381567

File tree

9 files changed

+133
-3
lines changed

9 files changed

+133
-3
lines changed

.changeset/ten-bobcats-breathe.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@ai-sdk/google-vertex': patch
3+
'@ai-sdk/anthropic': patch
4+
'@ai-sdk/amazon-bedrock': patch
5+
---
6+
7+
fix(vertex): throw warning when strict: true for vertexAnthropic

content/providers/01-ai-sdk-providers/08-amazon-bedrock.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,11 @@ Via Anthropic, Amazon Bedrock provides three provider-defined tools that can be
546546

547547
They are available via the `tools` property of the provider instance.
548548

549+
<Note>
550+
Amazon Bedrock does not support strict mode on tool definitions. Setting
551+
`strict: true` on a tool will be ignored and a warning will be emitted.
552+
</Note>
553+
549554
### Bash Tool
550555

551556
The Bash Tool allows running bash commands. Here's how to create and use it:

content/providers/01-ai-sdk-providers/16-google-vertex.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,12 @@ Google Vertex Anthropic supports a subset of Anthropic's built-in tools. The fol
15481548
`@ai-sdk/anthropic` provider if you need access to all Anthropic tools.
15491549
</Note>
15501550

1551+
<Note>
1552+
Google Vertex Anthropic does not support strict mode on tool definitions.
1553+
Setting `strict: true` on a tool will be ignored and a warning will be
1554+
emitted.
1555+
</Note>
1556+
15511557
For more background on Anthropic tools, see [Anthropic's documentation](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview).
15521558

15531559
#### Bash Tool

packages/amazon-bedrock/src/bedrock-prepare-tools.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export async function prepareTools({
8282
tools: ProviderTools,
8383
toolChoice,
8484
supportsStructuredOutput: false,
85+
supportsStrictTools: false,
8586
});
8687

8788
toolWarnings.push(...anthropicToolWarnings);

packages/anthropic/src/anthropic-messages-language-model.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ type AnthropicMessagesConfig = {
129129
* When false, the model will use JSON tool fallback for structured outputs.
130130
*/
131131
supportsNativeStructuredOutput?: boolean;
132+
133+
/**
134+
* When false, `strict` on tool definitions will be ignored and a warning emitted.
135+
* Defaults to true.
136+
*/
137+
supportsStrictTools?: boolean;
132138
};
133139

134140
export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
@@ -270,6 +276,10 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
270276
(this.config.supportsNativeStructuredOutput ?? true) &&
271277
modelSupportsStructuredOutput;
272278

279+
const supportsStrictTools =
280+
(this.config.supportsStrictTools ?? true) &&
281+
modelSupportsStructuredOutput;
282+
273283
const structureOutputMode =
274284
anthropicOptions?.structuredOutputMode ?? 'auto';
275285
const useStructuredOutput =
@@ -614,13 +624,15 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
614624
disableParallelToolUse: true,
615625
cacheControlValidator,
616626
supportsStructuredOutput: false,
627+
supportsStrictTools,
617628
}
618629
: {
619630
tools: tools ?? [],
620631
toolChoice,
621632
disableParallelToolUse: anthropicOptions?.disableParallelToolUse,
622633
cacheControlValidator,
623634
supportsStructuredOutput,
635+
supportsStrictTools,
624636
},
625637
);
626638

0 commit comments

Comments
 (0)