Skip to content

[codex] Add Discord mention pattern wake phrases - #29393

Closed
alvinycheung wants to merge 3 commits into
NousResearch:mainfrom
alvinycheung:codex/discord-mention-patterns
Closed

[codex] Add Discord mention pattern wake phrases#29393
alvinycheung wants to merge 3 commits into
NousResearch:mainfrom
alvinycheung:codex/discord-mention-patterns

Conversation

@alvinycheung

Copy link
Copy Markdown

Summary

Adds reusable text wake phrase support for the Discord gateway via discord.mention_patterns. Configured regex patterns can satisfy require_mention, matching the behavior teams often expect from name-based bot aliases while keeping Discord native @mention behavior intact.

Changes

  • Add shared helpers for compiling, matching, and stripping configured mention patterns.
  • Wire Discord message handling to treat configured regex matches as valid mentions when require_mention is enabled.
  • Strip a leading wake phrase plus common separators before dispatch, while preserving mid-message references.
  • Skip invalid regex patterns with a warning instead of failing gateway startup.
  • Document the new discord.mention_patterns default config key.
  • Add focused Discord gateway tests for alias triggering, stripping, embedded-word non-matches, invalid regex handling, ignored channels, and existing mention behavior.

Validation

  • python -m pytest tests/gateway/test_discord_free_response.py tests/gateway/test_discord_allowed_channels.py tests/gateway/test_discord_bot_filter.py tests/gateway/test_discord_connect.py -q
  • git diff --check

Security / local config

No local Hermes/OpenClaw config, tokens, OAuth files, .env files, user IDs, or bot credentials are included in this PR. Only source and test files are changed.

@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/discord Discord bot adapter labels May 20, 2026
@alvinycheung
alvinycheung marked this pull request as ready for review May 27, 2026 14:26

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused Discord wake-phrase implementation; the feature premise is still present on current main: plugins/platforms/discord/adapter.py:6212-6214 only accepts native explicit mentions when the gate applies.

Problems

  • scripts/gateway-watchdog.py:10-12 is unrelated to Discord mention patterns and hardcodes contributor-local macOS paths; it also hardcodes profile homes at lines 67-69. Please remove it from this PR. Hermes already has the portable system-service command in hermes_cli/subcommands/gateway.py:152-156.
  • Current main uses _self_is_explicitly_mentioned(message) at plugins/platforms/discord/adapter.py:6213; preserve that helper when integrating the pattern condition rather than reviving the stale direct message.mentions check in this diff.
  • The stated documentation update is not present in website/docs/user-guide/messaging/discord.md:314-322, and the tests only set the private _mention_patterns field instead of covering the config bridge at gateway/config.py:1209,1267.

Suggested changes

  • Keep the PR to the Discord feature, document discord.mention_patterns, and add a YAML-to-adapter configuration-path test.

Automated hermes-sweeper review.


STATE_FILE = Path("~/.hermes/gateway_watchdog_state.json").expanduser()
HERMES_BIN = Path("/Users/alvin/.local/bin/hermes")
PYTHON_BIN = Path("/Users/alvin/personal/hermes-agent/venv/bin/python")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this watchdog from the Discord wake-phrase PR. It hardcodes a contributor-local macOS executable, and the adjacent constants plus later HERMES_HOME assignments make the script non-portable and not profile-safe; hermes gateway install is the supported cross-platform service mechanism.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 13, 2026
@alvinycheung alvinycheung closed this by deleting the head repository Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/discord Discord bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants