From deb59eab727c757d7ea9a239616582b25b531525 Mon Sep 17 00:00:00 2001 From: pdonizete <2013236+pdonizete@users.noreply.github.com> Date: Sat, 2 May 2026 17:35:24 -0300 Subject: [PATCH] fix: allow kanban tools for orchestrator profiles with kanban toolset The _check_kanban_mode() gating function only checked for HERMES_KANBAN_TASK env var, which is only set by the dispatcher when spawning workers. This prevented orchestrator profiles (like techlead) from using kanban_create, kanban_link, etc. even when they had 'kanban' explicitly in their toolsets config. Now uses load_config() from hermes_cli.config (which has mtime-based caching) to check if 'kanban' is in the profile's toolsets list. This enables orchestrators to route work via Kanban while workers continue using the dispatcher env var. Fixes #18968 --- tools/kanban_tools.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/tools/kanban_tools.py b/tools/kanban_tools.py index de5d180c83..d0023a3078 100644 --- a/tools/kanban_tools.py +++ b/tools/kanban_tools.py @@ -40,13 +40,31 @@ logger = logging.getLogger(__name__) # --------------------------------------------------------------------------- def _check_kanban_mode() -> bool: - """Tools are available iff the current process has ``HERMES_KANBAN_TASK`` - set in its env, which the dispatcher sets when spawning a worker. + """Tools are available when: - Humans running ``hermes chat`` see zero kanban tools. Workers spawned - by the kanban dispatcher (gateway-embedded by default) see all seven. + 1. ``HERMES_KANBAN_TASK`` is set (dispatcher-spawned worker), OR + 2. The current profile has ``kanban`` in its toolsets config + (orchestrator profiles like techlead that route work via Kanban). + + Humans running ``hermes chat`` without the kanban toolset see zero + kanban tools. Workers spawned by the kanban dispatcher (gateway- + embedded by default) and orchestrator profiles with the kanban + toolset enabled see all seven. """ - return bool(os.environ.get("HERMES_KANBAN_TASK")) + if os.environ.get("HERMES_KANBAN_TASK"): + return True + + # Check if the current profile has the kanban toolset enabled. + # Uses load_config() which has mtime-based caching, so this adds + # negligible overhead. The check_fn results are further TTL-cached + # (~30s) by the tool registry. + try: + from hermes_cli.config import load_config + cfg = load_config() + toolsets = cfg.get("toolsets", []) + return "kanban" in toolsets + except Exception: + return False # ---------------------------------------------------------------------------