fix(vertex): throw warning when strict: true for vertexAnthropic#13353
Merged
aayush-kapoor merged 5 commits intomainfrom Mar 16, 2026
Merged
fix(vertex): throw warning when strict: true for vertexAnthropic#13353aayush-kapoor merged 5 commits intomainfrom
aayush-kapoor merged 5 commits intomainfrom
Conversation
This was referenced Mar 12, 2026
lgrammel
approved these changes
Mar 16, 2026
Collaborator
lgrammel
left a comment
There was a problem hiding this comment.
Do any provider docs need to be updated (e.g. add info boxes)?
Collaborator
Author
just added a small note to the providers that don't support it yet. couldn't find a better place than them other than the |
vercel-ai-sdk bot
pushed a commit
that referenced
this pull request
Mar 16, 2026
) ## Background #13167 When setting `strict: true` for tools and calling anthropic providers via the google vertex provider, the vertex provider doesn't accept the property `strict` and if passed - will throw an error that looks like this `{"type":"invalid_request_error","message":"tools.0.custom.strict: Extra inputs are not permitted"}` this behaviour needed to be documented via a warning so that users know the difference. ## Summary - introduced a `supportsStrictTools` property in both anthropic and the google-vertex provider - anthropic sets that value to true by default; google vertex is false - theconditional logic for setting strict: true for tools in anthropic provider now no longer depends on the `supportsStructuredOutput` flag ## Manual Verification <details> <summary>repro (run it before and after to observe warning) </summary> ```ts import { vertexAnthropic } from '@ai-sdk/google-vertex/anthropic'; import { generateText, tool } from 'ai'; import { z } from 'zod'; import { run } from '../../lib/run'; const conditions = [ { name: 'sunny', minTemperature: -5, maxTemperature: 35 }, { name: 'snowy', minTemperature: -10, maxTemperature: 0 }, { name: 'rainy', minTemperature: 0, maxTemperature: 15 }, { name: 'cloudy', minTemperature: 5, maxTemperature: 25 }, ]; run(async () => { const result = await generateText({ model: vertexAnthropic('claude-sonnet-4-6'), maxOutputTokens: 512, tools: { weather: tool({ description: 'Get weather by city and unit', inputSchema: z.object({ city: z.string(), unit: z.enum(['celsius', 'fahrenheit']), daysFromNow: z.number().min(1).default(1), }), execute: async ({ city }) => { const condition = conditions[Math.floor(Math.random() * conditions.length)]; return { city, condition: condition.name, temperature: Math.floor( Math.random() * (condition.maxTemperature - condition.minTemperature + 1), ) + condition.minTemperature, }; }, strict: true, }), cityAttractions: tool({ inputSchema: z.object({ city: z.string() }), }), }, prompt: 'What is the weather in San Francisco and what attractions should I visit?', }); for (const toolCall of result.toolCalls) { if (toolCall.dynamic) { continue; } switch (toolCall.toolName) { case 'cityAttractions': { toolCall.input.city; break; } case 'weather': { toolCall.input.city; break; } } } for (const toolResult of result.toolResults) { if (toolResult.dynamic) { continue; } switch (toolResult.toolName) { case 'weather': { toolResult.input.city; toolResult.output.city; toolResult.output.temperature; break; } } } console.log(JSON.stringify(result, null, 2)); }); ``` </details> the same code will throw an error if L183 in `packages/google-vertex/src/anthropic/google-vertex-anthropic-provider.ts` is changed to true (hence the warning) ## Checklist - [x] Tests have been added / updated (for bug fixes / features) - [ ] Documentation has been added / updated (for bug fixes / features) - [x] A _patch_ changeset for relevant packages has been added (for bug fixes / features - run `pnpm changeset` in the project root) - [x] I have reviewed this pull request (self-review) ## Related Issues fixes #13167
Contributor
|
✅ Backport PR created: #13492 |
vercel-ai-sdk bot
added a commit
that referenced
this pull request
Mar 16, 2026
…ropic (#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>
nlaz
added a commit
to FlatFilers/ai
that referenced
this pull request
Mar 30, 2026
Vertex Anthropic's rawPredict endpoint rejects cache_control on message content blocks with 400: "cache_control: Extra inputs are not permitted". Add a supportsCacheControl config flag (mirroring the existing supportsStrictTools pattern from PR vercel#13353) so the shared Anthropic code conditionally omits cache_control and emits a warning instead. Made-with: Cursor
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
#13167
When setting
strict: truefor tools and calling anthropic providers via the google vertex provider, the vertex provider doesn't accept the propertystrictand if passed - will throw an error that looks like this{"type":"invalid_request_error","message":"tools.0.custom.strict: Extra inputs are not permitted"}this behaviour needed to be documented via a warning so that users know the difference.
Summary
supportsStrictToolsproperty in both anthropic and the google-vertex providersupportsStructuredOutputflagManual Verification
repro (run it before and after to observe warning)
the same code will throw an error if L183 in
packages/google-vertex/src/anthropic/google-vertex-anthropic-provider.tsis changed to true (hence the warning)Checklist
pnpm changesetin the project root)Related Issues
fixes #13167