Skip to content

AsyncChat.send_message_stream does not pass thought_signature with function calls #1938

@weshnjakow

Description

@weshnjakow

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.

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())

Metadata

Metadata

Assignees

Labels

api: vertex-aiIssues related to the Vertex AI API.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

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions