The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui_gateway): launch-profile slash worker spawns under own home after multiplex flip
KeyArgo4c2de106cac0
diff --git a/tests/tui_gateway/test_served_profile_child_env.py b/tests/tui_gateway/test_served_profile_child_env.pyindex fe0251fc280..80e38efe168 100644--- a/tests/tui_gateway/test_served_profile_child_env.py+++ b/tests/tui_gateway/test_served_profile_child_env.py@@ -84,6 +84,36 @@ def test_slash_worker_child_runs_in_the_served_profiles_env(mux_homes, monkeypat_assert_is_b_env(_child_view(served_env), b, with_secrets=True)+def test_launch_profile_worker_spawns_with_own_home_after_multiplex_flip(mux_homes, monkeypatch):+ """After ``set_multiplex_active`` (first foreign-profile request), the launch profile's own worker+ must still spawn under ITS home — ``served_profile_child_env(target_home=None, inherit_credentials=True)``+ raises ``UnscopedSecretError`` by design once multiplexing is on, so the spawn site must pass the+ launch home explicitly when no served home is set (regression for #115427)."""+ import tui_gateway.server as server++ a, _b = mux_homes+ monkeypatch.setattr(server, "_hermes_home", str(a)) # launch profile home, captured at import+ captured = {}++ class _Popen:+ def __init__(self, argv, **kw):+ captured["env"] = kw["env"]+ self.stdout = self.stderr = iter(())+ self.stdin = None++ def poll(self):+ return 0++ with monkeypatch.context() as m:+ m.setattr(server.subprocess, "Popen", _Popen)+ # Multiplex is already active (mux_homes fixture). profile_home=None = launch-profile session.+ server._SlashWorker("sess", "", profile_home=None)+ # No UnscopedSecretError: the worker is launched under the launch profile's own home, not routed.+ env = captured["env"]+ assert env["HERMES_HOME"] == str(a)+ assert env["A_MARKER"] == "a" # launch residual retained (target is not a routed/foreign home)++def test_helper_children_resolve_secrets_through_the_served_profile(mux_homes):"""``key_cmd`` helpers and the browser driver spawned during B's turn see B's key, never A's."""from agent.command_token_source import _mintdiff --git a/tui_gateway/server.py b/tui_gateway/server.pyindex 0df4529a1e8..3325bc5edb0 100644--- a/tui_gateway/server.py+++ b/tui_gateway/server.py@@ -240,12 +240,19 @@ class _SlashWorker:# worker must resolve config/skills/state against the session's profile home, not the gateway's# launch HERMES_HOME (#40677).from tools.environments.local import served_profile_child_env+ from agent.secret_scope import is_multiplex_active# The worker runs the agent → needs provider credentials; tier-1 secrets (gateway/GitHub/# infra) are still stripped. A served profile's worker gets THAT profile's home + secrets and# none of the launch profile's .env / TERMINAL_* residue, exactly what a standalone# `hermes -p X` would load itself.- env = _prepend_tool_paths(served_profile_child_env(target_home=profile_home, inherit_credentials=True))+ # Multiplexing fail-closed: once the gateway serves a second profile home (#115427), the launch+ # profile's OWN worker must still pass its home explicitly — otherwise inherit_credentials=True+ # with no target (profile_home is None for the launch profile) and no bound scope raises+ # UnscopedSecretError. When multiplexing is off the default (no target) is correct and untouched.+ env = _prepend_tool_paths(served_profile_child_env(+ target_home=profile_home or (_hermes_home if is_multiplex_active() else None),+ inherit_credentials=True))# Internal slash workers must import the same checkout as their parent.module_root = str(Path(__file__).resolve().parent.parent)env["PYTHONPATH"] = os.pathsep.join(