fix(send_message): allow kanban workers to call send_message

The kanban dispatcher sets HERMES_KANBAN_TASK on every spawned worker
but launches it with the assignee profile's HERMES_HOME (e.g.
~/.hermes/profiles/<name>/), which has no gateway.pid file. The
existing _check_send_message therefore returned False from the
is_gateway_running() fallback, even though the parent gateway is
alive and reachable.

Net effect: workers could call kanban_* tools (gated on
HERMES_KANBAN_TASK in _check_kanban_mode) but not send_message. This
breaks the natural pattern of "worker does the job, calls
send_message to deliver rich content to the originating chat, then
calls kanban_complete with a one-line summary" because the kanban
notifier's payload_summary is hard-truncated to the first line
(~200 chars) at gateway/run.py:3963 — anything richer has to ship
via send_message.

Honoring HERMES_KANBAN_TASK in _check_send_message — symmetric with
_check_kanban_mode in kanban_tools.py:42 — closes the gap. No new
state, no new env var, no profile-config changes required.
This commit is contained in:
Dominikh 2026-05-10 18:32:27 +00:00 committed by kshitij
parent 5af315c4cc
commit 8ac998cb0c

View file

@ -1757,7 +1757,20 @@ async def _send_feishu(pconfig, chat_id, message, media_files=None, thread_id=No
def _check_send_message():
"""Gate send_message on gateway running (always available on messaging platforms)."""
"""Gate send_message on gateway running (always available on messaging platforms).
Also passes for kanban workers the dispatcher sets ``HERMES_KANBAN_TASK``
on every spawned worker, but those workers run with the assignee profile's
``HERMES_HOME`` which has no ``gateway.pid``, so the gateway-running check
would fail even though the parent gateway is alive. Honoring the env var
lets workers call ``send_message`` to deliver rich content directly to the
originating chat (paired with ``kanban_complete`` for the short notifier
summary), which is the canonical pattern for any worker that needs to
reply with more than the ~200-char first-line truncation the kanban
notifier applies.
"""
if os.environ.get("HERMES_KANBAN_TASK"):
return True
from gateway.session_context import get_session_env
platform = get_session_env("HERMES_SESSION_PLATFORM", "")
if platform and platform != "local":