mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-03 02:11:48 +00:00
fix: coerce show_reasoning and guard_agent_created config bools
Widens #16528 to two sibling sites that had the same quoted-boolean bug: a YAML string "false" (or "0", "no", "off") silently evaluated truthy under bool() / if-check. - gateway/run.py _load_show_reasoning: is_truthy_value wrap - tools/skill_manager_tool.py _guard_agent_created_enabled: is_truthy_value wrap - regression tests for both
This commit is contained in:
parent
bb706c3f38
commit
27ec74c68a
4 changed files with 70 additions and 3 deletions
|
|
@ -567,6 +567,26 @@ class TestSecurityScanGate:
|
|||
with patch("hermes_cli.config.load_config", side_effect=RuntimeError("boom")):
|
||||
assert _guard_agent_created_enabled() is False
|
||||
|
||||
def test_guard_flag_quoted_false_stays_disabled(self):
|
||||
"""Quoted 'false' from YAML edits must not enable the guard."""
|
||||
from tools.skill_manager_tool import _guard_agent_created_enabled
|
||||
|
||||
for quoted in ("false", "False", "0", "no", "off"):
|
||||
with patch("hermes_cli.config.load_config",
|
||||
return_value={"skills": {"guard_agent_created": quoted}}):
|
||||
assert _guard_agent_created_enabled() is False, \
|
||||
f"guard_agent_created={quoted!r} must coerce to False"
|
||||
|
||||
def test_guard_flag_quoted_true_enables(self):
|
||||
"""Quoted truthy strings must enable the guard."""
|
||||
from tools.skill_manager_tool import _guard_agent_created_enabled
|
||||
|
||||
for quoted in ("true", "True", "1", "yes", "on"):
|
||||
with patch("hermes_cli.config.load_config",
|
||||
return_value={"skills": {"guard_agent_created": quoted}}):
|
||||
assert _guard_agent_created_enabled() is True, \
|
||||
f"guard_agent_created={quoted!r} must coerce to True"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# External skills directories (skills.external_dirs) — mutations in place
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue