google-genai-haystack 7.2.0__tar.gz → 7.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/CHANGELOG.md +14 -0
  2. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/PKG-INFO +1 -1
  3. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/generators/google_genai/chat/chat_generator.py +10 -8
  4. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/generators/google_genai/chat/utils.py +22 -4
  5. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/tests/test_chat_generator.py +59 -11
  6. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/tests/test_chat_generator_utils.py +74 -0
  7. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/.gitignore +0 -0
  8. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/LICENSE.txt +0 -0
  9. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/README.md +0 -0
  10. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/examples/chatgenerator_example.py +0 -0
  11. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/pydoc/config_docusaurus.yml +0 -0
  12. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/pyproject.toml +0 -0
  13. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/src/haystack_integrations/common/google_genai/__init__.py +0 -0
  14. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/src/haystack_integrations/common/google_genai/utils.py +0 -0
  15. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/src/haystack_integrations/common/py.typed +0 -0
  16. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/embedders/google_genai/__init__.py +0 -0
  17. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/embedders/google_genai/document_embedder.py +0 -0
  18. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/embedders/google_genai/multimodal_document_embedder.py +0 -0
  19. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/embedders/google_genai/text_embedder.py +0 -0
  20. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/embedders/py.typed +0 -0
  21. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/generators/google_genai/__init__.py +0 -0
  22. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/generators/google_genai/chat/interactions_chat_generator.py +0 -0
  23. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/generators/google_genai/chat/interactions_utils.py +0 -0
  24. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/generators/py.typed +0 -0
  25. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/src/haystack_integrations/token_counters/google_genai/__init__.py +0 -0
  26. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/src/haystack_integrations/token_counters/google_genai/token_counter.py +0 -0
  27. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/src/haystack_integrations/token_counters/py.typed +0 -0
  28. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/tests/conftest.py +0 -0
  29. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/tests/test_document_embedder.py +0 -0
  30. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/tests/test_files/apple.jpg +0 -0
  31. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/tests/test_files/banana.png +0 -0
  32. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/tests/test_files/sample_docx.docx +0 -0
  33. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/tests/test_files/sample_pdf_3.pdf +0 -0
  34. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/tests/test_interactions_chat_generator.py +0 -0
  35. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/tests/test_interactions_chat_generator_utils.py +0 -0
  36. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/tests/test_multimodal_document_embedder.py +0 -0
  37. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/tests/test_text_embedder.py +0 -0
  38. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/tests/test_token_counter.py +0 -0
  39. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.2}/tests/test_utils.py +0 -0
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [integrations/google_genai-v7.2.1] - 2026-11-06
4
+
5
+ ### 🐛 Bug Fixes
6
+
7
+ - Keep parallel Gemini tool calls when replaying thought signatures (#4167)
8
+
9
+
10
+ ## [integrations/google_genai-v7.2.0] - 2026-11-06
11
+
12
+ ### 🚀 Features
13
+
14
+ - *(google_genai)* Add `GoogleGenAIInteractionsChatGenerator` for the Gemini Interactions API (#4199)
15
+
16
+
3
17
  ## [integrations/google_genai-v7.1.0] - 2026-11-02
4
18
 
5
19
  ### 🐛 Bug Fixes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: google-genai-haystack
3
- Version: 7.2.0
3
+ Version: 7.2.2
4
4
  Summary: Use models like Gemini via Google Gen AI SDK
5
5
  Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/google_genai#readme
6
6
  Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
@@ -458,11 +458,12 @@ class GoogleGenAIChatGenerator:
458
458
  keys set only at initialization are kept. Supports `thinking_budget` for Gemini 2.5 series
459
459
  thinking configuration.
460
460
  :param safety_settings: Safety settings for content filtering. If provided, it will override the
461
- default settings.
461
+ default settings. Pass an empty list to send no safety settings for this call.
462
462
  :param streaming_callback: A callback function that is called when a new token is
463
463
  received from the stream.
464
464
  :param tools: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
465
- If provided, it will override the tools set during initialization.
465
+ If provided, it will override the tools set during initialization. Pass an empty list to disable tools for
466
+ this call.
466
467
  :returns: A dictionary with the following keys:
467
468
  - `replies`: A list containing the generated ChatMessage responses.
468
469
 
@@ -476,8 +477,8 @@ class GoogleGenAIChatGenerator:
476
477
  messages = _normalize_messages(messages)
477
478
  # Merge generation_kwargs with instance defaults; other configs fall back to instance defaults
478
479
  generation_kwargs = {**self._generation_kwargs, **(generation_kwargs or {})}
479
- safety_settings = safety_settings or self._safety_settings
480
- tools = tools or self._tools
480
+ safety_settings = safety_settings if safety_settings is not None else self._safety_settings
481
+ tools = tools if tools is not None else self._tools
481
482
 
482
483
  # Process thinking configuration and response format
483
484
  generation_kwargs = _process_thinking_config(generation_kwargs)
@@ -576,11 +577,12 @@ class GoogleGenAIChatGenerator:
576
577
  thinking configuration.
577
578
  See https://ai.google.dev/gemini-api/docs/thinking for possible values.
578
579
  :param safety_settings: Safety settings for content filtering. If provided, it will override the
579
- default settings.
580
+ default settings. Pass an empty list to send no safety settings for this call.
580
581
  :param streaming_callback: A callback function that is called when a new token is
581
582
  received from the stream.
582
583
  :param tools: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
583
- If provided, it will override the tools set during initialization.
584
+ If provided, it will override the tools set during initialization. Pass an empty list to disable tools for
585
+ this call.
584
586
  :returns: A dictionary with the following keys:
585
587
  - `replies`: A list containing the generated ChatMessage responses.
586
588
 
@@ -594,8 +596,8 @@ class GoogleGenAIChatGenerator:
594
596
  messages = _normalize_messages(messages)
595
597
  # Merge generation_kwargs with instance defaults; other configs fall back to instance defaults
596
598
  generation_kwargs = {**self._generation_kwargs, **(generation_kwargs or {})}
597
- safety_settings = safety_settings or self._safety_settings
598
- tools = tools or self._tools
599
+ safety_settings = safety_settings if safety_settings is not None else self._safety_settings
600
+ tools = tools if tools is not None else self._tools
599
601
 
600
602
  # Process thinking configuration and response format
601
603
  generation_kwargs = _process_thinking_config(generation_kwargs)
@@ -259,10 +259,13 @@ def _convert_message_to_google_genai_format(message: ChatMessage) -> types.Conte
259
259
  thought_signatures = message.meta.get("thought_signatures", []) if message.meta else []
260
260
 
261
261
  # If we have thought signatures, we need to reconstruct the exact part structure
262
- # from the previous assistant response to maintain multi-turn thinking context
262
+ # from the previous assistant response to maintain multi-turn thinking context.
263
+ # Gemini attaches a thought signature to the *first* function call of a parallel
264
+ # batch only, so unsigned tool calls / text must still be appended afterward.
263
265
  if thought_signatures and message.is_from(ChatRole.ASSISTANT):
264
266
  # Track which tool calls we've used (to handle multiple tool calls)
265
267
  tool_call_index = 0
268
+ included_non_thought_text = False
266
269
 
267
270
  # Reconstruct parts with their original thought signatures
268
271
  for sig_info in thought_signatures:
@@ -279,6 +282,7 @@ def _convert_message_to_google_genai_format(message: ChatMessage) -> types.Conte
279
282
  else:
280
283
  # Regular text part
281
284
  part_dict["text"] = message.text or ""
285
+ included_non_thought_text = True
282
286
 
283
287
  if sig_info.get("has_function_call"):
284
288
  # Find the corresponding tool call by index
@@ -295,6 +299,20 @@ def _convert_message_to_google_genai_format(message: ChatMessage) -> types.Conte
295
299
 
296
300
  parts.append(types.Part(**part_dict))
297
301
 
302
+ # Append parallel tool calls that had no thought signature of their own.
303
+ for tool_call in message.tool_calls[tool_call_index:]:
304
+ parts.append(
305
+ types.Part(
306
+ function_call=types.FunctionCall(
307
+ id=tool_call.id, name=tool_call.tool_name, args=tool_call.arguments
308
+ )
309
+ )
310
+ )
311
+
312
+ # Append unsigned text that was not covered by a signed text part.
313
+ if message.text and message.text.strip() and not included_non_thought_text:
314
+ parts.append(types.Part(text=message.text))
315
+
298
316
  # If we reconstructed from signatures, we're done
299
317
  if parts:
300
318
  role = "model" # Assistant messages with signatures are always from the model
@@ -763,9 +781,9 @@ def _aggregate_streaming_chunks_with_reasoning(chunks: list[StreamingChunk]) ->
763
781
  if chunk.meta and "thought_signature_deltas" in chunk.meta:
764
782
  signature_deltas = chunk.meta["thought_signature_deltas"]
765
783
  if isinstance(signature_deltas, list):
766
- # Aggregate thought signatures - they should come from the final chunks
767
- # We'll keep the last set of signatures as they represent the complete state
768
- thought_signatures = signature_deltas
784
+ # Accumulate across chunks: parallel tool-call signatures can arrive
785
+ # in earlier chunks, and replacing would drop them.
786
+ thought_signatures.extend(signature_deltas)
769
787
 
770
788
  # Extract token usage metadata (from the last chunk that has it)
771
789
  if chunk.meta and "usage" in chunk.meta:
@@ -459,7 +459,7 @@ class TestGoogleGenAIChatGeneratorRun:
459
459
  assert results["replies"][0].tool_calls[0].tool_name == "weather"
460
460
 
461
461
  def test_run_streaming_parallel_tool_calls_in_separate_chunks(self):
462
- component = GoogleGenAIChatGenerator(model="gemini-3-flash-preview")
462
+ component = GoogleGenAIChatGenerator(model="gemini-3.8-flash")
463
463
  component._client = MagicMock()
464
464
  component._client.models.generate_content_stream = Mock(return_value=iter(_parallel_call_stream_chunks()))
465
465
 
@@ -505,6 +505,19 @@ class TestGoogleGenAIChatGeneratorRun:
505
505
  config = call_kwargs.kwargs.get("config") or call_kwargs[1].get("config")
506
506
  assert config.tools is not None
507
507
 
508
+ def test_run_with_empty_tools_override(self, mock_response, tools):
509
+ # an empty runtime list must disable the init tools for this call, not fall back to them;
510
+ # generation_kwargs keeps a config object in the request so its tools can be inspected
511
+ component = GoogleGenAIChatGenerator(tools=tools, generation_kwargs={"temperature": 0.5})
512
+ component._client = MagicMock()
513
+ component._client.models.generate_content = Mock(return_value=mock_response)
514
+
515
+ component.run([ChatMessage.from_user("Weather in Paris?")])
516
+ assert component._client.models.generate_content.call_args.kwargs["config"].tools is not None
517
+
518
+ component.run([ChatMessage.from_user("Weather in Paris?")], tools=[])
519
+ assert component._client.models.generate_content.call_args.kwargs["config"].tools is None
520
+
508
521
  def test_run_with_safety_settings(self, mock_response):
509
522
  safety = [{"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"}]
510
523
  component = GoogleGenAIChatGenerator()
@@ -628,6 +641,45 @@ class TestGoogleGenAIChatGeneratorRun:
628
641
  assert config.temperature == 0.9
629
642
  assert config.max_output_tokens == 100
630
643
 
644
+ @pytest.mark.asyncio
645
+ async def test_run_async_with_empty_tools_override(self, mock_response, tools):
646
+ component = GoogleGenAIChatGenerator(tools=tools, generation_kwargs={"temperature": 0.5})
647
+ component._async_client = MagicMock()
648
+ component._async_client.models.generate_content = AsyncMock(return_value=mock_response)
649
+
650
+ await component.run_async([ChatMessage.from_user("Weather in Paris?")])
651
+ assert component._async_client.models.generate_content.call_args.kwargs["config"].tools is not None
652
+
653
+ await component.run_async([ChatMessage.from_user("Weather in Paris?")], tools=[])
654
+ assert component._async_client.models.generate_content.call_args.kwargs["config"].tools is None
655
+
656
+ def test_run_with_empty_safety_settings_override(self, mock_response):
657
+ # an empty runtime list must send no safety settings for this call, not fall back to the init ones;
658
+ # generation_kwargs keeps a config object in the request so its safety settings can be inspected
659
+ safety_settings = [{"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_LOW_AND_ABOVE"}]
660
+ component = GoogleGenAIChatGenerator(safety_settings=safety_settings, generation_kwargs={"temperature": 0.5})
661
+ component._client = MagicMock()
662
+ component._client.models.generate_content = Mock(return_value=mock_response)
663
+
664
+ component.run([ChatMessage.from_user("Hello")])
665
+ assert component._client.models.generate_content.call_args.kwargs["config"].safety_settings is not None
666
+
667
+ component.run([ChatMessage.from_user("Hello")], safety_settings=[])
668
+ assert component._client.models.generate_content.call_args.kwargs["config"].safety_settings is None
669
+
670
+ @pytest.mark.asyncio
671
+ async def test_run_async_with_empty_safety_settings_override(self, mock_response):
672
+ safety_settings = [{"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_LOW_AND_ABOVE"}]
673
+ component = GoogleGenAIChatGenerator(safety_settings=safety_settings, generation_kwargs={"temperature": 0.5})
674
+ component._async_client = MagicMock()
675
+ component._async_client.models.generate_content = AsyncMock(return_value=mock_response)
676
+
677
+ await component.run_async([ChatMessage.from_user("Hello")])
678
+ assert component._async_client.models.generate_content.call_args.kwargs["config"].safety_settings is not None
679
+
680
+ await component.run_async([ChatMessage.from_user("Hello")], safety_settings=[])
681
+ assert component._async_client.models.generate_content.call_args.kwargs["config"].safety_settings is None
682
+
631
683
  @pytest.mark.asyncio
632
684
  async def test_run_async_streaming(self, mock_streaming_chunk):
633
685
  component = GoogleGenAIChatGenerator()
@@ -680,7 +732,7 @@ class TestGoogleGenAIChatGeneratorRun:
680
732
 
681
733
  @pytest.mark.asyncio
682
734
  async def test_run_async_streaming_parallel_tool_calls_in_separate_chunks(self):
683
- component = GoogleGenAIChatGenerator(model="gemini-3-flash-preview")
735
+ component = GoogleGenAIChatGenerator(model="gemini-3.8-flash")
684
736
  component._async_client = MagicMock()
685
737
 
686
738
  async def mock_stream():
@@ -928,7 +980,7 @@ class TestGoogleGenAIChatGeneratorInference:
928
980
  "What's the weather like in Paris and Berlin? Produce a separate tool call for each city."
929
981
  )
930
982
  ]
931
- component = GoogleGenAIChatGenerator(model="gemini-3-flash-preview", tools=tools)
983
+ component = GoogleGenAIChatGenerator(model="gemini-3.8-flash", tools=tools)
932
984
  results = component.run(messages=initial_messages)
933
985
 
934
986
  assert len(results["replies"]) == 1
@@ -972,9 +1024,7 @@ class TestGoogleGenAIChatGeneratorInference:
972
1024
  """
973
1025
  # We use a model that supports the thinking feature
974
1026
  chat_messages = [ChatMessage.from_user("Why is the sky blue? Explain in one sentence.")]
975
- component = GoogleGenAIChatGenerator(
976
- model="gemini-3-flash-preview", generation_kwargs={"thinking_level": "low"}
977
- )
1027
+ component = GoogleGenAIChatGenerator(model="gemini-3.8-flash", generation_kwargs={"thinking_level": "medium"})
978
1028
  results = component.run(chat_messages)
979
1029
 
980
1030
  assert len(results["replies"]) == 1
@@ -999,7 +1049,7 @@ class TestGoogleGenAIChatGeneratorInference:
999
1049
  """
1000
1050
  # Use a model that supports thinking with tools
1001
1051
  component = GoogleGenAIChatGenerator(
1002
- model="gemini-3-flash-preview",
1052
+ model="gemini-3.8-flash",
1003
1053
  tools=tools,
1004
1054
  generation_kwargs={"thinking_level": "low"}, # Dynamic allocation
1005
1055
  )
@@ -1105,7 +1155,7 @@ class TestGoogleGenAIChatGeneratorInference:
1105
1155
  )
1106
1156
 
1107
1157
  agent = Agent(
1108
- chat_generator=GoogleGenAIChatGenerator(model="gemini-3-flash-preview"),
1158
+ chat_generator=GoogleGenAIChatGenerator(model="gemini-3.8-flash"),
1109
1159
  system_prompt="You are an Agent that can retrieve and analyze images and documents.",
1110
1160
  tools=[multimodal_retriever_tool],
1111
1161
  )
@@ -1188,9 +1238,7 @@ class TestAsyncGoogleGenAIChatGeneratorInference:
1188
1238
  Async integration test for the thinking feature.
1189
1239
  """
1190
1240
  chat_messages = [ChatMessage.from_user("Why is the sky blue? Explain in one sentence.")]
1191
- component = GoogleGenAIChatGenerator(
1192
- model="gemini-3-flash-preview", generation_kwargs={"thinking_level": "low"}
1193
- )
1241
+ component = GoogleGenAIChatGenerator(model="gemini-3.8-flash", generation_kwargs={"thinking_level": "medium"})
1194
1242
  results = await component.run_async(chat_messages)
1195
1243
 
1196
1244
  assert len(results["replies"]) == 1
@@ -705,6 +705,44 @@ class TestStreamingChunkConversion:
705
705
  assert "thought_signatures" in result.meta
706
706
  assert result.meta["thought_signatures"][0]["signature"] == "sig_xyz"
707
707
 
708
+ def test_aggregate_streaming_chunks_accumulates_thought_signatures_across_chunks(self):
709
+ """Signature deltas from earlier chunks must not be overwritten by later ones."""
710
+ model = "gemini-2.5-flash"
711
+ component_info = ComponentInfo.from_component(GoogleGenAIChatGenerator(model=model))
712
+ parts = [
713
+ types.Part(
714
+ text="Checking the weather.",
715
+ thought=True,
716
+ thought_signature=b"reasoning_signature",
717
+ ),
718
+ types.Part(
719
+ function_call=types.FunctionCall(name="get_weather", args={"city": "Paris"}),
720
+ thought_signature=b"tool_signature",
721
+ ),
722
+ ]
723
+ chunks = [
724
+ _convert_google_chunk_to_streaming_chunk(
725
+ chunk=types.GenerateContentResponse(
726
+ candidates=[types.Candidate(content=types.Content(role="model", parts=[part]))]
727
+ ),
728
+ index=index,
729
+ component_info=component_info,
730
+ model=model,
731
+ )
732
+ for index, part in enumerate(parts)
733
+ ]
734
+
735
+ result = _aggregate_streaming_chunks_with_reasoning(chunks)
736
+
737
+ assert result.reasoning.reasoning_text == "Checking the weather."
738
+ assert len(result.tool_calls) == 1
739
+ assert result.tool_calls[0].tool_name == "get_weather"
740
+ assert result.tool_calls[0].arguments == {"city": "Paris"}
741
+ assert [base64.b64decode(signature["signature"]) for signature in result.meta["thought_signatures"]] == [
742
+ b"reasoning_signature",
743
+ b"tool_signature",
744
+ ]
745
+
708
746
  def test_convert_google_chunk_to_streaming_chunk_with_cached_tokens(self, monkeypatch):
709
747
  """cached_content_token_count from usage_metadata is included in the streaming chunk's usage."""
710
748
  monkeypatch.setenv("GOOGLE_API_KEY", "test-api-key")
@@ -978,6 +1016,42 @@ class TestConvertMessageToGoogleGenAI:
978
1016
  assert google_content.parts[1].function_call.args == {"city": "Paris"}
979
1017
  assert google_content.parts[1].thought_signature == b"encrypted_mock_thought_signature_2"
980
1018
 
1019
+ def test_convert_message_keeps_parallel_tool_calls_without_thought_signatures(self):
1020
+ """Gemini signs only the first parallel function call; unsigned siblings must still be replayed."""
1021
+ paris = ToolCall(id="call_paris", tool_name="get_weather", arguments={"city": "Paris"})
1022
+ london = ToolCall(id="call_london", tool_name="get_weather", arguments={"city": "London"})
1023
+ thought_signatures = [
1024
+ {
1025
+ "part_index": 0,
1026
+ "signature": base64.b64encode(b"sig_on_first_only").decode("utf-8"),
1027
+ "has_text": False,
1028
+ "has_function_call": True,
1029
+ "is_thought": False,
1030
+ },
1031
+ ]
1032
+
1033
+ message = ChatMessage.from_assistant(
1034
+ text="Checking both cities",
1035
+ tool_calls=[paris, london],
1036
+ meta={"thought_signatures": thought_signatures},
1037
+ )
1038
+
1039
+ google_content = _convert_message_to_google_genai_format(message)
1040
+
1041
+ assert google_content.role == "model"
1042
+ assert len(google_content.parts) == 3
1043
+
1044
+ assert google_content.parts[0].function_call.name == "get_weather"
1045
+ assert google_content.parts[0].function_call.args == {"city": "Paris"}
1046
+ assert google_content.parts[0].thought_signature == b"sig_on_first_only"
1047
+
1048
+ assert google_content.parts[1].function_call.name == "get_weather"
1049
+ assert google_content.parts[1].function_call.args == {"city": "London"}
1050
+ assert not google_content.parts[1].thought_signature
1051
+
1052
+ assert google_content.parts[2].text == "Checking both cities"
1053
+ assert not google_content.parts[2].thought_signature
1054
+
981
1055
  def test_thought_signature_bytes_round_trip(self, monkeypatch):
982
1056
  """Raw (non UTF-8) thought signature bytes are stored as base64 strings and restored as bytes."""
983
1057
  monkeypatch.setenv("GOOGLE_API_KEY", "test-api-key")