fix(tools): reject non-finite number parameters

This commit is contained in:
Wesley Zhang
2026-08-12 02:25:20 +09:00
committed by Xubin Ren
parent 057e8f7af6
commit 99e07e138e
2 changed files with 21 additions and 0 deletions
+3
View File
@@ -1,6 +1,7 @@
"""Base class for agent tools."""
from __future__ import annotations
import math
import typing
from abc import ABC, abstractmethod
from collections.abc import Callable
@@ -67,6 +68,8 @@ class Schema(ABC):
return [f"{label} should be number"]
if t in _JSON_TYPE_MAP and t not in ("integer", "number") and not isinstance(val, _JSON_TYPE_MAP[t]):
return [f"{label} should be {t}"]
if t == "number" and isinstance(val, float) and not math.isfinite(val):
return [f"{label} must be finite"]
errors: list[str] = []
if "enum" in schema and val not in schema["enum"]: