mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Safely handle FunctionDeclaration without a required attribute
Update `_function_declaration_to_tool_param` to use `getattr` when accessing the `required` field within `function_declaration.parameters`. This prevents `AttributeError` when a `FunctionDeclaration`'s parameters schema does not include a `required` attribute Close #2891 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 830225582
This commit is contained in:
committed by
Copybara-Service
parent
2882995289
commit
93aad61198
@@ -525,13 +525,13 @@ def _function_declaration_to_tool_param(
|
||||
},
|
||||
}
|
||||
|
||||
if (
|
||||
function_declaration.parameters
|
||||
and function_declaration.parameters.required
|
||||
):
|
||||
tool_params["function"]["parameters"][
|
||||
"required"
|
||||
] = function_declaration.parameters.required
|
||||
required_fields = (
|
||||
getattr(function_declaration.parameters, "required", None)
|
||||
if function_declaration.parameters
|
||||
else None
|
||||
)
|
||||
if required_fields:
|
||||
tool_params["function"]["parameters"]["required"] = required_fields
|
||||
|
||||
return tool_params
|
||||
|
||||
|
||||
Reference in New Issue
Block a user