The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(left-core): the classic CLI prints migration outcomes on stderr, also those its gateway kept
Teknium00686933a6a1
diff --git a/hermes_cli/cli_init_mixin.py b/hermes_cli/cli_init_mixin.pyindex 6ffa60589bd..f3079d847d2 100644--- a/hermes_cli/cli_init_mixin.py+++ b/hermes_cli/cli_init_mixin.py@@ -392,6 +392,8 @@ class CLIInitMixin:def _init_runtime_state(self, resume):"""Session store + all per-run mutable state (queues, overlays, pet/voice/status-bar fields)."""from cli import _hermes_home+ from hermes_cli.left_core_migration import serve_notices_on_stderr+ serve_notices_on_stderr()# A signature change across turns (/model, credential rotation) rebuilds the agent.self._active_agent_route_signature = Noneself.agent: Optional[Any] = None # initialized on first usediff --git a/hermes_cli/left_core_migration.py b/hermes_cli/left_core_migration.pyindex 217e6931172..fd2cc4009f3 100644--- a/hermes_cli/left_core_migration.py+++ b/hermes_cli/left_core_migration.py@@ -598,14 +598,29 @@ def recover_for_provider(name: Optional[str]) -> None:from hermes_constants import get_hermes_home, hermes_home_keyfrom providers import get_provider_profilehome = Path(get_hermes_home())+ # A terminal user sees outcomes now, also those another process (the gateway this CLI started) kept;+ # otherwise (Desktop, gateway, a detached turn) the home's first agent in any process delivers them.+ say = (lambda message: print(message, file=sys.stderr)) if _interactive() or _terminal_front_end else None+ if say is not None:+ for message in _claim_notices(home):+ say(message)if hermes_home_key(home) in _attempted: # this process already tried: skip the config/auth/.env readsreturnif plugin_present(feature.plugin, home) or get_provider_profile(str(name).strip().lower()) is not None:returnif feature_in_use(feature, home, process_env=True):- # A terminal user sees the outcome now; otherwise (Desktop, gateway, a detached turn) the home's- # first agent in any process delivers it.- recover_at_startup(say=(lambda message: print(message, file=sys.stderr)) if _interactive() else None)+ recover_at_startup(say=say)+++_terminal_front_end = False+++def serve_notices_on_stderr() -> None:+ """This process is a terminal front end (the classic CLI, whose turns run in the gateway): outcomes of+ :func:`recover_for_provider` print to its stderr even when its output is piped (``hermes chat -q``),+ since a resolution that fails before any agent exists (no credentials) leaves no agent to deliver them."""+ global _terminal_front_end+ _terminal_front_end = Truedef profile_env_names() -> frozenset[str]:diff --git a/tests/hermes_cli/test_left_core_provider_runtime.py b/tests/hermes_cli/test_left_core_provider_runtime.pyindex 619d4425edc..4b89ee1fcdc 100644--- a/tests/hermes_cli/test_left_core_provider_runtime.py+++ b/tests/hermes_cli/test_left_core_provider_runtime.py@@ -17,6 +17,7 @@ import hermes_cli.left_core_migration as lcm@pytest.fixture(autouse=True)def _fresh(monkeypatch):monkeypatch.setattr(lcm, "_attempted", set())+ monkeypatch.setattr(lcm, "_terminal_front_end", False)for name in ("HERMES_INFERENCE_PROVIDER", "COPILOT_GITHUB_TOKEN", "GH_TOKEN", "GITHUB_TOKEN"):monkeypatch.delenv(name, raising=False)import hermes_cli.memory_provider_migration as mpm@@ -167,3 +168,20 @@ def test_an_interactive_terminal_sees_the_resolution_outcome_now_and_only_there(lcm.recover_for_provider("copilot")assert capsys.readouterr().err.count("GitHub Copilot moved out of core") == 1assert "moved out of core" not in _agent_start_in_another_process()+++def test_a_piped_cli_front_end_prints_the_outcome_and_what_another_process_kept(tmp_path, monkeypatch,+ installs_ok, capsys):+ """``hermes chat -q`` with output piped: its turn runs in the gateway, and a resolution that fails+ before any agent exists (no credentials) leaves none to deliver what the migration kept. The classic+ CLI is a terminal front end: it prints outcomes on stderr, also one its gateway kept, exactly once."""+ home = _copilot_home(tmp_path, monkeypatch)+ monkeypatch.setattr(lcm, "_interactive", lambda: False)+ lcm._queue_notice(home, "kept by the gateway's start")+ lcm.serve_notices_on_stderr()+ lcm.recover_for_provider("copilot")+ lcm.recover_for_provider("copilot")+ err = capsys.readouterr().err+ assert err.count("kept by the gateway's start") == 1+ assert err.count("GitHub Copilot moved out of core") == 1+ assert "moved out of core" not in _agent_start_in_another_process()