diff --git a/google/genai/tests/types/test_types.py b/google/genai/tests/types/test_types.py index 50a3f9058..7c06b85bb 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 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'