hermes - 💡(How to fix) Fix Gateway hooks: `agent:end` event never dispatches to handler [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#14583Fetched 2026-04-24 06:16:22
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
labeled ×3

A gateway hook subscribed to agent:end loads successfully but the handle() function is never called. Messages are processed and responses delivered correctly — the hook simply never fires.

Error Message

Hook loads and registers without error. Agent processes messages normally. handle() is never invoked. No errors in gateway.log or gateway.error.log related to hook dispatch. The handler imports cleanly outside the gateway process (python3 -c "import handler" succeeds).

  • No exception or error logged at dispatch time — suggesting the dispatch call site itself is not reached, rather than the handler failing silently

Root Cause

A gateway hook subscribed to agent:end loads successfully but the handle() function is never called. Messages are processed and responses delivered correctly — the hook simply never fires.

Fix Action

Workaround

None found. Considering polling OpenRouter's usage API as an alternative data source for dispatch logging.

Code Example

~/.hermes/hooks/circuit-breaker/HOOK.yaml
~/.hermes/hooks/circuit-breaker/handler.py

---

name: circuit-breaker
description: Log dispatches to SQLite
events:
  - agent:end

---

import logging
from pathlib import Path

LOG = Path.home() / "spock" / "logs" / "hook-test.log"

async def handle(event_type, context):
    logging.basicConfig(filename=str(LOG), level=logging.DEBUG)
    logging.debug(f"HOOK FIRED: {event_type} keys={list(context.keys())}")
    with open(str(LOG), "a") as f:
        f.write(f"FIRED: {event_type}\n")

---

[hooks] Loaded hook 'circuit-breaker' for events: ['agent:end']
RAW_BUFFERClick to expand / collapse

Gateway hooks: agent:end event never dispatches to handler

Environment

  • Hermes Agent v0.10.0 (2026.4.16)
  • Python 3.11.15
  • macOS 15.7.5 (Intel x86_64)
  • Gateway running via hermes gateway run --replace
  • Model: moonshotai/kimi-k2.6 via OpenRouter

Description

A gateway hook subscribed to agent:end loads successfully but the handle() function is never called. Messages are processed and responses delivered correctly — the hook simply never fires.

Steps to Reproduce

  1. Create hook directory and files:
~/.hermes/hooks/circuit-breaker/HOOK.yaml
~/.hermes/hooks/circuit-breaker/handler.py
  1. HOOK.yaml:
name: circuit-breaker
description: Log dispatches to SQLite
events:
  - agent:end
  1. handler.py (minimal reproducer):
import logging
from pathlib import Path

LOG = Path.home() / "spock" / "logs" / "hook-test.log"

async def handle(event_type, context):
    logging.basicConfig(filename=str(LOG), level=logging.DEBUG)
    logging.debug(f"HOOK FIRED: {event_type} keys={list(context.keys())}")
    with open(str(LOG), "a") as f:
        f.write(f"FIRED: {event_type}\n")
  1. Start gateway: hermes gateway run --replace
  2. Gateway log confirms hook loaded:
[hooks] Loaded hook 'circuit-breaker' for events: ['agent:end']
  1. Send a message via Telegram (or Signal). Agent responds correctly.
  2. Check ~/spock/logs/hook-test.log — file does not exist. handle() was never called.

Expected Behaviour

After the agent finishes processing a message and sends its response, the agent:end event should dispatch to all registered gateway hooks, calling handle("agent:end", context) with the documented context keys (platform, user_id, session_id, message, response).

Actual Behaviour

Hook loads and registers without error. Agent processes messages normally. handle() is never invoked. No errors in gateway.log or gateway.error.log related to hook dispatch. The handler imports cleanly outside the gateway process (python3 -c "import handler" succeeds).

Observations

  • The hook loads on every gateway restart (confirmed by repeated [hooks] Loaded hook log lines)
  • The handler module is syntactically valid and importable
  • The handler function signature matches the documented interface (async def handle(event_type, context))
  • Other gateway functionality works correctly (Telegram/Signal message processing, slash commands, pairing)
  • No exception or error logged at dispatch time — suggesting the dispatch call site itself is not reached, rather than the handler failing silently

Questions

  1. Is agent:end actually wired to dispatch in gateway mode, or only in CLI chat mode?
  2. Is there a different event name for gateway-processed messages (e.g. gateway:agent:end or message:end)?
  3. Does the hook system require hooks_auto_accept: true in config.yaml for gateway hooks to fire, even after loading?

Workaround

None found. Considering polling OpenRouter's usage API as an alternative data source for dispatch logging.

extent analysis

TL;DR

The agent:end event may not be dispatching to the handler due to a potential mismatch in event names or dispatching logic in gateway mode.

Guidance

  • Verify if the agent:end event is actually wired to dispatch in gateway mode by checking the gateway's documentation or source code.
  • Investigate if there's a different event name for gateway-processed messages, such as gateway:agent:end or message:end, that could be used instead.
  • Check the config.yaml file to see if hooks_auto_accept is set to true, which might be required for gateway hooks to fire.
  • Consider adding logging or debugging statements to the gateway's hook dispatching logic to see if the event is being dispatched at all.

Example

No code snippet is provided as the issue seems to be related to the event dispatching logic rather than the handler code itself.

Notes

The issue might be specific to the gateway mode or the OpenRouter model being used. More information about the gateway's configuration and the OpenRouter model might be needed to provide a definitive solution.

Recommendation

Apply a workaround by using a different event name or polling OpenRouter's usage API as an alternative data source for dispatch logging, as the root cause of the issue is unclear.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix Gateway hooks: `agent:end` event never dispatches to handler [1 participants]