feat(discord-tool): add add_reaction / remove_reaction actions - #80817
Open
vel007-ai wants to merge 1 commit into
Open
feat(discord-tool): add add_reaction / remove_reaction actions#80817vel007-ai wants to merge 1 commit into
vel007-ai wants to merge 1 commit into
Conversation
The discord tool can pin, unpin, delete and thread a message, but not
react to one. An agent asked to react has nowhere to go: the adapter's
reaction machinery is private and reachable only from the 👀/✅
lifecycle hooks, and `send_message(action="react")` is deliberately not
agent-callable (toolsets.py: outbound messaging is handled outside the
agent loop). Observed failure mode is quiet - the model searches its
tools, finds pin/delete/thread but no react, and types the emoji into
its reply instead, where it is prose rather than a reaction.
Adds the pair to the core (participate) action set, next to
create_thread, following the pin_message/unpin_message shape:
add_reaction(channel_id, message_id, emoji)
remove_reaction(channel_id, message_id, emoji)
Both target the bot's own reaction (`/reactions/{emoji}/@me`), so an
agent can retract only what it placed and never strips another user's.
The emoji is percent-encoded with ':' preserved, so unicode emoji and
the custom-emoji `name:id` form both address correctly.
13 tasks
Collaborator
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.
What does this PR do?
The
discordtool can pin, unpin, delete and thread a message, but not react to one. Adds the missing pair to the core (participate) action set, next tocreate_thread:Both target
/channels/{cid}/messages/{mid}/reactions/{emoji}/@me, following the existingpin_message/unpin_messageshape. Because they are scoped to@me, an agent can retract only what it placed and can never strip another user's reaction — including the adapter's own 👀/✅ lifecycle marks. The emoji is percent-encoded with:preserved, so both unicode emoji and the custom-emojiname:idform address correctly.Why
An agent asked to react has nowhere to go today, and the failure is silent rather than loud:
_add_reaction/_remove_reaction) is private and reachable only from the lifecycle hooks.send_message(action="react")is deliberately not agent-callable —toolsets.pyis explicit that outbound platform messaging is handled outside the agent loop, andsend_message_tool.pysays the same. (I opened feat(discord): agent-facing add_reaction/remove_reaction (photon parity) #79074 to give the Discord adapter the publicadd_reaction/remove_reactionpair for photon parity, which is worth having on its own — but it does not put reactions in reach of a model, because nothing in an agent's toolset dispatches to it.)discordanddiscord_admin, and neither could react.Observed failure mode, from a real transcript: asked to reply with a verdict and react with it, the model searched its tools (
"Discord reply to message and add reaction"), got backdiscordanddiscord_admin, found pin/delete/thread but nothing for reactions, and silently gave up — typing the emoji into its reply text instead, where it is prose rather than a reaction. Nothing errored; the capability just wasn't there.With this change the same prompt works unmodified: the model finds
add_reaction, calls it, and the reaction lands alongside the lifecycle ✅.Related Issue
Partially addresses #29026, which asks for both directions. This is the outbound half (the agent placing reactions); inbound Discord reaction events remain #46855.
Changes Made
tools/discord_tool.py—_add_reaction/_remove_reactionaction handlers, a shared_reaction_path()encoder, both registered in_ACTIONSand_CORE_ACTION_NAMES, entries in_ACTION_MANIFESTand_REQUIRED_PARAMS, and anemojiparameter threaded through_run_discord_action+_HANDLER_DEFAULTS+ the schema properties.tests/tools/test_discord_tool.py— 5 tests: add, remove, custom-emojiname:idencoding, core-vs-admin placement, and schema exposure.How to Test
pytest tests/tools/test_discord_tool.py -q→ 46 passed.DISCORD_BOT_TOKENset:{"success": true, ...}and the reaction appears/disappears. I verified this on a real message, then end-to-end: an agent asked for a verdict reaction placed 🔴 itself via the new action, leaving the lifecycle ✅ untouched.Checklist
Code
discordREST tool; feat(matrix): agent-facing add_reaction/remove_reaction (photon parity) #77994/feat(discord): agent-facing add_reaction/remove_reaction (photon parity) #79074 add the adapter-side pair for Matrix/Discord, which is a different, non-agent-callable path)pytest tests/ -qand all tests pass — partially:tests/tools/test_discord_tool.pyis fully green (46 passed). The full run in my environment has pre-existing failures from optional deps I don't have installed; the file I touch has an identical pass/fail set before and after.Documentation & Housekeeping
discord.server_actionsallowlist)