Skip to content

Google GenAI - Bug in GoogleGenAIChatGenerator when thinking budget is set to 0 #2845

@fkdosilovic

Description

@fkdosilovic

Describe the bug

There is a bug in GoogleGenAIChatGenerator when it's used with Vertex AI API, default model (gemini-2.5-flash) and thinking budget is set to 0. Here's the error returned by the system:

RuntimeError: Thinking configuration error for model 'gemini-2.5-flash': 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Unable to submit request because Thinking_config.include_thoughts is only enabled when thinking is enabled.. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini', 'status': 'INVALID_ARGUMENT'}}
The model may not support thinking features or the thinking_budget value may be invalid. Try removing the 'thinking_budget' parameter from generation_kwargs or use a different model.

The problem is with the ThinkingConfig.include_thoughts config in line 845 that should be set based on the thinking_budget or should be left to the user to set in generation_config dictionary, but it is currently set always to True.

To Reproduce

from haystack.dataclasses import ChatMessage
from haystack_integrations.components.generators.google_genai import (
    GoogleGenAIChatGenerator,
)

chat_generator = GoogleGenAIChatGenerator(
    api="vertex",
    vertex_ai_project="<gcp-project>",
    vertex_ai_location="global",
    generation_kwargs={"thinking_budget": 0},
)

response = chat_generator.run(
    messages=[ChatMessage.from_user("How many r's are there in strawberry?")]
)
print(f"{response=}")

Describe your environment (please complete the following information):

  • OS: MacOS
  • Haystack version: 2.24.1
  • Integration version: google-genai-haystack (v3.4.0)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions