Skip to content

Backport: fix(vertex): throw warning when strict: true for vertexAnthropic#13492

Merged
vercel-ai-sdk[bot] merged 1 commit intorelease-v6.0from
backport-pr-13353-to-release-v6.0
Mar 16, 2026
Merged

Backport: fix(vertex): throw warning when strict: true for vertexAnthropic#13492
vercel-ai-sdk[bot] merged 1 commit intorelease-v6.0from
backport-pr-13353-to-release-v6.0

Conversation

@vercel-ai-sdk
Copy link
Copy Markdown
Contributor

@vercel-ai-sdk vercel-ai-sdk bot commented Mar 16, 2026

This is an automated backport of #13353 to the release-v6.0 branch. FYI @aayush-kapoor

)

## 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
@vercel-ai-sdk vercel-ai-sdk bot enabled auto-merge (squash) March 16, 2026 18:41
@tigent tigent bot added ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label documentation Improvements or additions to documentation maintenance CI, internal documentation, automations, etc provider/amazon-bedrock Issues related to the @ai-sdk/amazon-bedrock provider provider/anthropic Issues related to the @ai-sdk/anthropic provider provider/google-vertex Issues related to the @ai-sdk/google-vertex provider labels Mar 16, 2026
@vercel-ai-sdk vercel-ai-sdk bot merged commit 2381567 into release-v6.0 Mar 16, 2026
31 checks passed
@vercel-ai-sdk vercel-ai-sdk bot deleted the backport-pr-13353-to-release-v6.0 branch March 16, 2026 18:55
@vercel-ai-sdk
Copy link
Copy Markdown
Contributor Author

vercel-ai-sdk bot commented Mar 16, 2026

🚀 Published in:

Package Version
ai 6.0.128
@ai-sdk/amazon-bedrock 4.0.80
@ai-sdk/angular 2.0.129
@ai-sdk/anthropic 3.0.61
@ai-sdk/gateway 3.0.74
@ai-sdk/google-vertex 4.0.90
@ai-sdk/langchain 2.0.134
@ai-sdk/llamaindex 2.0.128
@ai-sdk/react 3.0.130
@ai-sdk/rsc 2.0.128
@ai-sdk/svelte 4.0.128
@ai-sdk/vue 3.0.128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label documentation Improvements or additions to documentation maintenance CI, internal documentation, automations, etc provider/amazon-bedrock Issues related to the @ai-sdk/amazon-bedrock provider provider/anthropic Issues related to the @ai-sdk/anthropic provider provider/google-vertex Issues related to the @ai-sdk/google-vertex provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant