Skip to content

The agent that grows with you

fix(cli): hand --api-key and --base-url from hermes chat --cli to the classic CLI

Teknium90118119404e
diff --git a/hermes_cli/main.py b/hermes_cli/main.py
index 7c5e4e644ec..6455b76ede4 100644
--- a/hermes_cli/main.py
+++ b/hermes_cli/main.py
@@ -1765,7 +1765,7 @@ def cmd_chat(args):
safe_mode = getattr(args, "safe_mode", False)
kwargs = {
"model": args.model,
- "reasoning": getattr(args, "reasoning", None),
+ **{k: getattr(args, k, None) for k in ("reasoning", "api_key", "base_url")}, # TUI refuses the last two
"toolsets": args.toolsets,
"query": args.query,
"oneshot": bool(getattr(args, "oneshot_exit", False)),
diff --git a/tests/hermes_cli/test_argparse_flag_propagation.py b/tests/hermes_cli/test_argparse_flag_propagation.py
index 67c0a1f3926..bf4bb43ff08 100644
--- a/tests/hermes_cli/test_argparse_flag_propagation.py
+++ b/tests/hermes_cli/test_argparse_flag_propagation.py
@@ -63,6 +63,67 @@ class TestChatVerboseArg:
assert "verbose" not in captured
+class TestChatRouteFlagsReachClassicCli:
+ """``hermes chat --cli --api-key K --base-url U`` hands both to ``cli.main`` (#134889 CLI-34).
+
+ cmd_chat built the classic kwargs from _CHAT_PASSTHROUGH plus a few explicit keys, neither of
+ which carried them, so the session was created on the profile's credential (``credential_ref``
+ null) and a later ``--resume --api-key`` had no launch key to re-supply."""
+
+ def test_cmd_chat_forwards_api_key_and_base_url(self, monkeypatch):
+ import types
+
+ import hermes_cli.main as main_mod
+ from hermes_cli._parser import build_top_level_parser
+
+ parser, _subparsers, chat_parser = build_top_level_parser()
+ chat_parser.set_defaults(func=main_mod.cmd_chat)
+ args = parser.parse_args(["chat", "--cli", "--api-key", "K-LAUNCH", "--base-url", "http://127.0.0.1:9/v1"])
+ captured = {}
+ fake_cli = types.ModuleType("cli")
+ fake_cli.main = lambda **kwargs: captured.update(kwargs)
+ fake_banner = types.ModuleType("hermes_cli.banner")
+ fake_banner.prefetch_update_check = lambda: None
+ fake_skills_sync = types.ModuleType("tools.skills_sync")
+ fake_skills_sync.sync_skills = lambda quiet=True: None
+ monkeypatch.setitem(sys.modules, "cli", fake_cli)
+ monkeypatch.setitem(sys.modules, "hermes_cli.banner", fake_banner)
+ monkeypatch.setitem(sys.modules, "tools.skills_sync", fake_skills_sync)
+ monkeypatch.setattr(main_mod, "_has_any_provider_configured", lambda: True)
+ monkeypatch.setattr(main_mod, "_pin_kanban_board_env", lambda: None)
+
+ main_mod.cmd_chat(args)
+
+ assert captured["api_key"] == "K-LAUNCH"
+ assert captured["base_url"] == "http://127.0.0.1:9/v1"
+
+ def test_cmd_chat_omits_them_when_absent(self, monkeypatch):
+ import types
+
+ import hermes_cli.main as main_mod
+ from hermes_cli._parser import build_top_level_parser
+
+ parser, _subparsers, chat_parser = build_top_level_parser()
+ chat_parser.set_defaults(func=main_mod.cmd_chat)
+ args = parser.parse_args(["chat", "--cli"])
+ captured = {}
+ fake_cli = types.ModuleType("cli")
+ fake_cli.main = lambda **kwargs: captured.update(kwargs)
+ fake_banner = types.ModuleType("hermes_cli.banner")
+ fake_banner.prefetch_update_check = lambda: None
+ fake_skills_sync = types.ModuleType("tools.skills_sync")
+ fake_skills_sync.sync_skills = lambda quiet=True: None
+ monkeypatch.setitem(sys.modules, "cli", fake_cli)
+ monkeypatch.setitem(sys.modules, "hermes_cli.banner", fake_banner)
+ monkeypatch.setitem(sys.modules, "tools.skills_sync", fake_skills_sync)
+ monkeypatch.setattr(main_mod, "_has_any_provider_configured", lambda: True)
+ monkeypatch.setattr(main_mod, "_pin_kanban_board_env", lambda: None)
+
+ main_mod.cmd_chat(args)
+
+ assert "api_key" not in captured and "base_url" not in captured
+
+
class TestAcceptHooksOnAgentSubparsers:
"""Verify --accept-hooks is accepted at every agent-subcommand
position (before the subcommand, between group/subcommand, and