[Feature]: Ambient agent gating — message:received hook - #31065
Closed
brimdor wants to merge 1 commit into
Closed
Conversation
Adds a new gateway hook event that fires after adapter-level gates
(mention check, channel allowlist) but before agent invocation.
User-installed hooks at ~/.hermes/hooks/ can return
{"action": "ignore"} to silently drop a message, preventing
the agent from being invoked at all. This enables "ambient" or
"blend-in" bots that observe all channel activity but only
respond selectively.
- gateway/run.py: emit_collect("message:received", ...) with
full message context (platform, chat, user, thread, message text)
- gateway/hooks.py: document the new event in module docstring
- tests/gateway/test_hooks.py: 5 new tests for ignore/respond
decisions, mixed handlers, context keys, and no-handler case
Zero impact on default behavior. Opt-in via user hooks only.
Closes NousResearch#31061
Collaborator
Contributor
|
Thanks for the ambient-gating implementation. This is now redundant with the gateway plugin hook already on
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem or Use Case
Hermes platform adapters have a binary response gate: either
require_mention: true(bot only responds when @mentioned) orfree_response_channels: \"*\"(bot responds to every message). There is no middle ground for an ambient, "blend-in" agent that observes all channel activity but only replies when it genuinely has something useful, funny, or insightful to add.Users who have opened the adapter (
require_mention: false,free_response_channels: \"*\") still need a way to selectively gate messages before paying for a full agent turn.Closes #31061
Proposed Solution
Add a new
message:receivedhook event that fires after adapter-level gates (mention check, channel allowlist) but before agent invocation.User-installed hooks at
~/.hermes/hooks/can return{"action": "ignore"}to silently drop a message, preventing the agent from being invoked at all.Hook context
{ "platform": "discord", # platform name "chat_id": "123", # channel/thread ID "user_id": "456", # author ID "user_name": "alice", # display name "message": "hello world", # full message text "message_id": "789", # message ID "is_bot": False, # was sender a bot? "chat_name": "general", # channel name "chat_topic": "...", # channel topic (if any) "thread_id": "...", # thread ID (if in thread) "guild_id": "101", # guild/workspace ID }Usage example
Create
~/.hermes/hooks/ambient-gate/HOOOK.yaml:Create
~/.hermes/hooks/ambient-gate/handler.py:Changes
gateway/run.pymessage:receivedhook + gate on{"action": "ignore"}gateway/hooks.pytests/gateway/test_hooks.pyTotal: +138 lines, 3 files
Backward Compatibility
require_mention/free_response_channelslogicrun_agent.py,prompt_builder.py, or session storageFeature Type
Gateway / messaging improvement
Scope
Medium (3 files, +138 lines)
Tests
Contribution