Skip to content

fix(vertex): add fallback for providerOptions key#12403

Merged
aayush-kapoor merged 2 commits intomainfrom
aayush/vertex-thought-signature
Feb 12, 2026
Merged

fix(vertex): add fallback for providerOptions key#12403
aayush-kapoor merged 2 commits intomainfrom
aayush/vertex-thought-signature

Conversation

@aayush-kapoor
Copy link
Copy Markdown
Collaborator

Background

multi step tool calls fail because the thoughtSignature gets lost due to a key mismatch in providerOptions.
if the thoughtSignature is passed under the google key, the vertex provider silently drops it. the api then rejects the request and we see the errors as observed in #12351

Summary

fallback check to see if vertex key doesn't have a thoughtSignature, we check if it's passed within the google key

Manual Verification

verified via the repro code given in the original issue, which is resolved after the fix

Checklist

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Related Issues

fixes #12351

@vercel-ai-sdk vercel-ai-sdk bot added ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label provider/azure Issues related to the @ai-sdk/azure provider labels Feb 10, 2026
@buibaoanh
Copy link
Copy Markdown

The fix is incomplete as we expect google under providerMetadata, right now it is vertex.

@buibaoanh
Copy link
Copy Markdown

From a user perspective:

Step 1: Tool Call Generation (Output)

(i) What I put in: A generateText call using @ai-sdk/google-vertex with a Gemini 3 thinking model.

(ii) What I get back: The reasoning state is returned under providerMetadata: { vertex: { thoughtSignature: "..." } }.

(iii) Expected behavior: Per Google Cloud Documentation, the thoughtSignature is a native field of the Gemini Part object. It should be returned under the google namespace to maintain consistency with the Google AI provider and allow for universal history persistence.

Step 2: Tool Result Resumption (Input)

(i) What I put in: I pass the history back to the Vertex provider. Following the standard convention, the signature is provided under the google namespace.

(ii) What I get back: A 500 Internal Server Error from Vertex AI.

(iii) Expected behavior: The model should resume reasoning.

@aayush-kapoor
Copy link
Copy Markdown
Collaborator Author

i verified the fix for the reproduction code snippet you provided and the pr fixed the error! so assuming the bug only produces in a setup like your repro, the fix should be enough.

we specifically allow keeping vertex as provider option key name since there were previous requests of doing so for keeping a track when using vertex provider.

under the hood, you can rest assure that the needed providerOptions are passed how the endpoint expects them

@buibaoanh
Copy link
Copy Markdown

If user set providerOptions with key google, let's say thinkingConfig, right now what I got is vertex in providerMetadata.

I would expect google in providerMetadata as stated in Vertex AI and for consistency reason.

I noticed that providerOptionsName is selected by hardcoded provider Name for @ai-sdk/google-vertex instead of provider key in providerOptions in this logic.

Comment on lines +87 to +89
(providerOptionsName !== 'google'
? part.providerOptions?.google
: undefined);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be simplified to just part.providerOptions?.google? (it would double lookup and return undefined in the negative case but i dont think that is an issue)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm i tried that and it leads to a regression with some other tests. it would basically ignore any options set under a key which is not google (which wouldn't work in the case of vertex provider, where we added this change recently)

@aayush-kapoor
Copy link
Copy Markdown
Collaborator Author

@buibaoanh the mapping isn't 1-1 if you compare it to google's sdk but that is by design of the AI SDK

there is a reason for why it's mapped to vertex instead of google and you can see here and here why

the ideal dx for setting providerOptions when using vertex provider is that the user defines the key to be vertex

@buibaoanh
Copy link
Copy Markdown

@aayush-kapoor Ok, what about google-vertex docs refer to google as namespace for both providerOptions and providerMetadata?

@aayush-kapoor
Copy link
Copy Markdown
Collaborator Author

@buibaoanh thanks for pointing out, will update the docs

@aayush-kapoor aayush-kapoor merged commit 051361b into main Feb 12, 2026
24 checks passed
@aayush-kapoor aayush-kapoor deleted the aayush/vertex-thought-signature branch February 12, 2026 17:30
aayush-kapoor added a commit that referenced this pull request Feb 18, 2026
## Background

as a follow up to this comment:
#12403 (comment)

## Checklist

- [ ] na ~~Tests have been added / updated (for bug fixes / features)~~
- [x] Documentation has been added / updated (for bug fixes / features)
- [ ] na ~~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)
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 provider/azure Issues related to the @ai-sdk/azure provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@ai-sdk/google-vertex drops thoughtSignature in multi-step tool calls due to namespace desync

3 participants