From a0c346543ad77c510568ff2fa3e272705141b60b Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Fri, 14 Aug 2026 13:29:26 -0700 Subject: [PATCH] test(agent): cover agent-in-profile-A with ambient home bound to profile B Regression case from CodeRabbit review: profile name must derive from a root resolver independent of the ambient home. --- tests/agent/test_bot_profile_prompt_isolation.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/agent/test_bot_profile_prompt_isolation.py b/tests/agent/test_bot_profile_prompt_isolation.py index 9767b9cf45..ffcbb315c8 100644 --- a/tests/agent/test_bot_profile_prompt_isolation.py +++ b/tests/agent/test_bot_profile_prompt_isolation.py @@ -114,3 +114,19 @@ def test_profile_name_default_when_home_is_root(tmp_path, monkeypatch): monkeypatch.setenv("HERMES_HOME", str(tmp_path)) assert system_prompt._profile_name_for_home(tmp_path) == "default" + + +def test_profile_name_correct_when_ambient_is_another_profile(tmp_path, monkeypatch): + """CodeRabbit case: agent belongs to profile A while the ambient home is + bound to profile B. The root must derive independently of the ambient + home, so A still resolves as 'mybot' (not 'default', and never 'other').""" + from agent import system_prompt + + bot_home = tmp_path / "profiles" / "mybot" + bot_home.mkdir(parents=True) + other_home = tmp_path / "profiles" / "other" + other_home.mkdir(parents=True) + + monkeypatch.setenv("HERMES_HOME", str(other_home)) + + assert system_prompt._profile_name_for_home(bot_home) == "mybot"