Skip to content

feat(matrix): agent-facing add_reaction/remove_reaction (photon parity) - #77994

Open
CocaKova wants to merge 1 commit into
NousResearch:mainfrom
CocaKova:feat/matrix-agent-reactions
Open

feat(matrix): agent-facing add_reaction/remove_reaction (photon parity)#77994
CocaKova wants to merge 1 commit into
NousResearch:mainfrom
CocaKova:feat/matrix-agent-reactions

Conversation

@CocaKova

@CocaKova CocaKova commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

What

send_message(action="react") resolves reactions by duck-typing public add_reaction/remove_reaction coroutines on the live adapter (tools/send_message_tool.py). The photon adapter ships the pair; Matrix has only the private _send_reaction/_redact_reaction machinery it uses for lifecycle tapbacks (👀/✅) — so reacting on Matrix errors Platform 'matrix' does not support message reactions even though the adapter can already post native m.reaction annotations.

This adds the public pair to the Matrix adapter, mirroring photon's semantics:

  • Default target = the room's most recent inbound message (recorded in on_processing_start before the MATRIX_REACTIONS gate — that env var exists to mute the automatic tapback noise, not deliberate requests; same policy photon documents for PHOTON_REACTIONS).
  • Explicit message_id overrides the default.
  • remove_reaction redacts only annotations this process placed (tracked per (room, target)), so lifecycle tapbacks keep managing their own redaction.

Reactions land as standard m.annotation relations, so Element and other Matrix clients render them natively.

Why

Reaction support on Matrix is half-shipped today: the dispatch layer and its tests exist, photon and signal implement their sides, and website/docs/user-guide/messaging/matrix.md ("Matrix Tools and Controls") advertises reaction ability — but the Matrix adapter never grew the public verbs, so the MCP surface (mcp_serve.py exposes send_message wholesale) errors on Matrix. Verified end-to-end against a live Synapse homeserver before submitting: the agent's reaction arrives as a native annotation and renders in Element.

Related but out of scope: that same docs section lists several matrix_* tools (matrix_send_reaction, matrix_fetch_history, …) that don't exist in the tree — worth a separate docs pass.

Tests

8 new tests in tests/gateway/test_matrix_agent_reactions.py (default targeting, explicit id, no-target and send-failure error paths, unreact redaction + own-annotation guard, target recording under MATRIX_REACTIONS=false, and the send_message dispatch end-to-end via a stub runner). 173 matrix gateway tests + tests/tools/test_send_message_react.py + the photon reaction suite all pass.

send_message(action="react") dispatches by duck-typing public
add_reaction/remove_reaction on the live adapter. Photon ships the
pair; Matrix had only the private _send_reaction machinery, so
reacting on Matrix errored "Platform 'matrix' does not support
message reactions" even though the adapter already posts native
m.reaction annotations for its lifecycle tapbacks.

Add the public pair, mirroring photon's semantics: default target is
the room's most recent inbound message (recorded in
on_processing_start before the MATRIX_REACTIONS gate — that env var
mutes the automatic tapback noise, not deliberate agent intents),
explicit message_id overrides, and unreact redacts only annotations
this process placed.

8 new tests in tests/gateway/test_matrix_agent_reactions.py; 173
matrix gateway tests + the send_message react dispatch and photon
reaction suites all green.
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins platform/matrix Matrix adapter (E2EE) labels Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have platform/matrix Matrix adapter (E2EE) type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants