From bc83479f94879b7165f64d5a79ed72e2b5956140 Mon Sep 17 00:00:00 2001 From: Giuseppe Date: Thu, 4 Jun 2026 19:43:38 +0200 Subject: [PATCH] fix: bool('false') is True coerces endpoint toggles incorrectly (#2361) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Python's bool('false') returns True because the string is non-empty. A JS client serialising a boolean as the string 'false' would have supports_tools or is_enabled silently flipped to True — so 'disable tool support' would actually enable it. Use an explicit lookup dict for supports_tools and a case-insensitive string check for is_enabled so both string and native bool inputs are handled correctly. Co-authored-by: Claude Sonnet 4.6 --- routes/model_routes.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/routes/model_routes.py b/routes/model_routes.py index 30c6562..6220305 100644 --- a/routes/model_routes.py +++ b/routes/model_routes.py @@ -1899,9 +1899,10 @@ def setup_model_routes(model_discovery): if body: if "supports_tools" in body: v = body["supports_tools"] - ep.supports_tools = bool(v) if v in (True, False, "true", "false", 1, 0) else None + ep.supports_tools = {True: True, False: False, 'true': True, 'false': False, 1: True, 0: False}.get(v) if "is_enabled" in body: - ep.is_enabled = bool(body["is_enabled"]) + v_ie = body['is_enabled'] + ep.is_enabled = v_ie.lower() in ('true', '1', 'yes') if isinstance(v_ie, str) else bool(v_ie) if "name" in body and isinstance(body["name"], str): ep.name = body["name"].strip() or ep.name if "model_type" in body and isinstance(body["model_type"], str):