feat(slack): add multiparty-mentions user-message gating mode - #1319
feat(slack): add multiparty-mentions user-message gating mode#1319HSTsou wants to merge 2 commits into
Conversation
New `allow_user_messages = "multiparty-mentions"`: behaves like `involved` while a thread is a 1:1 conversation (single human + this bot) — the bot follows the whole thread without @mention. Once a second distinct human or another bot posts in the thread, it falls back to `mentions`. Slack implementation: - Eager multi-human detection from message events (thread_first_human / multihuman_threads caches, mirroring eager multibot detection), so live traffic needs no extra API calls. - bot_participated_in_thread now also derives multi-human from the fetched thread history (covers threads predating the process) and returns (involved, other_bot_present, multi_human). Discord/Feishu: multi-human detection not implemented yet — the mode behaves like multibot-mentions there (documented on the enum and in config docs). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important CHANGES REQUESTED What This PR DoesAdds How It WorksEager per-event detection ( Findings
Finding Details🟡 F1:
|
incorrect link. Setting closing-soon if not fixed. |
Mob code review — PR #1319
|
…he, tests, docs - F1: app_mention events now feed note_human_in_thread (a second human joining via @bot was previously invisible to multiparty-mentions). - F2: thread_first_human uses the same two-stage eviction as enforce_cache_bounds (TTL retain, then oldest-half drop) so the map stays bounded even when all entries are fresh. - F6: fast path — already-promoted multi-human threads return after a single cache check, skipping first-human bookkeeping. - F7: documented why eager detection runs unconditionally for all modes. - F8: documented the in-memory-only design and ~200-message history recovery window on the cache field. - F3: 4 unit tests (idempotency, promotion, fast path, bounded eviction). - F4/F5/F9: irreversibility note in config-reference; multiparty-mentions added to messaging/discord/feishu docs with Slack-only fallback note; chart values comment clarifies cross-platform behavior. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Thanks for the thorough review @chaodu-agent — all findings addressed in 1b5e40c:
On the "three reasons we might not need this": fair challenges. Our production data point — two bots in shared team channels where humans regularly discuss inside bot threads — is exactly the case 🤖 Addressed by Claude Code |
What problem does this solve?
Teams running a Slack bot face a gating dilemma in threads:
involved: great for 1:1 threads (conversation flows without re-@mentioning), but once other humans join the thread, the bot follows every message — side discussions between humans trigger the bot and burn tokens on messages not addressed to it.mentions: safe in busy threads, but tedious in 1:1 — every follow-up needs an @mention.multibot-mentionssolves this adaptively for multiple bots, but not for multiple humans.We hit this in production: users complained the bot replied to human-to-human side chatter in shared threads, but switching to
mentionsmade 1:1 debugging sessions painful.Discord Discussion URL: https://discord.com/channels/1491295327620169908/1523968250604556399
At a Glance
Prior Art & Industry Research
OpenClaw: group reply triggering is controlled by static mention gating —
requireMentionper group, with implicit mentions (reply/quote) andmentionPatterns. It's a per-group static switch: there is no mode that adapts within a thread based on how many humans are participating.Hermes Agent: Telegram groups are mention-gated, with an "observed context" mode where unmentioned group messages are appended to the session transcript as context but only an @mention triggers a response. Again — no participant-count-adaptive gating.
Other references: openab's own
multibot-mentions(this PR generalizes its "adaptive fallback" idea from bots to humans).Proposed Solution
New
allow_user_messages = "multiparty-mentions":involved— follows the thread without @mentionmentionsmentions(same asmultibot-mentions)Slack implementation mirrors the existing eager multibot machinery:
thread_first_humanrecords the first human sender per thread; a second distinct sender marks the thread in the positive-onlymultihuman_threadscache — zero extra API calls on the hot path.bot_participated_in_threadalso derives multi-human from the fetchedconversations.replieswindow (covers thread history predating the process) and now returns(involved, other_bot_present, multi_human).enforce_cache_boundsTTL policy.Discord/Feishu: multi-human detection not implemented yet — the mode behaves like
multibot-mentionsthere (documented on the enum, indocs/config-reference.md, and chart values). Happy to follow up with Discord parity if there's interest.Why this approach?
requireMention-style switch (OpenClaw's approach) can't distinguish a 1:1 debugging thread from a busy group thread in the same channel. Participant-count gating adapts per thread with no operator intervention.multibot-mentionsalready works; this stays consistent with the codebase's existing mental model.Alternatives Considered
requireMention: false): rejected — doesn't adapt within a thread; operators would need per-thread toggles.bot_participated_in_thread): rejected — the cached-involved early-return path skips the fetch, so a second human joining mid-conversation would go unnoticed. Eager per-event detection closes that gap.Validation
cargo test -p openab-core --lib: 617 passed, 0 failed — includes 2 newshould_process_user_messagetests for the new mode and a config deserialization test covering bothmultiparty-mentions/multiparty_mentionsspellings.cargo check -p openab-core -p openab-gatewayclean.discord.rs,feishu.rs(gateway has its ownAllowUsersenum).config.toml.example,charts/openab/values.yaml,docs/config-reference.md.🤖 Generated with Claude Code