From 55cb36edfe7a5c60d036fc8dcaf82a5af4fd71ab Mon Sep 17 00:00:00 2001 From: Google Team Member Date: Mon, 26 May 2025 00:20:22 -0700 Subject: [PATCH] Add handling for None param.annotation. This is the case for function tools that have no return value. PiperOrigin-RevId: 763306054 --- src/google/adk/tools/function_parameter_parse_util.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/google/adk/tools/function_parameter_parse_util.py b/src/google/adk/tools/function_parameter_parse_util.py index d1a1794..5cda5ba 100644 --- a/src/google/adk/tools/function_parameter_parse_util.py +++ b/src/google/adk/tools/function_parameter_parse_util.py @@ -289,6 +289,13 @@ def _parse_schema_from_parameter( ) _raise_if_schema_unsupported(variant, schema) return schema + if param.annotation is None: + # https://swagger.io/docs/specification/v3_0/data-models/data-types/#null + # null is not a valid type in schema, use object instead. + schema.type = types.Type.OBJECT + schema.nullable = True + _raise_if_schema_unsupported(variant, schema) + return schema raise ValueError( f'Failed to parse the parameter {param} of function {func_name} for' ' automatic function calling. Automatic function calling works best with'