8000 Add handling for None param.annotation. · SVendittelli/adk-python@55cb36e · GitHub
[go: up one dir, main page]

Skip to content

Commit 55cb36e

Browse files
google-genai-botcopybara-github
authored andcommitted
Add handling for None param.annotation.
This is the case for function tools that have no return value. PiperOrigin-RevId: 763306054
1 parent 74a331f commit 55cb36e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/google/adk/tools/function_parameter_parse_util.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,13 @@ def _parse_schema_from_parameter(
289289
)
290290
_raise_if_schema_unsupported(variant, schema)
291291
return schema
292+
if param.annotation is None:
293+
# https://swagger.io/docs/specification/v3_0/data-models/data-types/#null
294+
# null is not a valid type in schema, use object instead.
295+
schema.type = types.Type.OBJECT
296+
schema.nullable = True
297+
_raise_if_schema_unsupported(variant, schema)
298+
return schema
292299
raise ValueError(
293300
f'Failed to parse the parameter {param} of function {func_name} for'
294301
' automatic function calling. Automatic function calling works best with'

0 commit comments

Comments
 (0)
0