The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(gateway): launch-home dotenv loads under multiplex — red/green regression for #125530
Yuan Lie0cd1aba5d5e
diff --git a/tests/gateway/test_multiplex_credential_isolation.py b/tests/gateway/test_multiplex_credential_isolation.pyindex e176d19e710..c38ecb8c71e 100644--- a/tests/gateway/test_multiplex_credential_isolation.py+++ b/tests/gateway/test_multiplex_credential_isolation.py@@ -135,6 +135,59 @@ def test_turn_scoped_dotenv_reload_does_not_pollute_process_env(tmp_path, monkeyassert os.environ["DISCORD_ALLOWED_CHANNELS"] == "all-channels"+def test_launch_home_dotenv_still_loads_under_multiplex(tmp_path, monkeypatch):+ """#125530: the guard must skip only FOREIGN (routed) home loads.++ The launch profile's own scoped bodies bind an override naming the launch+ home (``_profile_runtime_scope_tokens(None)``), so a launch-home load can+ legitimately arrive with an override set. Skipping it hid the launch+ home's `.env` from the process env, silently breaking fallback_providers+ whose key lives only there. A routed profile's `.env` must still never be+ copied into ``os.environ``.+ """+ import os++ from hermes_cli.env_loader import load_hermes_dotenv+ from hermes_constants import (+ get_process_hermes_home,+ reset_hermes_home_override,+ set_hermes_home_override,+ )++ launch_home = get_process_hermes_home().resolve()+ monkeypatch.delenv("LAUNCH_ONLY_FALLBACK_KEY", raising=False)++ ss.set_multiplex_active(True)+ home_token = set_hermes_home_override(launch_home)+ try:+ # The launch home's OWN .env is process configuration: it must load.+ (launch_home / ".env").write_text(+ f"LAUNCH_ONLY_FALLBACK_KEY=launch-key-{launch_home.name}\n", encoding="utf-8"+ )+ try:+ loaded = load_hermes_dotenv(hermes_home=launch_home)+ assert loaded == [launch_home / ".env"]+ assert os.environ.get("LAUNCH_ONLY_FALLBACK_KEY") == f"launch-key-{launch_home.name}"+ finally:+ monkeypatch.delenv("LAUNCH_ONLY_FALLBACK_KEY", raising=False)+ finally:+ reset_hermes_home_override(home_token)+ ss.set_multiplex_active(False)++ # A FOREIGN routed home's .env is still never copied into os.environ.+ foreign = tmp_path / "profiles" / "routed"+ foreign.mkdir(parents=True)+ (foreign / ".env").write_text("LAUNCH_ONLY_FALLBACK_KEY=foreign-secret\n", encoding="utf-8")+ ss.set_multiplex_active(True)+ home_token = set_hermes_home_override(foreign)+ try:+ assert load_hermes_dotenv(hermes_home=foreign) == []+ assert "LAUNCH_ONLY_FALLBACK_KEY" not in os.environ+ finally:+ reset_hermes_home_override(home_token)+ ss.set_multiplex_active(False)++def test_cold_profile_hydrates_external_source_without_global_env(tmp_path, monkeypatch):