Skip to content

Your lightweight open-source personal agent.

fix(tools): separate null-only guard from union validation

Xubin Rene3fc2a7c7aae
diff --git a/nanobot/agent/tools/base.py b/nanobot/agent/tools/base.py
index 4618af2e8..277bc21be 100644
--- a/nanobot/agent/tools/base.py
+++ b/nanobot/agent/tools/base.py
@@ -75,12 +75,12 @@ class Schema(ABC):
nullable = (isinstance(raw_type, list) and "null" in raw_type) or schema.get("nullable", False)
t = Schema.resolve_json_schema_type(raw_type)
+ if (raw_type == "null" or raw_type == ["null"]) and val is not None:
+ return [f"{label} should be null"]
if nullable and val is None:
if "enum" in schema and val not in schema["enum"]:
return [f"{label} must be one of {schema['enum']}"]
return []
- if (raw_type == "null" or raw_type == ["null"]) and val is not None:
- return [f"{label} should be null"]
if isinstance(raw_type, list):
types = [item for item in cast(list[Any], raw_type) if item != "null"]
if len(types) > 1: