Files
hermes-agent/tests/hermes_cli/test_cli_retire_agent.py
kshitijk4poor 3c14c870e9 revert(cli): retire the CLI agent inline again; it is a GatewayAgent
Since the unified gateway runtime, the CLI's _init_agent() builds a
hermes_cli.gateway_agent.GatewayAgent, whose release_clients() is a no-op: the
gateway owns the real agent and its memory teardown. The off-thread release
added a non-daemon thread and a shutdown fallback around a call that releases
nothing, so _retire_agent and its test go back to main's version.
2026-10-19 19:15:44 +05:30

28 lines
1.1 KiB
Python

"""The interactive CLI must release the old AIAgent's LLM clients when it drops the instance
for a rebuild (/personality, /reasoning, /fast, model/route/credential change, MoA one-shot):
on the codex_app_server route the app-server child belongs to that instance and ``self.agent =
None`` alone orphans it for the CLI process lifetime (#72548)."""
from types import SimpleNamespace
from unittest.mock import patch
from hermes_cli.cli_commands_mixin import CLICommandsMixin
class _FakeAgent:
def __init__(self):
self.release_calls = 0
def release_clients(self):
self.release_calls += 1
def test_reasoning_command_releases_old_agent_clients_before_rebuild():
agent = _FakeAgent()
stub = SimpleNamespace(reasoning_config={"enabled": True, "effort": "medium"}, show_reasoning=False, agent=agent)
with patch("cli.save_config_value"), patch("cli._cprint"):
CLICommandsMixin._handle_reasoning_command(stub, "/reasoning high")
assert stub.reasoning_config == {"enabled": True, "effort": "high"}
assert stub.agent is None
assert agent.release_calls == 1