The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui-gateway): copy the custom provider gateway before pinning the inherited model
teknium1d5ff004af74e
diff --git a/tests/tui_gateway/test_profiles_inherit_launch_model.py b/tests/tui_gateway/test_profiles_inherit_launch_model.pynew file mode 100644index 00000000000..0a6f9f8de56--- /dev/null+++ b/tests/tui_gateway/test_profiles_inherit_launch_model.py@@ -0,0 +1,31 @@+"""profiles.create inherits the launch profile's model together with the custom gateway backing it.++``_inherit_launch_model`` pins the launch ``model`` into the new profile through the same+validated path as ``/api/model/set``, and that validation runs inside the new profile's home. A+launch model on a custom ``providers:`` gateway is therefore only valid once the gateway+definition is already in the profile — writing it after the pin never ran (#101885 / #94071).+"""++from __future__ import annotations++import yaml++import tui_gateway.server as srv+++def test_inherit_launch_model_carries_a_custom_provider_gateway(monkeypatch, tmp_path):+ home = tmp_path / ".hermes"+ home.mkdir()+ monkeypatch.setenv("HERMES_HOME", str(home))+ (home / "config.yaml").write_text(+ "model:\n provider: my-gateway\n default: my-finetune\n"+ "providers:\n my-gateway:\n api: https://llm.internal.example.com/v1\n key_env: GW_KEY\n"+ " unrelated:\n api: https://other.example.com/v1\n")+ profile = home / "profiles" / "scout"+ profile.mkdir(parents=True)++ assert srv._inherit_launch_model(profile) is True++ cfg = yaml.safe_load((profile / "config.yaml").read_text())+ assert (cfg["model"]["provider"], cfg["model"]["default"]) == ("my-gateway", "my-finetune")+ assert set(cfg["providers"]) == {"my-gateway"}diff --git a/tui_gateway/methods_profiles.py b/tui_gateway/methods_profiles.pyindex 5260b59163d..78ba30a6378 100644--- a/tui_gateway/methods_profiles.py+++ b/tui_gateway/methods_profiles.py@@ -318,8 +318,9 @@ def _inherit_launch_model(path) -> bool:model_cfg = launch_cfg.get("model") or {}if not (model_cfg.get("provider") and model_cfg.get("default")):return False- _pin_profile_model(path, str(model_cfg["provider"]), str(model_cfg["default"]))- # A custom `providers:` gateway travels with the model it backs (same seed as the CLI path).+ # A custom `providers:` gateway travels with the model it backs (same seed as the CLI path). It is+ # written BEFORE the pin: the pin validates the pick inside the new profile, and an empty profile+ # rejects a provider it has not been told about ("Unknown provider").custom = _lazy("hermes_cli.profiles", "launch_model_seed")(launch_cfg).get("providers")if custom:from hermes_cli.config import load_config, save_config@@ -327,6 +328,7 @@ def _inherit_launch_model(path) -> bool:cfg = load_config()cfg["providers"] = {**(cfg.get("providers") if isinstance(cfg.get("providers"), dict) else {}), **custom}save_config(cfg)+ _pin_profile_model(path, str(model_cfg["provider"]), str(model_cfg["default"]))return True