feat(gateway): inbound message reactions from Telegram - #24149
feat(gateway): inbound message reactions from Telegram#24149matrixclawx wants to merge 1 commit into
Conversation
Adds platform-level support for consuming user reactions on messages the bot is in. Telegram is the only adapter wired today; Discord/Slack still emit outbound lifecycle reactions only. - New ReactionEvent dataclass + ReactionHandler type in gateway/platforms/base.py - BasePlatformAdapter.set_reaction_handler() for consumers to opt in - Telegram adapter registers MessageReactionHandler, diffs old vs new reaction lists, emits one ReactionEvent per added/removed emoji - GatewayRunner default consumer appends a JSONL log at $HERMES_HOME/reactions/inbound.jsonl so agent tools can tail it - Channel reactor fallback (actor_chat when mr.user is None) - Tests cover dispatch, diff logic, no-handler drop, handler exceptions, and missing message_reaction shape - AGENTS.md note documents the flow and Telegram admin requirement
|
Related: #13992 (competing PR implementing the same feature behind env toggle) and #13942 (tracking issue). This PR takes a different architectural approach — new |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the inbound-reaction implementation. The current main branch needs a substantive rework before this can be salvaged.
Problems
- The PR targets
gateway/platforms/telegram.py, but that adapter was moved toplugins/platforms/telegram/adapter.pyby736ffb3bc15c56caeb27c554c7cc7f40a4232b45; the legacy path no longer exists on main. gateway/platforms/telegram.py:4518emits every Telegram reaction delta without proving the target was bot-authored or applying the normal inbound authorization/gating path. That can persist arbitrary group members' reaction activity for downstream consumers.tests/gateway/test_telegram_inbound_reactions.pydoes not exercise the claimedactor_chatfallback orGatewayRunnerJSONL serialization path.
Suggested changes
- Rework against the bundled Telegram plugin and the current plugin handler seam (
hermes_cli/plugins.py:991, added by7c4cde9e8). - Correlate reactions to bot outputs and apply authorization before dispatch; add coverage for that boundary, channel actors, and the chosen consumer behavior.
Automated hermes-sweeper review.
| @@ -4508,6 +4518,104 @@ def _build_message_event( | |||
| timestamp=message.date, | |||
There was a problem hiding this comment.
This handler emits every reaction update but never verifies that mr.message_id is a bot-authored target or applies normal inbound authorization before the event reaches a durable consumer. Please establish both boundaries before dispatching reaction data.
Summary
Adds inbound message-reaction handling to the Telegram gateway so agents can react to thumbs-up/down (or any emoji) on bot messages. Previously the adapter only sent outbound reactions; inbound
MessageReactionUpdatedevents were being dropped because noMessageReactionHandlerwas registered, even thoughallowed_updates=Update.ALL_TYPESwas already in place.ReactionEvent+ReactionHandlertypes ingateway/platforms/base.py.MessageReactionHandlerwired into the Telegram adapter — computes the add/remove diff between old and new reaction sets and emits one event per change. Channel posts (wheremr.user is None) fall back toactor_chatper python-telegram-bot semantics. Handler exceptions are caught so a bad consumer can't poison the polling loop.\$HERMES_HOME/reactions/inbound.jsonlso any agent toolset can tail the log and react out-of-band, without each sibling needing its own gateway patch.tests/gateway/covering add/remove diff, channel actor_chat fallback, exception isolation, and JSONL serialization.Test plan
python -m pytest tests/gateway/ -qpasses locally\$HERMES_HOME/reactions/inbound.jsonlactor_chatinstead ofuserremovedevent is emitted🤖 Generated with Claude Code