Update nanobot/agent/tools/base.py

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
This commit is contained in:
Kiplangat Korir 2026-02-02 20:52:30 +03:00 committed by GitHub
parent 7ef18c4e8a
commit 9b09cb5c63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -51,8 +51,14 @@ class Tool(ABC):
Unknown params are ignored.
"""
schema = self.parameters or {}
if schema.get("type") != "object":
return []
# Default to an object schema if type is missing, and fail fast on unsupported top-level types.
if "type" not in schema:
schema = {"type": "object", **schema}
elif schema.get("type") != "object":
raise ValueError(
f"Tool parameter schemas must have top-level type 'object'; got {schema.get('type')!r}"
)
return self._validate_schema(params, schema, path="")