feat(slack): follow all replies in threads Cyrus is bound to (CYPACK-1267)#1273
Open
cyrusagent wants to merge 2 commits into
Open
feat(slack): follow all replies in threads Cyrus is bound to (CYPACK-1267)#1273cyrusagent wants to merge 2 commits into
cyrusagent wants to merge 2 commits into
Conversation
After an initial @mention binds a Slack thread, plain follow-up messages in that thread are now fed into the same agent session — no re-mention needed. - SlackEventTransport accepts "message" events, drops bot/own messages, subtype events, and non-threaded messages, and de-dupes the app_mention + message double-delivery on (channel, ts). - ChatPlatformAdapter gains optional isSessionInitiatingEvent; ChatSessionHandler refuses to start a new session from a non-initiating event, so a plain reply only continues an already-bound thread. - SlackChatAdapter marks app_mention as initiating, message as follow-up. - Slack setup manifest subscribes to message.channels/groups/mpim/im. CYPACK-1267
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.
Summary
Makes Cyrus feel "present" in a Slack thread it's been pulled into. After an initial
@mentionbinds a thread, every subsequent reply in that thread is fed into the same agent session — no need to re-mention Cyrus each time. (CYPACK-1267)This is the cyrus (runtime) half of the change; the cyrus-hosted half (webhook forwarding gate + Slack manifest) is in a paired PR.
What changed
SlackEventTransportnow acceptsmessageevents (not justapp_mention). It applies cheap, conservative structural filters before doing any work:bot_id) — prevents reply loopsbot_message, …)app_mentionand amessageevent; we collapse identical(channel, ts)pairs (10-min TTL) so the thread is prompted once.ChatPlatformAdaptergains an optionalisSessionInitiatingEvent(event).ChatSessionHandlerrefuses to start a new session from a non-initiating event, so a plain reply only ever continues an already-bound thread — it never spins one up. (Defaults to "initiating" when the adapter omits the method, so Linear/GitHub behaviour is unchanged.)SlackChatAdaptermarksapp_mentionas session-initiating andmessageas follow-up;SlackMessageTranslatornow mapsmessage→ user prompt.cyrus-setup-slack) subscribes tomessage.channels/message.groups/message.mpim/message.im(the*:historyscopes were already present).Design notes (SOLID)
isSessionInitiatingEvent); the handler owns session lifecycle.true, so existing adapters (and the test adapter) need no change.Testing
pnpm test:packages:run— all green (slack-event-transport 70, edge-worker 673, etc.). New tests cover: threaded message emitted, non-threaded/bot/subtype dropped, app_mention+message dedup, and the session-initiation gate.pnpm typecheckandpnpm lintclean.Operational note
Existing Slack apps must add the four
message.*bot events in Event Subscriptions for follow-ups to be delivered.