Skip to content

fix(send_message): allow kanban workers to call send_message#23358

Closed
dmnkhorvath wants to merge 2 commits into
NousResearch:mainfrom
dmnkhorvath:fix/send-message-kanban-worker-check
Closed

fix(send_message): allow kanban workers to call send_message#23358
dmnkhorvath wants to merge 2 commits into
NousResearch:mainfrom
dmnkhorvath:fix/send-message-kanban-worker-check

Conversation

@dmnkhorvath

@dmnkhorvath dmnkhorvath commented May 10, 2026

Copy link
Copy Markdown
Contributor

Summary

send_message is unavailable to kanban-dispatcher-spawned workers because _check_send_message falls back to is_gateway_running(), which reads {HERMES_HOME}/gateway.pid — and workers run under the assignee profile's HERMES_HOME (e.g. ~/.hermes/profiles/calendar/), where no PID file exists. The parent gateway is alive and reachable; only the check fails.

This is asymmetric with _check_kanban_mode in tools/kanban_tools.py:42, which already honors HERMES_KANBAN_TASK (the env var the dispatcher sets on every spawned worker, see hermes_cli/kanban_db.py:3782). So today, a worker can call every kanban_* tool but cannot call send_message.

This PR mirrors that pattern in _check_send_message: if HERMES_KANBAN_TASK is set, the worker is dispatcher-spawned, the parent gateway is by definition running, and send_message is safe to allow.

Why this matters

The kanban completion notifier truncates payload_summary to its first line, max 200 chars (gateway/run.py:3963):

h = payload_summary.strip().splitlines()[0][:200]

For workers whose natural output is richer than a one-liner (a calendar listing, a deck export with a paste URL, a research idea ranking, a video summary with bullets), the only ergonomic delivery path is for the worker to call send_message(platform=..., chat_id=..., text=<full content>) itself, then kanban_complete(summary=<one-liner>) for the notifier's "✔ done" line. Today that pattern silently fails: send_message is gated off, the worker either hallucinates success or substitutes kanban_comment (which the user never sees on Telegram).

Net user-visible effect: a Telegram-originated kanban task completes, the user gets ✔ Kanban t_xxxx done — <one-line headline> and nothing else. Rich content lives in the kanban DB but never reaches the chat.

Relationship to other in-flight work

Change

 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", "")
     ...

os is already imported at module top (tools/send_message_tool.py:11).

Test plan

  • Reproduced locally: spawned a kanban worker via Telegram-originated dispatch; before patch, worker's tool registry showed send_message unavailable (check failed) and the worker silently fell back to kanban_comment.
  • Applied patch + restarted gateway. Worker can now invoke send_message(platform="telegram", chat_id=..., text=...) and the rich content reaches the originating chat.
  • No new tests added — happy to add one if reviewers want; the existing test surface for _check_send_message is thin.

Out of scope

  • The 200-char first-line truncation in gateway/run.py:3963 is intentional (notifier wants scannable headlines). This PR does not touch it; instead it makes the documented worker-side workaround actually work.
  • No changes to _check_kanban_mode, profile config defaults, or the dispatcher.

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.
Adds a TestCheckSendMessage class with 7 focused tests pinning the
four passing conditions and the failure modes:

  - HERMES_KANBAN_TASK grants access (the new branch)
  - HERMES_KANBAN_TASK short-circuits before consulting
    session_context or gateway.status (so workers don't depend on
    those import paths being healthy)
  - HERMES_SESSION_PLATFORM=telegram grants access
  - HERMES_SESSION_PLATFORM=local falls through to gateway check
  - is_gateway_running()=True grants access
  - All signals absent → False
  - gateway.status ImportError is swallowed → False

Pinning the short-circuit (test NousResearch#2) is the load-bearing one — it
documents the contract that worker-side availability cannot regress
to depending on gateway-side state lookups.
@alt-glitch alt-glitch added type/bug Something isn't working comp/tools Tool registry, model_tools, toolsets comp/cron Cron scheduler and job management P3 Low — cosmetic, nice to have labels May 10, 2026
kshitijk4poor added a commit that referenced this pull request May 11, 2026
For PRs #23206 (Frowtek), #23252 (Sylw3ster), #23358 (dmnkhorvath),
#23659 (smwbev), and #23356 (TurgutKural) — all part of the kanban
bug-fix batch salvage.
@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Merged via salvage PR #23791. Your commits were cherry-picked onto current main with your authorship preserved in git log. Thanks for the fix!

rmulligan pushed a commit to rmulligan/hermes-agent that referenced this pull request May 11, 2026
For PRs NousResearch#23206 (Frowtek), NousResearch#23252 (Sylw3ster), NousResearch#23358 (dmnkhorvath),
NousResearch#23659 (smwbev), and NousResearch#23356 (TurgutKural) — all part of the kanban
bug-fix batch salvage.
JinyuID pushed a commit to JinyuID/hermes-agent that referenced this pull request May 11, 2026
For PRs NousResearch#23206 (Frowtek), NousResearch#23252 (Sylw3ster), NousResearch#23358 (dmnkhorvath),
NousResearch#23659 (smwbev), and NousResearch#23356 (TurgutKural) — all part of the kanban
bug-fix batch salvage.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
For PRs NousResearch#23206 (Frowtek), NousResearch#23252 (Sylw3ster), NousResearch#23358 (dmnkhorvath),
NousResearch#23659 (smwbev), and NousResearch#23356 (TurgutKural) — all part of the kanban
bug-fix batch salvage.
jsboige pushed a commit to jsboige/hermes-agent that referenced this pull request May 14, 2026
For PRs NousResearch#23206 (Frowtek), NousResearch#23252 (Sylw3ster), NousResearch#23358 (dmnkhorvath),
NousResearch#23659 (smwbev), and NousResearch#23356 (TurgutKural) — all part of the kanban
bug-fix batch salvage.
AlexFoxD pushed a commit to AlexFoxD/hermes-agent that referenced this pull request May 21, 2026
For PRs NousResearch#23206 (Frowtek), NousResearch#23252 (Sylw3ster), NousResearch#23358 (dmnkhorvath),
NousResearch#23659 (smwbev), and NousResearch#23356 (TurgutKural) — all part of the kanban
bug-fix batch salvage.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
For PRs NousResearch#23206 (Frowtek), NousResearch#23252 (Sylw3ster), NousResearch#23358 (dmnkhorvath),
NousResearch#23659 (smwbev), and NousResearch#23356 (TurgutKural) — all part of the kanban
bug-fix batch salvage.
Seven74AI pushed a commit to Seven74AI/hermes-agent that referenced this pull request Jun 13, 2026
For PRs NousResearch#23206 (Frowtek), NousResearch#23252 (Sylw3ster), NousResearch#23358 (dmnkhorvath),
NousResearch#23659 (smwbev), and NousResearch#23356 (TurgutKural) — all part of the kanban
bug-fix batch salvage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cron Cron scheduler and job management comp/tools Tool registry, model_tools, toolsets P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants