Skip to content

fix(slack): tighten strict mention routing - #20723

Closed
Claude-Kimn wants to merge 8 commits into
NousResearch:mainfrom
Claude-Kimn:codex/ai-5142-runtime-main
Closed

fix(slack): tighten strict mention routing#20723
Claude-Kimn wants to merge 8 commits into
NousResearch:mainfrom
Claude-Kimn:codex/ai-5142-runtime-main

Conversation

@Claude-Kimn

@Claude-Kimn Claude-Kimn commented May 6, 2026

Copy link
Copy Markdown

What does this PR do?

Improves Slack channel/thread routing for strict mention mode and nudges non-tool empty model responses to produce a short visible answer before giving up.

This carries the AI-5142 production hotfixes onto the current main branch so deployments can be reproduced from source instead of a server-only runtime branch.

Related Issue

Fixes #8019

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • gateway/platforms/slack.py
    • allow configured plain-text mention_patterns to count as explicit Slack calls, including in strict_mention mode
    • keep strict mode from auto-engaging on prior thread memory/session presence alone
    • allow only narrow same-user direct follow-up after this bot's immediately preceding reply
    • ignore strict follow-up messages that mention a different Slack user
  • gateway/config.py
    • bridge top-level Slack mention_patterns into platform extra config/env
  • run_agent.py
    • nudge non-tool empty responses to produce a short visible answer before giving up
  • hermes_cli/commands.py
    • route Slack native slash aliases such as /hermes-status to Hermes commands
  • tests/run_agent/test_run_agent.py
    • cover non-tool empty response retry behavior

How to Test

  1. Configure Slack with require_mention: true, strict_mention: true, and mention_patterns for a bot name.
  2. In a Slack channel thread, verify that @bot and configured name calls route to the bot.
  3. Verify that unrelated thread replies, replies mentioning another user, and old thread/session presence do not auto-engage the bot.
  4. Verify that same-user direct follow-up after the bot's immediately previous reply is still routed.
  5. Verify that a non-tool empty response receives a nudge asking the model to produce a short visible reply.

Tested:

./venv/bin/python -m pytest tests/gateway/test_slack_mention.py tests/run_agent/test_run_agent.py -k "slack_mention or truly_empty_response"
# 44 passed

Local macOS clone did not have pytest installed; the test command above was run in the Hermes runtime venv on Linux.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Linux runtime venv

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

N/A

Screenshots / Logs

Production symptoms addressed:

  • Slack strict-mode bot replied to thread messages due to prior thread/session participation.
  • Non-tool empty model responses repeated empty outputs without an explicit recovery instruction.

@Claude-Kimn Claude-Kimn closed this May 6, 2026
@Claude-Kimn

Copy link
Copy Markdown
Author

I'm sorry about pushing the pr to this upstream.
AI made this PR but i didn't make to make it.

@alt-glitch alt-glitch added type/bug Something isn't working platform/slack Slack app adapter comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists labels May 6, 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/slack Slack app adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slack require_mention is bypassed in active threads, which breaks multi-agent workflows

3 participants