feat(slack-agent): gate thread follow-ups behind a relevance classifier - #557
Open
JeremyFunk wants to merge 1 commit into
Open
feat(slack-agent): gate thread follow-ups behind a relevance classifier#557JeremyFunk wants to merge 1 commit into
JeremyFunk wants to merge 1 commit into
Conversation
Thread follow-up promotion only checked engagement — is the bot part of this thread — so once it was, every human reply there dispatched a full agent turn, including people talking to each other. A confirmed follow-up now also passes a semantic gate: one small RESPOND/PASS classifier call asking whether the reply is actually directed at the bot. A PASS drops the turn silently, before the 👀 ack and typing indicator, and the bot stays engaged for the next message that is for it. Real @mentions and DMs skip the gate — an explicit address answers the question itself. The gate fails open (classifier error, timeout, or unparseable verdict all answer the follow-up), same asymmetry as the engagement check: a wrong drop loses a user's message invisibly, a wrong answer costs one turn. Model is configurable via OPENROUTER_GATE_MODEL, following OPENROUTER_MODEL when unset. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Thread follow-up promotion (
agent/lib/thread-follow-up.ts) only answers a mechanical question — is the bot part of this thread. Once it is, every human reply in the thread dispatched a full agent turn: in an incident thread where two engineers are talking to each other, the bot answered each of their messages. Cost amplifier, and a bot that butts into conversations never addressed to it.Change
A confirmed follow-up now also passes a semantic gate (
agent/lib/follow-up-relevance.ts): one classifier call — recent thread tail + the new reply in, a singleRESPOND/PASSword out — asking whether the reply is actually directed at the bot or expects it to act. Orders of magnitude cheaper than the agent turn it gates.@mentionsand DMs skip the gate. An explicit address answers the question itself.:eyes:ack and typing indicator, so a message the bot stays out of gets no reaction at all, and drops via the same throw-to-un-dispatch escape hatch as the disengagement drop. The bot stays engaged — the next reply that is for it gets answered. The only trace is a structuredfollow_up_not_relevantlog (ids only, never message text).confirmThreadFollowUp: classifier error, timeout (10s), or an unparseable verdict all answer the follow-up. A wrong drop loses a user's message with nothing on screen to explain it; a wrong answer costs one turn. The prompt's tiebreak leans the same way.OPENROUTER_GATE_MODEL) since the job wants a small, fast model; unset, it followsOPENROUTER_MODELrather than silently using a third one.Runs on the dispatch path (post-200, inside eve's
waitUntil), so it spends nothing from Slack's ~3s webhook budget.Trade-off
Every un-mentioned reply in an engaged thread now costs one tiny classifier call. That is the mechanism working; set
OPENROUTER_GATE_MODELto something small to make it cheaper.Testing
bun testinapps/slack-agent: 281 pass (12 new — verdict parsing, prompt contents, fail-open on error/unparseable, deps-injected classifier)tscclean🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.