hermes - ✅(Solved) Fix [Feature]: Configurable command prefix for the messaging gateway [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#12688Fetched 2026-04-20 12:17:26
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1labeled ×1referenced ×1

Fix Action

Fix / Workaround

  • Using DMs only — partially works, but doesn't help in rooms/channels
  • Patching the source locally — breaks on every hermes update

PR fix notes

PR #12841: feat(gateway): add configurable command_prefix to avoid platform conflicts

Description (problem / solution / changelog)

Summary

Closes #12688.

On Matrix and Mattermost, the / character is reserved by the platform for native slash commands, making Hermes gateway commands like /reset, /model, /status unreliable or unusable.

Changes

Add a command_prefix config key with per-platform override support:

gateway:
  command_prefix: "!"       # global default (default: /)
  platform_command_prefix:
    matrix: "\\"
    mattermost: "!"

Modified files:

  • gateway/config.py — Add command_prefix and platform_command_prefix fields to GatewayConfig, with get_command_prefix(platform) method and YAML parsing
  • gateway/platforms/base.py — Use command_prefix in MessageEvent.is_command and command_name properties
  • gateway/platforms/{discord,matrix,mattermost,slack,telegram}.py — Pass command_prefix through to MessageEvent construction
  • gateway/run.py — Set adapter.command_prefix from config during platform init
  • tests/test_command_prefix.py — 17 tests covering MessageEvent detection, GatewayConfig defaults/overrides, and config parsing

Testing

All 17 new tests pass. No existing tests broken. Default remains / so existing setups are unaffected.

Changed files

  • gateway/config.py (modified, +34/-0)
  • gateway/platforms/base.py (modified, +12/-6)
  • gateway/platforms/discord.py (modified, +5/-5)
  • gateway/platforms/matrix.py (modified, +3/-1)
  • gateway/platforms/mattermost.py (modified, +2/-1)
  • gateway/platforms/slack.py (modified, +4/-2)
  • gateway/platforms/telegram.py (modified, +1/-0)
  • gateway/run.py (modified, +1/-0)
  • tests/test_command_prefix.py (added, +102/-0)

Code Example

gateway:
  command_prefix: "!"  # global fallback, default: /
  platform_command_prefix:
    matrix: "\\"
    mattermost: "!"

---
RAW_BUFFERClick to expand / collapse

Problem or Use Case

On Matrix and Mattermost, the / character is reserved by the platform for its own native slash command system. This means Hermes gateway commands like /reset, /model, /status, and /background either get intercepted by the client before reaching the bot, or conflict with platform-registered commands — making them unreliable or completely unusable.

This is a real blocker for anyone running the gateway on these two platforms, both of which are listed as supported.

Proposed Solution

Add a command_prefix key to ~/.hermes/config.yaml that controls which character the gateway uses to detect commands, with an optional per-platform override:

gateway:
  command_prefix: "!"  # global fallback, default: /
  platform_command_prefix:
    matrix: "\\"
    mattermost: "!"

The default would remain / so no existing setup is affected. The change should be isolated to the prefix-stripping logic in gateway/run.py. The pattern is consistent with how other per-platform config keys already work (e.g. tool_progress, reset_by_platform).

Alternatives Considered

Alternatives Considered

  • Using DMs only — partially works, but doesn't help in rooms/channels
  • Patching the source locally — breaks on every hermes update

Feature Type

Configuration option

Scope

Small (single file, < 50 lines)

Contribution

  • I'd like to implement this myself and submit a PR

Debug Report (optional)

extent analysis

TL;DR

To resolve the issue of Hermes gateway commands being intercepted by Matrix and Mattermost's native slash command systems, add a configurable command_prefix to the gateway settings.

Guidance

  • Introduce a command_prefix key in ~/.hermes/config.yaml to specify the character used for detecting commands, with optional per-platform overrides.
  • Update the gateway/run.py file to incorporate the new prefix-stripping logic based on the configured command_prefix.
  • Test the changes on both Matrix and Mattermost platforms to ensure the gateway commands are no longer intercepted.
  • Consider setting a global fallback prefix (e.g., !) and specific prefixes for Matrix (e.g., \) and Mattermost (e.g., !) to maintain compatibility.

Example

gateway:
  command_prefix: "!"  # global fallback
  platform_command_prefix:
    matrix: "\\"
    mattermost: "!"

Notes

This solution assumes that the prefix-stripping logic in gateway/run.py can be updated to support the new command_prefix configuration. The changes should be isolated to this file to minimize the impact on the existing codebase.

Recommendation

Apply the proposed workaround by introducing the command_prefix configuration option, as it provides a flexible solution for resolving the command interception issue on Matrix and Mattermost platforms.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING