The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(kanban): strip stale session routing from dispatched worker env
trymhaak148497f6d6ad
diff --git a/hermes_cli/kanban_db.py b/hermes_cli/kanban_db.pyindex 355a7933a31..a4b3c383df7 100644--- a/hermes_cli/kanban_db.py+++ b/hermes_cli/kanban_db.py@@ -8815,6 +8815,12 @@ def _default_spawn(prompt = f"work kanban task {task.id}"env = dict(os.environ)+ # The dispatcher is detached from every conversation. Its worker must never+ # inherit routing mirrored by a previous gateway turn, even before the first+ # session binds ContextVars in this process.+ from gateway.session_context import _VAR_MAP+ for key in _VAR_MAP:+ env.pop(key, None)# Inject HERMES_HOME so the worker reads the profile-scoped config.yaml# (fallback_providers, toolsets, agent settings, etc.) instead of the rootdiff --git a/tests/hermes_cli/test_kanban_db.py b/tests/hermes_cli/test_kanban_db.pyindex f4e55235255..0904a877b69 100644--- a/tests/hermes_cli/test_kanban_db.py+++ b/tests/hermes_cli/test_kanban_db.py@@ -3096,17 +3096,23 @@ class TestSharedBoardPaths:assert kb.kanban_db_path() == default_home / "kanban.db"assert kb.workspaces_root() == default_home / "kanban" / "workspaces"- def test_dispatcher_spawn_injects_kanban_db_and_workspaces_root(+ def test_dispatcher_spawn_injects_kanban_paths_without_stale_session(self, tmp_path, monkeypatch):- # The dispatcher's `_default_spawn` must inject HERMES_KANBAN_DB- # and HERMES_KANBAN_WORKSPACES_ROOT into the worker env so the- # worker converges on the dispatcher's paths even when the- # `-p <profile>` flag rewrites HERMES_HOME.+ # The dispatcher must pin board paths while stripping any unrelated+ # HERMES_SESSION_* identity inherited from the long-lived gateway.default_home = tmp_path / ".hermes"default_home.mkdir()self._set_home(monkeypatch, tmp_path, default_home)+ from gateway import session_context as sc++ # A dispatcher can launch before the gateway binds its first session.+ monkeypatch.setattr(sc, "_session_context_engaged", False)+ sc.reset_session_vars()+ for key in sc._VAR_MAP:+ monkeypatch.setenv(key, "stale-routing-value")+captured = {}class _FakePopen:@@ -3144,6 +3150,8 @@ class TestSharedBoardPaths:)assert env["HERMES_KANBAN_TASK"] == "t_dispatch_env"assert env["HERMES_KANBAN_BRANCH"] == "wt/t_dispatch_env"+ for key in sc._VAR_MAP:+ assert key not in env# ---------------------------------------------------------------------------