The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(setup): Quick Setup offers to keep a model imported from another agent
Tekniuma42b88a37638
diff --git a/hermes_cli/setup.py b/hermes_cli/setup.pyindex 53bc84432c6..42542a2855e 100644--- a/hermes_cli/setup.py+++ b/hermes_cli/setup.py@@ -738,7 +738,10 @@ def _run_setup_wizard_impl(args):label, runner = _FIRST_TIME_MODES[setup_mode]if runner is not None:from hermes_cli import setup_quick- _run_setup_steps([(label, lambda: getattr(setup_quick, runner)(config, hermes_home, is_existing))])+ # Quick Setup offers to keep a model the import brought (Full setup acknowledges it below).+ run_args = (config, hermes_home, is_existing) + (+ (imported_from,) if runner == "_run_first_time_quick_setup" else ())+ _run_setup_steps([(label, lambda: getattr(setup_quick, runner)(*run_args))])_record_setup_completed(config)return_run_full_setup(config, hermes_home, is_existing=is_existing, imported_from=imported_from)diff --git a/hermes_cli/setup_quick.py b/hermes_cli/setup_quick.pyindex 044cefc02fc..3940c6b9403 100644--- a/hermes_cli/setup_quick.py+++ b/hermes_cli/setup_quick.py@@ -85,14 +85,41 @@ def _run_portal_one_shot(config: dict) -> None:_record_setup_completed(config)-def _run_first_time_quick_setup(config: dict, hermes_home, is_existing: bool):- """Streamlined first-time setup via Nous Portal: OAuth, model, terminal & messaging;- everything else gets defaults."""- from hermes_cli.setup import (- _apply_default_agent_settings, _info, print_header, print_info, _print_setup_summary, print_success,- print_warning, prompt_choice, save_config, setup_gateway, setup_terminal_backend- )- # Step 1: Nous Portal — OAuth login + model selection (provider set to "nous" by the save).+def _imported_model_label(config: dict) -> str:+ """``"<provider> · <model>"`` when *config* (just written by an agent import) names a model+ Hermes has credentials for, else ``""``."""+ from hermes_cli.auth import AuthError, resolve_provider+ from hermes_cli.models import provider_label+ from hermes_cli.setup_migration import _model_section_has_credentials+ model = config.get("model")+ name = model.get("default") if isinstance(model, dict) else model+ if not (isinstance(name, str) and name.strip()) or not _model_section_has_credentials(config):+ return ""+ try:+ provider = resolve_provider()+ except AuthError:+ return ""+ return f"{provider_label(provider)} · {name.strip()}"+++def _keep_imported_model(config: dict, imported_from: str) -> bool:+ """After an import that brought a model, ask whether to keep it (the default) or switch to+ Nous Portal; True keeps it."""+ from hermes_cli.setup import _info, print_header, prompt_choice+ label = _imported_model_label(config) if imported_from else ""+ if not label:+ return False+ print_header("Model & Provider", gap=True)+ _info(f"Settings were imported from {imported_from}.")+ return prompt_choice(f"Keep your imported model ({label}) or switch to Nous Portal?", [+ f"Keep {label}",+ "Switch to Nous Portal — free OAuth login, 300+ models plus the Tool Gateway",+ ], 0, description=f" Settings were imported from {imported_from}.") == 0+++def _quick_setup_nous_portal(config: dict) -> None:+ """Quick Setup's Nous Portal step: OAuth login + model selection (provider set to "nous" by the save)."""+ from hermes_cli.setup import _info, print_header, print_info, print_warningprint_header("Nous Portal", gap=True)_info("One subscription, 300+ models, plus the Tool Gateway:"," web search, image generation, TTS, browser automation.",@@ -110,6 +137,19 @@ def _run_first_time_quick_setup(config: dict, hermes_home, is_existing: bool):# The wizard's later save_config(config) must not clobber the login/model save._reload_config_into(config)++def _run_first_time_quick_setup(config: dict, hermes_home, is_existing: bool, imported_from: str = ""):+ """Streamlined first-time setup via Nous Portal: OAuth, model, terminal & messaging;+ everything else gets defaults. A model brought by an agent import (*imported_from* names the+ agents) is offered first and kept by default, which skips the Nous Portal step."""+ from hermes_cli.setup import (+ _apply_default_agent_settings, _info, print_info, _print_setup_summary, print_success,+ prompt_choice, save_config, setup_gateway, setup_terminal_backend+ )+ # Step 1: the imported model, or Nous Portal.+ if not _keep_imported_model(config, imported_from):+ _quick_setup_nous_portal(config)+# Step 2: Terminal Backend; Step 3: defaults for everything else.setup_terminal_backend(config)_apply_default_agent_settings(config)diff --git a/tests/hermes_cli/test_setup_quick_import.py b/tests/hermes_cli/test_setup_quick_import.pynew file mode 100644index 00000000000..91546d39b69--- /dev/null+++ b/tests/hermes_cli/test_setup_quick_import.py@@ -0,0 +1,62 @@+"""First-time Quick Setup after an agent import: a model the import brought is kept by default+instead of being replaced by the Nous Portal login/model step."""++from argparse import Namespace+from unittest.mock import patch++import pytest+++def _fake_import(_hermes_home):+ """What an agent import leaves behind: a model in config.yaml and its key in .env."""+ from hermes_cli.config import load_config, save_config, save_env_value+ config = load_config()+ config["model"] = {"provider": "openrouter", "default": "anthropic/claude-sonnet-4.5"}+ save_config(config)+ save_env_value("OPENROUTER_API_KEY", "sk-or-demo-not-a-real-key")+ return "OpenClaw"+++def _fake_nous_flow(config):+ """The real flow logs in and saves provider ``nous`` with a Portal model."""+ from hermes_cli.config import save_config+ config["model"] = {"provider": "nous", "default": "Hermes-4-405B"}+ save_config(config)++[email protected]("switch, nous_runs, expected_model", [+ (False, 0, {"provider": "openrouter", "default": "anthropic/claude-sonnet-4.5"}),+ (True, 1, {"provider": "nous", "default": "Hermes-4-405B"}),+])+def test_quick_setup_keeps_imported_model_unless_user_switches(switch, nous_runs, expected_model):+ from hermes_cli.config import get_env_value, load_config+ from hermes_cli.setup import run_setup_wizard++ questions = []++ def answer(question, choices, default=0, description=None):+ # Enter on every menu (the mode menu's default is Quick Setup), except the keep/switch+ # question when the test switches.+ questions.append(question)+ if switch and "switch to Nous Portal" in question:+ return 1+ return default++ with patch("hermes_cli.setup.is_interactive_stdin", return_value=True), \+ patch("hermes_cli.setup.offer_agent_import", side_effect=_fake_import), \+ patch("hermes_cli.setup.prompt_choice", side_effect=answer), \+ patch("hermes_cli.model_setup_flows._model_flow_nous", side_effect=_fake_nous_flow) as nous, \+ patch("hermes_cli.setup.setup_terminal_backend"), \+ patch("hermes_cli.setup.setup_gateway") as gateway, \+ patch("hermes_cli.setup._print_setup_summary"), \+ patch("hermes_cli.setup._record_setup_completed"):+ run_setup_wizard(Namespace(non_interactive=False, section=None, reset=False,+ reconfigure=False, quick=False))++ assert nous.call_count == nous_runs+ model = load_config()["model"]+ assert {k: model.get(k) for k in expected_model} == expected_model+ assert get_env_value("OPENROUTER_API_KEY") == "sk-or-demo-not-a-real-key"+ gateway.assert_called_once() # the rest of Quick Setup still runs+ assert any("Keep your imported model (OpenRouter · anthropic/claude-sonnet-4.5)" in q+ for q in questions), questions