Skip to content

The agent that grows with you

fix: retain partial-update diagnostics at canonical CLI launch

Tekniuma6376f0eebde
diff --git a/hermes_cli/gateway_chat_startup.py b/hermes_cli/gateway_chat_startup.py
new file mode 100644
index 00000000000..885eace3310
--- /dev/null
+++ b/hermes_cli/gateway_chat_startup.py
@@ -0,0 +1,18 @@
+"""Frontend startup checks shared by classic chat and top-level one-shot."""
+from __future__ import annotations
+
+
+def launch_gateway_chat(args) -> int:
+ try:
+ from hermes_cli.main import _confirm_startup_expensive_model_override
+ from hermes_cli.gateway_chat import launch_from_args
+
+ # Consent belongs before discovery/admission, even with --yolo.
+ _confirm_startup_expensive_model_override(args)
+ return launch_from_args(args)
+ except ImportError as exc:
+ from hermes_constants import emit_partial_update_hint
+
+ if emit_partial_update_hint(exc):
+ return 1
+ raise
diff --git a/hermes_cli/main.py b/hermes_cli/main.py
index c47aa600976..9d6d825f685 100644
--- a/hermes_cli/main.py
+++ b/hermes_cli/main.py
@@ -1654,11 +1654,8 @@ _CHAT_PASSTHROUGH = (
def cmd_chat(args):
"""Run interactive chat CLI."""
if not _resolve_use_tui(args):
- # Consent is a frontend admission guard, not a property of the executor.
- # Run it before discovery or session creation, including --yolo launches.
- _confirm_startup_expensive_model_override(args)
- from hermes_cli.gateway_chat import launch_from_args
- sys.exit(launch_from_args(args))
+ from hermes_cli.gateway_chat_startup import launch_gateway_chat
+ sys.exit(launch_gateway_chat(args))
_apply_safe_mode(args)
_apply_user_config_bypass(args)
_guard_noninteractive_user_config(args)
@@ -2884,9 +2881,8 @@ def _run_oneshot_from_args(args) -> None:
Bypasses cli.py entirely; the transport launcher never returns.
"""
- _confirm_startup_expensive_model_override(args)
- from hermes_cli.gateway_chat import launch_from_args
- sys.exit(launch_from_args(args))
+ from hermes_cli.gateway_chat_startup import launch_gateway_chat
+ sys.exit(launch_gateway_chat(args))
def _light_chat_parser():
diff --git a/tests/hermes_cli/test_cli_partial_update_hint_96900.py b/tests/hermes_cli/test_cli_partial_update_hint_96900.py
index 94deb9206bf..e25ccee3090 100644
--- a/tests/hermes_cli/test_cli_partial_update_hint_96900.py
+++ b/tests/hermes_cli/test_cli_partial_update_hint_96900.py
@@ -1,18 +1,15 @@
"""Chat startup must explain a mixed-version ImportError (#96900).
-A half-updated install can ship a newer ``cli.py`` that imports
-``resolve_turn_limit`` / ``split_model_config_default`` from
-``hermes_cli.config`` while the older ``config.py`` does not export them.
-Construction of ``HermesCLI`` then dies before the agent-setup mixin can
-print ``partial_update_hint``. ``cmd_chat`` is the load-bearing catch:
+A half-updated install can ship a newer launcher importing config helpers
+that the older ``hermes_cli.config`` does not export. The transport launch
+must preserve the diagnostic previously provided around ``cli.main``.
+``cmd_chat`` is the load-bearing catch:
bare ``hermes`` and ``hermes chat`` (including the fast-chat launch path)
all go through it.
"""
from argparse import Namespace
import io
-import sys
-import types
import pytest
@@ -102,16 +99,17 @@ def test_emit_hint_stays_silent_for_third_party_import_error():
"name",
["resolve_turn_limit", "split_model_config_default"],
)
[email protected]("entry", ["cmd_chat", "_run_oneshot_from_args"])
def test_cmd_chat_prints_update_hint_when_config_helper_is_missing(
- main_mod, monkeypatch, capsys, name
+ main_mod, monkeypatch, capsys, name, entry
):
- def boom(**_kwargs):
+ def boom(_args):
raise _missing_config_name_error(name)
- monkeypatch.setitem(sys.modules, "cli", types.SimpleNamespace(main=boom))
+ monkeypatch.setattr("hermes_cli.gateway_chat.launch_from_args", boom)
with pytest.raises(SystemExit) as excinfo:
- main_mod.cmd_chat(_chat_args())
+ getattr(main_mod, entry)(_chat_args())
assert excinfo.value.code == 1
err = capsys.readouterr().err
@@ -120,16 +118,17 @@ def test_cmd_chat_prints_update_hint_when_config_helper_is_missing(
assert "partially-updated" in err
-def test_cmd_chat_still_reraises_unrelated_import_errors(main_mod, monkeypatch):
[email protected]("entry", ["cmd_chat", "_run_oneshot_from_args"])
+def test_cmd_chat_still_reraises_unrelated_import_errors(main_mod, monkeypatch, entry):
exc = ImportError("cannot import name 'dumps' from 'requests'")
exc.name = "requests"
- def boom(**_kwargs):
+ def boom(_args):
raise exc
- monkeypatch.setitem(sys.modules, "cli", types.SimpleNamespace(main=boom))
+ monkeypatch.setattr("hermes_cli.gateway_chat.launch_from_args", boom)
with pytest.raises(ImportError) as excinfo:
- main_mod.cmd_chat(_chat_args())
+ getattr(main_mod, entry)(_chat_args())
assert excinfo.value is exc