feat(gateway): opt-in Discord requester mention on approval prompts - #21528
feat(gateway): opt-in Discord requester mention on approval prompts#21528donovan-yohan wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an opt-in Discord feature to @mention the original requester when a dangerous-command execution approval prompt is posted, improving responsiveness (especially for mobile users) while keeping mentions tightly scoped via per-message allowed_mentions.
Changes:
- Introduces
discord.mention_exec_approval/DISCORD_MENTION_EXEC_APPROVAL(defaultfalse) and wires it through config/env bridging. - Refactors status/approval metadata construction into
gateway.run._build_status_thread_metadata, adding Discord requester fields while preserving Feishu reply-in-thread behavior. - Updates Discord adapter
send_exec_approval()to conditionally prepend a validated<@user_id>mention and pinallowed_mentionsto that single user; adds/extends tests and documentation.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
gateway/run.py |
Extracts status/approval metadata builder and enriches metadata for Discord/Feishu. |
gateway/platforms/discord.py |
Adds config reader + mention/allowed_mentions behavior in exec approval sends. |
gateway/config.py |
Bridges discord.mention_exec_approval from YAML to adapter extra and env var. |
tests/gateway/test_status_thread_metadata.py |
Adds focused unit tests for the new metadata builder behavior. |
tests/gateway/test_discord_send.py |
Adds tests covering ping-enabled/disabled paths and invalid requester ID handling. |
tests/gateway/test_config.py |
Adds tests for YAML→env bridging and env precedence. |
tests/gateway/conftest.py |
Extends the shared Discord mock to support embed fields and allowed-mentions assertions. |
website/docs/user-guide/messaging/discord.md |
Documents the new Discord setting and behavior. |
website/docs/reference/environment-variables.md |
Documents the new env var and links to the Discord docs section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8c7d7f5 to
50d4d66
Compare
|
Rebased/resolved conflicts against current Follow-up fixes included:
Verification:
Current head: |
50d4d66 to
7e0749c
Compare
7e0749c to
570b69f
Compare
|
Rebased against current Follow-up cleanup:
Verification:
GitHub now reports |
Add opt-in Discord requester mentions for dangerous command approval prompts, with scoped allowed_mentions, config/env bridging, docs, and gateway tests.
570b69f to
06028cb
Compare
Summary
Adds an opt-in Discord setting,
discord.mention_exec_approval/DISCORD_MENTION_EXEC_APPROVAL, defaultfalse.When enabled, dangerous-command approval prompts on Discord prepend
<@user_id> command approval neededso the original requester gets notified while the agent is blocked waiting for approval.The mention is constrained to a digit-only requester ID and the outgoing approval message uses per-message
AllowedMentionsrestricted to that single user.@everyone,@here, role pings, and replied-user pings remain disabled.Configuration
If both are present, the environment variable wins. Blank or invalid env values stay disabled.
Implementation
extra; does not seed process env from YAML, so gateway config reloads cannot get stuck behind a self-written env var.requester_user_idfor Discord human requesters.thread_id, Telegram DM topic fallback, Feishu reply metadata).send_exec_approval()adds mention content only when the setting is enabled and the requester ID is digit-only.Verification
ulimit -n 4096 && ./scripts/run_tests.sh tests/gateway/test_config.py tests/gateway/test_discord_send.py tests/gateway/test_status_thread_metadata.py -q— 87 passedulimit -n 4096 && ./scripts/run_tests.sh tests/gateway/test_tts_media_routing.py -q— 6 passedgit diff --check upstream/main...HEADFull
tests/gateway -qwas also attempted locally: the PR-relevant suites passed, while the run still had unrelated existing/baseline failures aroundPlatform.GOOGLE_CHATplugin enum registration plus two parallel timing failures that passed when rerun in isolation.Risk
Low: default off, requester IDs are validated before mention construction, and the mention allowlist is scoped per approval message.