openclaw - ✅(Solved) Fix slack: agents do not wake on <!subteam^...> user-group mentions [1 pull requests, 2 comments, 3 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
openclaw/openclaw#73827Fetched 2026-04-29 06:14:34
View on GitHub
Comments
2
Participants
3
Timeline
5
Reactions
1
Timeline (top)
commented ×2cross-referenced ×1mentioned ×1subscribed ×1

Mentioning a Slack user-group (subteam) does not wake any of the OpenClaw agents that belong to it. The Slack adapter's mention preflight only recognizes direct <@UXXX> tokens against each bot's own user id; it has no awareness of <!subteam^SXXX> tokens at all. So a message like:

<!subteam^S0B07LS458B> ping

…in a channel where three agents are subscribed will route to one of them, evaluate wasMentioned=false, hit the room's requireMention gate, and silently drop. The agents are working as coded, but it's a real adapter gap as soon as anyone uses Slack user-groups to address a fleet of agents.

Root Cause

extensions/slack/src/monitor/message-handler/prepare.ts (compiled as dist/extensions/slack/prepare-*.js) computes:

const explicitlyMentioned = Boolean(
  ctx.botUserId && message.text?.includes(`<@${ctx.botUserId}>`),
);

…and feeds that into matchesMentionWithExplicit. There is zero handling of <!subteam^...> tokens anywhere in the Slack extension. Slack's bundled @slack/types references subteam only as a block-kit element type — never the inbound mention path.

Fix Action

Fixed

PR fix notes

PR #73828: feat(slack): wake on configured subteam mentions

Description (problem / solution / changelog)

Closes #73827.

What

Adds GroupChatConfig.subteamMentions: string[] and teaches the Slack adapter's mention preflight to treat <!subteam^SXXX> tokens as an explicit @-mention for the routed agent when SXXX is in the agent's configured list (or the global fallback).

Why

Mentioning a Slack user-group containing multiple OpenClaw agents currently wakes none of them — the adapter only checks for direct <@UXXX> tokens. Full context, options considered, and config example in #73827.

This is the "option 3" config-only path: no new Slack scopes, no API cache, no event subscriptions. Composes cleanly with a future API-expansion implementation (option 2).

Diff highlights

  • src/config/types.messages.ts — schema field on GroupChatConfig (auto-inherited by global messages.groupChat and per-agent agents.list[].groupChat).
  • extensions/slack/src/monitor/message-handler/subteam-mentions.ts — pure helper:
    • extractSlackSubteamMentionIds(text)
    • matchesConfiguredSubteamMention(ids, cfg, agentId) — agent override beats global, presence-as-override mirrors existing mentionPatterns semantics.
  • extensions/slack/src/monitor/message-handler/prepare.ts — passes routing.route.agentId into resolveWasMentioned and folds the per-agent subteam check into the explicit-mention signal. Pre-routing seed kept at bot-id only; the existing wasMentioned && !seedTopLevelRoomThreadBySource re-route handles thread reseed when subteam path is what triggers the wake.
  • extensions/slack/src/monitor/message-handler/subteam-mentions.test.ts — covers extraction, dedupe, case-insensitivity, agent override, opt-out via empty list.

Test

Local unit tests added; not run in this branch (no node_modules in clone). Maintainers' CI will exercise them. Manually traced the prepare.ts mention path and confirmed:

  • wasMentioned flips true when <!subteam^SXXX> is in text and SXXX is in the routed agent's allowlist.
  • Empty allowlist on agent shadows global (opt-out works).
  • Pre-routing seeding behavior unchanged for non-subteam paths.

Out of scope

API-driven subteam-membership expansion (option 2 in #73827). Happy to follow up with that as a separate PR if maintainers want it.

Changed files

  • extensions/slack/src/monitor/message-handler/prepare.ts (modified, +18/-6)
  • extensions/slack/src/monitor/message-handler/subteam-mentions.test.ts (added, +112/-0)
  • extensions/slack/src/monitor/message-handler/subteam-mentions.ts (added, +59/-0)
  • src/config/types.messages.ts (modified, +10/-0)

Code Example

<!subteam^S0B07LS458B> ping

---

const explicitlyMentioned = Boolean(
  ctx.botUserId && message.text?.includes(`<@${ctx.botUserId}>`),
);

---

{
  "agents": {
    "list": [
      {
        "id": "jack",
        "groupChat": { "subteamMentions": ["S0B07LS458B"] }
      },
      {
        "id": "amanda",
        "groupChat": { "subteamMentions": ["S0B07LS458B"] }
      }
    ]
  }
}

---

{ "messages": { "groupChat": { "subteamMentions": ["S0B07LS458B"] } } }
RAW_BUFFERClick to expand / collapse

Summary

Mentioning a Slack user-group (subteam) does not wake any of the OpenClaw agents that belong to it. The Slack adapter's mention preflight only recognizes direct <@UXXX> tokens against each bot's own user id; it has no awareness of <!subteam^SXXX> tokens at all. So a message like:

<!subteam^S0B07LS458B> ping

…in a channel where three agents are subscribed will route to one of them, evaluate wasMentioned=false, hit the room's requireMention gate, and silently drop. The agents are working as coded, but it's a real adapter gap as soon as anyone uses Slack user-groups to address a fleet of agents.

Repro

  1. Create a Slack user-group (e.g. via usergroups.create or the Slack UI) and add 2+ OpenClaw bot users as members.
  2. From any other Slack user, post <!subteam^SXXXXXX> hello in a channel where the agents have an active config.
  3. Expected: each subscribed agent treats it as an @-mention and is eligible to reply (subject to the usual policies).
  4. Actual: no agent replies. Verbose logs show wasMentioned=false for each candidate route.

Root cause

extensions/slack/src/monitor/message-handler/prepare.ts (compiled as dist/extensions/slack/prepare-*.js) computes:

const explicitlyMentioned = Boolean(
  ctx.botUserId && message.text?.includes(`<@${ctx.botUserId}>`),
);

…and feeds that into matchesMentionWithExplicit. There is zero handling of <!subteam^...> tokens anywhere in the Slack extension. Slack's bundled @slack/types references subteam only as a block-kit element type — never the inbound mention path.

Options considered

  1. Don't change behavior, document. Tell users to mention each <@UXXX> individually. Loses the operational value of subteams entirely.
  2. Full Slack-API expansion. Detect <!subteam^SXXX> tokens, call usergroups.users.list (cached, with subteam_updated / subteam_members_changed event invalidation), expand to user ids, match each against botUserId. Most "magical" — works without per-agent config — but requires a new Slack scope (usergroups:read), an API cache, and event subscription wiring.
  3. Config-only allowlist (this PR). Add groupChat.subteamMentions: string[] (resolved per-agent, falling back to global). When a <!subteam^SXXX> token appears in the message and SXXX is in the agent's list, treat it as an explicit mention. No new scopes, no cache, no event subscriptions. Each agent self-declares which subteams should wake it.

I went with option 3 first because:

  • ships value immediately for the common case ("I built a group with these 3 agents in it, mention them as a group")
  • no new Slack OAuth scopes
  • no API churn or eventual-consistency surface
  • composes cleanly with option 2 later if there's appetite (the resolver in option 3 just becomes a fast path / fallback when the API isn't available)

Option 2 stays on the table; happy to follow up with it.

Proposed change (PR attached)

PR: see linked PR.

  • New field: GroupChatConfig.subteamMentions?: string[] (already inherited by both cfg.messages.groupChat and per-agent agents.list[].groupChat).
  • New helper module extensions/slack/src/monitor/message-handler/subteam-mentions.ts with:
    • extractSlackSubteamMentionIds(text) — pulls all <!subteam^SXXX> ids out of a message, uppercased and deduped.
    • matchesConfiguredSubteamMention(ids, cfg, agentId) — resolves the configured allowlist (agent override beats global, presence-as-override mirrors mentionPatterns semantics) and tests for intersection.
  • prepare.ts now computes isExplicitlyMentionedForAgent(agentId) and feeds it into matchesMentionWithExplicit after routing has chosen the agent. Pre-routing seeding is unchanged (still bot-id only); the post-routing re-route on wasMentioned && !seedTopLevelRoomThreadBySource already handles thread re-seed when the subteam path is what triggered the wake.
  • Unit tests cover token extraction, agent override semantics, and case-insensitivity.

Configuration example

{
  "agents": {
    "list": [
      {
        "id": "jack",
        "groupChat": { "subteamMentions": ["S0B07LS458B"] }
      },
      {
        "id": "amanda",
        "groupChat": { "subteamMentions": ["S0B07LS458B"] }
      }
    ]
  }
}

…or globally:

{ "messages": { "groupChat": { "subteamMentions": ["S0B07LS458B"] } } }

Notes / caveats

  • groupChat.subteamMentions is resolved with presence-as-override semantics (an explicit empty list on an agent opts that agent out, even when a global list is set). This matches the existing mentionPatterns resolution behavior.
  • IDs are normalized to uppercase before comparison so s0b07ls458b and S0B07LS458B match.
  • No new permissions or scopes required.
  • Test file: extensions/slack/src/monitor/message-handler/subteam-mentions.test.ts.

Acceptance

  • <!subteam^SXXX> matching its agent's allowlist produces wasMentioned=true and clears requireMention gates.
  • Subteams not in the allowlist behave as today (silent).
  • Per-agent allowlist shadows the global list.
  • No new Slack OAuth scopes.
  • Unit tests cover the helper.

Reported / debugged by: <@U03Q05S3QAY> Davin Casely (#cg-intelligence-agents, 2026-04-28).

extent analysis

TL;DR

To fix the issue where mentioning a Slack user-group does not wake OpenClaw agents, add a subteamMentions configuration field to allow agents to recognize and respond to subteam mentions.

Guidance

  • Add a subteamMentions field to the agent's groupChat configuration, listing the subteam IDs that should wake the agent.
  • Use the extractSlackSubteamMentionIds function to pull subteam IDs from incoming messages and the matchesConfiguredSubteamMention function to check if the message mentions a configured subteam.
  • Update the prepare.ts file to compute isExplicitlyMentionedForAgent and feed it into matchesMentionWithExplicit to handle subteam mentions.
  • Test the configuration by sending a message with a subteam mention and verifying that the agent responds.

Example

{
  "agents": {
    "list": [
      {
        "id": "jack",
        "groupChat": { "subteamMentions": ["S0B07LS458B"] }
      }
    ]
  }
}

Notes

  • The subteamMentions field is resolved with presence-as-override semantics, allowing agents to opt out of subteam mentions even if a global list is set.
  • IDs are normalized to uppercase before comparison for case-insensitive matching.

Recommendation

Apply the proposed configuration-only allowlist workaround by adding the subteamMentions field to the agent's configuration, as it provides an immediate solution without requiring new Slack OAuth scopes or API churn.

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