Description
When using @ai-sdk/google-vertex with Gemini models (e.g. gemini-3.5-flash) via streamText, tool calls work correctly at the LLM reasoning step, but sending the tool result back causes a 400 Bad Request from the Gemini API. Plain text-only responses work fine.
Error message received:
Invalid JSON payload received. Unknown name "id" at 'contents[1].parts[0].function_call': Cannot find field.
Invalid JSON payload received. Unknown name "id" at 'contents[2].parts[0].function_response': Cannot find field.
Steps to reproduce
- Set up an agent using
streamText with @ai-sdk/google-vertex targeting gemini-3.5-flash.
- Define at least one tool.
- Send a prompt that causes the model to invoke a tool.
- Return the tool result to continue the conversation.
- Observe
400 from aiplatform.googleapis.com on the second turn.
Environment
| Package |
Version |
| ai |
^6.0.82 |
| @ai-sdk/google-vertex |
^4.0.142 |
| Node.js |
22 |
| Runtime |
Node |
Error payload
{
"errorUrl": "https://aiplatform.googleapis.com/v1/publishers/google/models/gemini-3.5-flash:streamGenerateContent?alt=sse",
"modelName": "gemini-3.5-flash",
"errorMessage": "Invalid JSON payload received. Unknown name \"id\" at 'contents[1].parts[0].function_call': Cannot find field.\nInvalid JSON payload received. Unknown name \"id\" at 'contents[2].parts[0].function_response': Cannot find field.",
"errorStatusCode": 400
}
- This only reproduces on multi-turn conversations where a tool call is made and a result is returned — single-turn text-only completions are unaffected.
- Other providers (e.g. OpenAI, Anthropic) are not affected since they accept or require the
id field.
- This may be a regression introduced when normalizing tool call message shapes across providers in the v6 message format.
- This only reproduces on multi-turn conversations where a tool call is made and a result is returned — single-turn text-only completions are unaffected.
- Other providers (e.g. OpenAI, Anthropic) are not affected since they accept or require the
id field.
- This may be a regression introduced when normalizing tool call message shapes across providers in the v6 message format.
Description
When using
@ai-sdk/google-vertexwith Gemini models (e.g.gemini-3.5-flash) viastreamText, tool calls work correctly at the LLM reasoning step, but sending the tool result back causes a400 Bad Requestfrom the Gemini API. Plain text-only responses work fine.Error message received:
Steps to reproduce
streamTextwith@ai-sdk/google-vertextargetinggemini-3.5-flash.400fromaiplatform.googleapis.comon the second turn.Environment
Error payload
idfield.idfield.