googleapis / googleapis/python-genai

AsyncChat.send_message_stream does not pass thought_signature with function calls

Open
#1,938 7 comments 0 reactions 1 assignee Assigned to @kkorpal View on GitHub
api: vertex-ai priority: p2 type: bug
Dominant language
Python
Stars
4k
Forks
1k
Avg merge
2d 11h
Merged PRs (30d)
40

Description

which leads to
```
google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Unable to submit request because function call `default_api:what_time_is_now` in the 2. content block is missing a `thought_signature`. Learn more: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/thought-signatures', 'status': 'INVALID_ARGUMENT'}}
```

#### Environment details

- Programming language: python 3.13
- OS: Ubuntu 24.04
- Package version: 1.57.0

#### Steps to reproduce

Can be reproduced with this script.

```python
import asyncio
import os

from google import genai
from google.genai.types import HttpOptions, GenerateContentConfig

client = genai.Client(
http_options=HttpOptions(api_version="v1"),
vertexai=True,
project=os.environ["GCP_PROJECT"],
location="global",
)

def what_date_is_today():
"""Get today's date in YYYY-MM-DD format."""
return "2023-04-20"

def what_time_is_now():
"""Get current time in HH:MM format."""
return "12:00"

async def main():
ai_chat = client.aio.chats.create(
model="gemini-3-pro-preview",
config=GenerateContentConfig(
temperature=0,
tools=([what_date_is_today, what_time_is_now]),
system_instruction="Answer what date and time is now",
),
)

async for chunk in await ai_chat.send_message_stream(
"What is the date and time now?"
):
print(chunk.text)
# fails with this error:
#
# File "/home/lev/stars/back/env/lib/python3.13/site-packages/google/genai/errors.py", line 225, in raise_error_async
# raise ClientError(status_code, response_json, response)
# google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Unable to submit request because function call `default_api:what_time_is_now` in the 2. content block is missing a `thought_signature`. Learn more: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/thought-signatures', 'status': 'INVALID_ARGUMENT'}}

if __name__ == "__main__":
asyncio.run(main())

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.