mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-17 04:11:35 +00:00
profiles.create ("New bot" in the TUI/Desktop) mirrored the launch
profile's stt/tts/voice sections from load_config_readonly(), which
returns the env-expanded config, so every ${VAR} ref in those sections
landed in the new profile's config.yaml as the launch profile's
plaintext secret. Template preservation on save cannot help: the new
profile's raw file has no templates to restore. The secret then
overrides the new profile's own .env (rotating the key there is
ignored) and travels with config.yaml if the profile is published.
Read the launch config.yaml raw at every site that copies launch config
into a profile, as _seed_model_config already does:
- _mirror_voice_sections (stt/tts/voice)
- _inherit_launch_model (the custom providers: gateway seed)
- _configure_cfg_sections (an MCP server copied from the launch catalog
when the editor enables it on a profile that lacks it)
34 lines
1.6 KiB
Python
34 lines
1.6 KiB
Python
"""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 hermes_yaml as 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))
|
|
monkeypatch.setenv("FAKE_GW_TOKEN", "gw-FAKE-111")
|
|
(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 api_key: ${FAKE_GW_TOKEN}\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"}
|
|
# The gateway travels as the launch file wrote it: the ref, never the launch secret.
|
|
assert cfg["providers"]["my-gateway"]["api_key"] == "${FAKE_GW_TOKEN}"
|