Skip to content

Commit 6e6e124

Browse files
committed
fix(tools): strip unsupported prefixItems from JSON schema to fix FunctionTool crash
1 parent 4b1b166 commit 6e6e124

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/google/adk/tools/_function_parameter_parse_util.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,19 @@ def _generate_json_schema_for_parameter(
131131
json_schema_dict = _add_unevaluated_items_to_fixed_len_tuple_schema(
132132
json_schema_dict
133133
)
134-
return json_schema_dict
134+
135+
def _strip_unsupported_keys(d: Any) -> Any:
136+
if isinstance(d, dict):
137+
d.pop('prefixItems', None)
138+
d.pop('unevaluatedItems', None)
139+
for k, v in d.items():
140+
_strip_unsupported_keys(v)
141+
elif isinstance(d, list):
142+
for item in d:
143+
_strip_unsupported_keys(item)
144+
return d
145+
146+
return _strip_unsupported_keys(json_schema_dict)
135147

136148

137149
def _is_builtin_primitive_or_compound(

0 commit comments

Comments
 (0)