-
Notifications
You must be signed in to change notification settings - Fork 21
ClientError 400 INVALID_ARGUMENT: missing thought_signature when using tool calling with any gemini-3 model (thinking model) #274
Description
Description
When registering a tool with register_tool() and calling chat() using a Google thinking/reasoning model (e.g. gemini-3-flash-preview), the request fails with a 400 INVALID_ARGUMENT error. The Google API reports that the thought_signature field is missing from the functionCall parts of the request.
According to Google's documentation, thinking models require a thought_signature to be forwarded when tool call results are returned in subsequent turns. This suggests that chatlas is not preserving or forwarding this signature when handling tool responses for thinking models.
Minimal Reproducible Example:
from chatlas import ChatGoogle
from os import getenv
chat_client = ChatGoogle(
api_key=getenv("GOOGLE_API_KEY"),
model="gemini-3-flash-preview",
system_prompt="You answer questions about number sums. Use the sum_tool.",
)
def sum_tool(a: int, b: int) -> int:
"""A function that sums two numbers.
Args:
a (int): The first number.
b (int): The second number.
Returns:
int: The sum of a and b.
"""
return a + b
chat_client.register_tool(sum_tool)
chat_client.chat("What is 12345 + 54321?")Output
# 🔧 tool request (1ix307fu)
sum_tool(b=54321, a=12345)
# ✅ tool result (1ix307fu)
66666
ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Function call is missing a thought_signature in functionCall parts. This is required for tools to work correctly, and missing thought_signature may lead to degraded model performance. Additional data, function call `default_api:sum_tool` , position 2. Please refer to https://ai.google.dev/gemini-api/docs/thought-signatures for more details.', 'status': 'INVALID_ARGUMENT'}}
Cell In[14], line 1
----> 1 chat_client.chat("What is 12345 + 54321?")Observation
The tool call is correctly invoked by the model (visible in the chat echo output as sum_tool(a=12345, b=54321)), but when chatlas sends the tool result back to the API in the next turn, the thought_signature from the original functionCall part is not included, causing the API to reject the request.
Environment
| Package | Version |
|---|---|
| Python | 3.13.12 |
| chatlas | 0.15.3.dev1+g01584d2c0 |
| google-genai | 1.68.0 |
| OS | Linux |