nextlevelbuilder / nextlevelbuilder/goclaw

Slack: require_mention is bypassed for every reply in a thread whose root message mentions the bot

Open
#1,502 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

agent:github-maintain area:channels bug maintain:bug-confirmed maintain:triaged P2-medium
Dominant language
Go
Stars
3.6k
Forks
1.1k
Avg merge
3d 5h
Merged PRs (30d)
24

Description

Bug

With a Slack channel configured as require_mention: true and thread_ttl: 0 ("always require @mention"), the bot still auto-replies to every reply in a thread whose root message @mentions the bot — including human-to-human messages that never mention it.

Root cause

In internal/channels/slack/handlers.go (handleMessage), the order of operations is:

  1. For thread replies, fetchThreadParentContext fetches the thread root and prepends its raw text — mention tags included — to content:
    content = replyCtx + "\n\n" + content
  2. The mention gate then runs on the combined string:
    mentioned := c.isBotMentioned(content)

Since isBotMentioned is a plain strings.Contains(text, "<@"+botUserID+">"), the parent's mention tag inside the quoted [Replying to …] block satisfies the gate for every reply in that thread, forever — regardless of require_mention and thread_ttl.

Reproduction

  1. Slack channel instance with require_mention: true, thread_ttl: 0.
  2. User A posts a channel message mentioning the bot: @bot @UserB please help with X (starts a thread).
  3. User B replies in the thread without mentioning the bot: @UserA do you have more info?

Expected: the bot stays silent (no mention in the reply, thread auto-reply disabled).
Actual: the bot replies. Confirmed in production logs: the reply event reaches the agent (inbound: scheduling message) with no mention in its text.

Fix

Evaluate the mention gate on the event's own text (ev.Text) before any context injection. PR incoming that extracts the gate into a shouldRespondInGroup(eventText, channelID, threadTS) helper (thread-participation TTL behavior preserved) with table tests pinning the regression.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in internal/channels/slack/handlers.go at handleMessage, then trace fetchThreadParentContext and the mention-gate logic. Run or add the table tests for the shouldRespondInGroup behavior; done means an unmentioned reply stays silent when require_mention is true and thread_ttl is 0, while thread-participation TTL behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.