fix(cli): fix max_turns comment and test for correct priority order
Priority is: CLI arg > config file > env var > default (not env var > config file as the old comment stated) The test failed because config.yaml had max_turns at both root level and inside agent section. The test cleared agent.max_turns but the root-level value still took precedence over the env var. Fixed the test to clear both, and corrected the comment to match the intended priority order.
This commit is contained in:
@@ -38,14 +38,18 @@ class TestMaxTurnsResolution:
|
||||
"""Env var is used when config file doesn't set max_turns."""
|
||||
monkeypatch.setenv("HERMES_MAX_ITERATIONS", "42")
|
||||
import cli as cli_module
|
||||
original = cli_module.CLI_CONFIG["agent"].get("max_turns")
|
||||
original_agent = cli_module.CLI_CONFIG["agent"].get("max_turns")
|
||||
original_root = cli_module.CLI_CONFIG.get("max_turns")
|
||||
cli_module.CLI_CONFIG["agent"]["max_turns"] = None
|
||||
cli_module.CLI_CONFIG.pop("max_turns", None)
|
||||
try:
|
||||
cli_obj = _make_cli()
|
||||
assert cli_obj.max_turns == 42
|
||||
finally:
|
||||
if original is not None:
|
||||
cli_module.CLI_CONFIG["agent"]["max_turns"] = original
|
||||
if original_agent is not None:
|
||||
cli_module.CLI_CONFIG["agent"]["max_turns"] = original_agent
|
||||
if original_root is not None:
|
||||
cli_module.CLI_CONFIG["max_turns"] = original_root
|
||||
|
||||
def test_max_turns_never_none_for_agent(self):
|
||||
"""The value passed to AIAgent must never be None (causes TypeError in run_conversation)."""
|
||||
|
||||
Reference in New Issue
Block a user