feat(slack): make bot mention stripping configurable - #47536
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for identifying the multi-bot routing ambiguity. The behavior is still present on current main: the active Slack adapter unconditionally strips the addressed bot token from inbound text (plugins/platforms/slack/adapter.py:2870-2872), thread context (:3792-3794), and parent reply context (:3890-3894).
Problems
- The PR edits
gateway/platforms/slack.py, but commit5600105478ffde29d7566b45421b100eaa29c4efmoved the active adapter toplugins/platforms/slack/adapter.py; the proposed runtime edits need to be salvaged into that plugin. - Slack YAML translation is now plugin-owned:
gateway/config.py:1269-1309dispatchesplugins/platforms/slack/adapter.py::_apply_yaml_config(:4485-4519). The new setting belongs in that hook rather than a restored core Slack-specific block. - Please document the new user-facing setting alongside the Slack mention configuration at
website/docs/user-guide/messaging/slack.md:383-419.
Suggested changes
- Port the resolver, the three stripping gates, and regression tests to the migrated plugin paths; preserve config.yaml as the user-facing mechanism and use the plugin bridge only for its existing internal environment-backed runtime model.
Automated hermes-sweeper review.
| @@ -2522,9 +2522,10 @@ async def _handle_slack_message(self, event: dict) -> None: | |||
| ): | |||
There was a problem hiding this comment.
Current main migrated the active Slack adapter to plugins/platforms/slack/adapter.py in 5600105478ffde29d7566b45421b100eaa29c4ef; salvage this guard and the other stripping sites into that plugin path so the change reaches the live adapter.
| @@ -1037,6 +1039,8 @@ def _merge_platform_map(source_platforms: Any) -> None: | |||
| os.environ["SLACK_REQUIRE_MENTION"] = str(slack_cfg["require_mention"]).lower() | |||
| if "strict_mention" in slack_cfg and not os.getenv("SLACK_STRICT_MENTION"): | |||
| os.environ["SLACK_STRICT_MENTION"] = str(slack_cfg["strict_mention"]).lower() | |||
There was a problem hiding this comment.
Current main delegates Slack YAML-to-environment translation to plugins/platforms/slack/adapter.py::_apply_yaml_config (gateway/config.py:1269-1309). Add this bridge to that plugin hook rather than the removed core Slack configuration block.
Summary
strip_bot_mentionsconfig, defaulting totrueto preserve existing behaviorstrip_bot_mentions: falseto keep raw<@U...>bot mention tokens in current message text, fetched thread context, and thread-parentreply_to_textSLACK_STRIP_BOT_MENTIONSenv fallbackRationale / example scenario
In a shared Slack channel with two Hermes gateway profiles installed, a user might write:
while another Hermes bot/profile is also participating in the same thread. If the Slack adapter strips
<@U_DEFAULT_HERMES>before the model sees the message, I only receivecan you check the deployment?. That loses the key evidence for who was explicitly addressed.An even more ambiguous case is a message that mentions one bot/profile but is addressed to another:
If the addressed mention is stripped, the model sees only
can you check on <@U_OTHER_HERMES>'s deployment?. In a multi-bot thread, that can look like the remaining mentioned bot/profile is the intended addressee, even though the user was actually asking the default Hermes bot to inspect something belonging to the other profile.Preserving the raw mention tokens when
strip_bot_mentions: falsegives the model the same routing clues Slack had at the adapter layer, so it can distinguish between:The default remains
true, so existing single-bot workspaces keep the current cleaned-up prompt text unless they opt into preserving mentions.Test plan
python -m pytest tests/gateway/test_slack.py tests/gateway/test_slack_approval_buttons.py tests/gateway/test_slack_mention.py -q -o 'addopts='git diff --checkpython -m py_compile gateway/platforms/slack.py gateway/config.py tests/gateway/test_slack.py tests/gateway/test_slack_approval_buttons.py tests/gateway/test_slack_mention.py tests/conftest.py