Skip to content

Curated history not set for Gemini 3.X when using streaming #795

@kchoong-vA

Description

@kchoong-vA

I noticed an issue when using the new Gemini models 3.1 Flash Lite and 3.5 Flash with streaming and function calling.

I think it is related to how the new models generate/return chunks and parts, and how CuratedHistory is set in a chat instance when using streaming (details below). It works as expected with non-streaming, since the check before setting CuratedHistory is handled differently there.

Environment details

  • Programming language: Go
  • OS: macOS 26.5 (ARM64)
  • Language runtime version: 1.26
  • Package version: 1.57.0

Steps to reproduce

  1. Start a chat session using (c *Chats) Create and include tools in the config.
  2. Send a message to invoke the tools with SendMessageStream.
  3. The last chunk of the stream returns a content part list with a single element in which everything is empty and the finish reason is STOP.
  4. https://github.com/googleapis/go-genai/blob/main/chats.go#L239 marks it as invalid and does not store the candidate in CuratedHistory.
  5. When sending the tool results via SendMessageStream again, the CuratedHistory used is empty.
  6. The LLM responds in a way unrelated to the initial request.

Metadata

Metadata

Labels

api:gemini-apiIssues related to Gemini APIpriority: 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