From e3fc2a7c7aae1a63ad8cafdfe516c3c78c53f010 Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Fri, 2 Oct 2026 23:04:27 +0800 Subject: [PATCH] fix(tools): separate null-only guard from union validation --- nanobot/agent/tools/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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: