Skip to content

@ai-sdk/google-vertex — Tool call/result messages include id field rejected by Gemini API (400 on function_call / function_response) #15891

Description

@nareshtank001

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

  1. Set up an agent using streamText with @ai-sdk/google-vertex targeting gemini-3.5-flash.
  2. Define at least one tool.
  3. Send a prompt that causes the model to invoke a tool.
  4. Return the tool result to continue the conversation.
  5. 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.

Metadata

Metadata

Assignees

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions