Skip to content

The agent that grows with you

fix(tui_gateway): bind the session's home for the cwd record only when the caller is not already in it

teknium1c935aa328f67
diff --git a/tui_gateway/session_workdir.py b/tui_gateway/session_workdir.py
index 314a75b6037..f2eec2785b6 100644
--- a/tui_gateway/session_workdir.py
+++ b/tui_gateway/session_workdir.py
@@ -315,10 +315,14 @@ def _register_session_cwd(session: dict | None) -> None:
cwd, cwd_source = _terminal_task_cwd_with_source(session)
# The cwd/override record is keyed by the ROUTED home (#123989). session.create is a plain
# @method, so bind the session's own profile home here or the record lands under the raw key
- # and the scoped turn (`profile:<p>:<key>`) misses it until the first `cd`.
+ # and the scoped turn (`profile:<p>:<key>`) misses it until the first `cd`. Callers already
+ # inside the session's scope (the turn) bind nothing: the routed home is theirs already.
+ import hermes_constants as hc
+
with contextlib.ExitStack() as stack:
- if profile_home := session.get("profile_home"):
- stack.callback(reset_hermes_home_override, set_hermes_home_override(str(profile_home)))
+ profile_home = session.get("profile_home")
+ if profile_home and hc.hermes_home_key(hc.get_hermes_home()) != hc.hermes_home_key(profile_home):
+ stack.callback(hc.reset_hermes_home_override, hc.set_hermes_home_override(str(profile_home)))
register_task_env_overrides(session["session_key"], {"cwd": cwd, "cwd_source": cwd_source})