Skip to content

The agent that grows with you

test(bot-relay): pin that a home override beats the launch-home fallback

kshitijk4poor209003492adb
diff --git a/tests/tools/test_bot_relay.py b/tests/tools/test_bot_relay.py
index e65ca0b8376..b39d0e420e5 100644
--- a/tests/tools/test_bot_relay.py
+++ b/tests/tools/test_bot_relay.py
@@ -710,8 +710,9 @@ def test_delivery_env_carries_only_the_given_author(monkeypatch):
def test_delivery_env_under_multiplex_names_the_pinned_launch_home(tmp_path, monkeypatch):
"""A relayed DM into the launch profile spawns with the launch home and its secrets, even after a
- host mirrors another home into HERMES_HOME; a bound scope still wins over the fallback."""
+ host mirrors another home into HERMES_HOME; a bound scope or home override still wins."""
from agent.secret_scope import reset_secret_scope, set_multiplex_active, set_secret_scope
+ from hermes_constants import reset_hermes_home_override, set_hermes_home_override
launch, mirrored = tmp_path / "launch", tmp_path / "mirrored"
launch.mkdir()
@@ -732,6 +733,14 @@ def test_delivery_env_under_multiplex_names_the_pinned_launch_home(tmp_path, mon
finally:
reset_secret_scope(token)
+ (mirrored / ".env").write_text("OPENROUTER_API_KEY=sk-override\n", encoding="utf-8")
+ home_token = set_hermes_home_override(str(mirrored))
+ try:
+ env = bot_relay.delivery_env(None, None)
+ assert (env["HERMES_HOME"], env["OPENROUTER_API_KEY"]) == (str(mirrored), "sk-override")
+ finally:
+ reset_hermes_home_override(home_token)
+
def test_delivery_env_single_profile_host_passes_the_process_env_through(tmp_path, monkeypatch):
"""Without multiplex nothing is pinned or overlaid: the child sees the process env as before."""
diff --git a/tools/bot_relay.py b/tools/bot_relay.py
index 9ce746ff675..6d090eb2b61 100644
--- a/tools/bot_relay.py
+++ b/tools/bot_relay.py
@@ -595,8 +595,9 @@ def delivery_env(author: Optional[dict], profile_home: "str | Path | None" = Non
# ``_profile_home`` answers None for the launch profile by design and a relay RPC binds no scope,
# so under multiplex an empty target means the launch profile, not "unknown" (the fail-closed
- # raise). Same shape as the slash-worker spawn (#115427); a bound scope or override still wins,
- # and a single-profile host keeps its pass-through env.
+ # raise; cf. the slash-worker spawn, #115427). An explicit target beats an override or bound scope
+ # inside ``served_profile_child_env``, so fill it only when both are absent; a single-profile host
+ # keeps its pass-through env.
target_home = profile_home
if (not target_home and is_multiplex_active() and not get_hermes_home_override()
and current_secret_scope() is None):