@@ -112,6 +112,30 @@ def _moa_reference_output_allowed(agent: Any) -> bool:
112112 )
113113
114114
115+ def _resolve_kanban_worker_guidance (valid_tool_names : set [str ]) -> str :
116+ """Return task lifecycle guidance only for a real dispatcher worker.
117+
118+ Orchestrator profiles may expose ``kanban_show`` in ordinary chat so they
119+ can route board work. Tool availability alone therefore does not mean the
120+ current process owns a task. Injecting worker guidance into those chats
121+ falsely tells the model to call ``kanban_show()`` first, even when no
122+ ``HERMES_KANBAN_TASK`` exists and the user explicitly requested direct
123+ execution.
124+
125+ Requiring both the dispatcher task marker and the worker tool keeps the
126+ prompt off ordinary orchestrator sessions and delegated children while
127+ preserving the full lifecycle contract for real workers.
128+ """
129+ if not os .environ .get ("HERMES_KANBAN_TASK" ):
130+ return ""
131+ if "kanban_show" not in valid_tool_names :
132+ return ""
133+
134+ from agent .prompt_builder import KANBAN_GUIDANCE
135+
136+ return KANBAN_GUIDANCE
137+
138+
115139def _relay_moa_reference_event (agent : Any , event : str , ** kwargs : Any ) -> None :
116140 """Relay MoA display events while preserving the ``-Q`` stdout contract."""
117141 if not _moa_reference_output_allowed (agent ):
@@ -1643,15 +1667,14 @@ def init_agent(
16431667 elif not agent .quiet_mode :
16441668 print ("🛠️ No tools loaded (all tools filtered out or unavailable)" )
16451669
1646- # Kanban worker/orchestrator lifecycle guidance is session-static:
1647- # the dispatcher decides at spawn time whether this process is a kanban
1648- # worker (kanban_show tool is present iff HERMES_KANBAN_TASK is set) .
1670+ # Kanban worker lifecycle guidance is session-static. Orchestrator profiles
1671+ # can expose kanban_show in ordinary chat, so tool presence alone is not a
1672+ # worker identity signal; the dispatcher task marker must also be present .
16491673 # Resolving the ~835-token block once here avoids re-running the
16501674 # membership test + reference on every system-prompt rebuild
16511675 # (init + each context compression).
1652- from agent .prompt_builder import KANBAN_GUIDANCE
1653- agent ._kanban_worker_guidance = (
1654- KANBAN_GUIDANCE if "kanban_show" in agent .valid_tool_names else ""
1676+ agent ._kanban_worker_guidance = _resolve_kanban_worker_guidance (
1677+ agent .valid_tool_names
16551678 )
16561679
16571680 # Check tool requirements
0 commit comments