Skip to content

Streaming with Vertex AI produces empty parts in tool-calling follow-up requests #273

@piotresky

Description

@piotresky

Environment details

  • Programming language: C#
  • OS: Windows 11
  • Language runtime version: .NET 8
  • Package version: 1.6.1
  • Microsoft.Extensions.AI: 10.4.1

Steps to reproduce

  1. Configure the client with vertexAI: true
  2. Set up a chat client with FunctionInvocation middleware and a tool
  3. Send a prompt that triggers a tool call
  4. The first LLM call succeeds and returns a function call
  5. The follow-up LLM call (with tool results in history) fails with:
Google.GenAI.ClientError: Unable to submit request because it must include at least one parts field,
which describes the prompt input. Learn more:
https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini
using System.ComponentModel;
using Google.Apis.Auth.OAuth2;
using Google.GenAI;
using Microsoft.Extensions.AI;

var vertexClient = new Client(
        project: "my-project",
        vertexAI: true,
        location: "us-central1",
        credential: GoogleCredential.GetApplicationDefault())
    .AsIChatClient("gemini-3-flash-preview")
    .AsBuilder()
    .UseFunctionInvocation()
    .Build();

[Description("Gets the current weather for a city")]
string GetWeather(string city) => $"Weather in {city}: 22°C, sunny";

var options = new ChatOptions { Tools = [AIFunctionFactory.Create(GetWeather)] };

// This fails on the second LLM call (after tool execution) with Vertex AI.
// Works fine with API key mode.
await foreach (var update in vertexClient.GetStreamingResponseAsync(
    "What's the weather in Warsaw?", options))
{
    Console.Write(update.Text);
}

Observed behavior

The follow-up request (after tool execution) contains a Content object with an empty parts array: { "role": "model", "parts": [] }. Vertex AI rejects this. The Gemini API (API key mode) tolerates it and works correctly.

The issue was introduced in 1.6.1. Version 1.6.0 works correctly with Vertex AI.

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions