refactor(tools): unify boolean argument coercion in helpers.tool

Centralize boolean argument coercion in helpers.tool and route the promoted and core tools through it. This removes the duplicated private coercion helpers, including one in the remote code execution tool, along with the repairable-error messages and prompt files that only the strict boolean validation used. Strict boolean argument validation gives way to the shared coercion, which maps common true/false strings and falls back to truthiness, so invalid reset and dedicated_context values stop returning repairable errors. Browser regression tests now import the real modules before installing their stubs.

Validation: pytest tests/test_tool_action_contracts.py tests/test_browser_agent_regressions.py
This commit is contained in:
linkliti committed 2026-10-21 19:04:33 +03:00
1 parent 6f345d4ec6
commit 8fbcbdbc00
17 files changed
+59 -85

No files matched your search

@@ -5,7 +5,7 @@ import re
import shlex
import time
from helpers.tool import Tool, Response
from helpers.tool import Tool, Response, coerce_bool
from helpers import files, rfc_exchange, projects, runtime, secrets, settings
from helpers.print_style import PrintStyle
from helpers.strings import truncate_text as truncate_text_string
@@ -69,8 +69,8 @@ class CodeExecution(Tool):
runtime_arg = self.args.get("runtime", "").lower().strip()
session = int(self.args.get("session", 0))
self.allow_running = bool(self.args.get("allow_running", False))
reset = bool(self.args.get("reset", False) or runtime_arg == "reset")
self.allow_running = coerce_bool(self.args.get("allow_running", False), False)
reset = coerce_bool(self.args.get("reset", False), False) or runtime_arg == "reset"
cfg = _get_config(self.agent)