fix(tools): coerce an empty-string list/dict argument to an empty container (#1024)

This commit is contained in:
Ahmed Allam
2026-08-08 16:58:30 -07:00
committed by GitHub
parent 72833b8e43
commit c29eb73c7f
2 changed files with 26 additions and 2 deletions
+3 -1
View File
@@ -160,7 +160,9 @@ def _schema_types(spec: dict[str, Any]) -> set[str]:
def _decode_structured(value: str, types: set[str]) -> Any:
stripped = value.strip()
if not stripped:
return value
# An empty string is the model's "no value" for a list/dict param; give it
# the empty container so it validates instead of failing the type check.
return [] if "array" in types else {}
try:
decoded = json.loads(stripped)
except json.JSONDecodeError: