From 1c5be7ead40b731eff604b4d5cc4f819e3bc165d Mon Sep 17 00:00:00 2001 From: RKS Date: Tue, 8 Sep 2026 00:45:12 -0400 Subject: [PATCH 1/2] fix: add malformed response finish reason --- google/genai/tests/types/test_types.py | 9 ++++++++- google/genai/types.py | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/google/genai/tests/types/test_types.py b/google/genai/tests/types/test_types.py index 50a3f9058..189578a00 100644 --- a/google/genai/tests/types/test_types.py +++ b/google/genai/tests/types/test_types.py @@ -24,6 +24,14 @@ import pytest from ... import types + +def test_finish_reason_malformed_response(): + assert types.FinishReason.MALFORMED_RESPONSE.value == 'MALFORMED_RESPONSE' + assert ( + types.FinishReason('MALFORMED_RESPONSE') + is types.FinishReason.MALFORMED_RESPONSE + ) + _is_mcp_imported = False if typing.TYPE_CHECKING: from mcp import types as mcp_types @@ -2969,4 +2977,3 @@ def test_computer_use_types(): assert c.enable_prompt_injection_detection is True assert len(c.disabled_safety_policies) == 2 assert types.SafetyPolicy.FINANCIAL_TRANSACTIONS in c.disabled_safety_policies - diff --git a/google/genai/types.py b/google/genai/types.py index 24d739ee8..10b242c70 100644 --- a/google/genai/types.py +++ b/google/genai/types.py @@ -513,6 +513,8 @@ class FinishReason(_common.CaseInSensitiveEnum): """Token generation stopped because the content potentially contains Sensitive Personally Identifiable Information (SPII).""" MALFORMED_FUNCTION_CALL = 'MALFORMED_FUNCTION_CALL' """The function call generated by the model is invalid.""" + MALFORMED_RESPONSE = 'MALFORMED_RESPONSE' + """The model response was malformed.""" IMAGE_SAFETY = 'IMAGE_SAFETY' """Token generation stopped because generated images have safety violations.""" UNEXPECTED_TOOL_CALL = 'UNEXPECTED_TOOL_CALL' From 29ade9a659ca88b1961c2133f116eaf387644653 Mon Sep 17 00:00:00 2001 From: RKS Date: Tue, 8 Sep 2026 00:45:38 -0400 Subject: [PATCH 2/2] style: preserve test file spacing --- google/genai/tests/types/test_types.py | 1 + 1 file changed, 1 insertion(+) diff --git a/google/genai/tests/types/test_types.py b/google/genai/tests/types/test_types.py index 189578a00..7c06b85bb 100644 --- a/google/genai/tests/types/test_types.py +++ b/google/genai/tests/types/test_types.py @@ -2977,3 +2977,4 @@ def test_computer_use_types(): assert c.enable_prompt_injection_detection is True assert len(c.disabled_safety_policies) == 2 assert types.SafetyPolicy.FINANCIAL_TRANSACTIONS in c.disabled_safety_policies +