feat(slack): tell trigger agent to always reply in the user's thread#440
Merged
Conversation
Even with thread_messages and user_name in the payload, the trigger subscriber had no explicit signal saying which thread_ts to use when replying — and for a fresh top-level DM event.thread_ts is undefined, so the agent could not derive it from the event alone. Bake the contract into the payload and the trigger definition: - Add `reply_in_thread_ts = event.thread_ts ?? event.ts` so the agent always has a concrete thread_ts to pass to SLACK_REPLY_IN_THREAD. For thread continuations this is the existing thread; for top-level messages this is the message's own ts, which kicks off a new thread the moment the bot replies. The agent NEVER has to decide start-vs-continue. - Add `reply_instruction`: a one-line natural-language directive that spells out the tool call (channel + thread_ts pair) the agent should use, so prompt-driven subscribers see the contract inline. - Update the trigger DEFINITIONS in trigger-store.ts so studio (and any agent reading the schema) sees the contract as part of the trigger description, not just inside the payload. Co-Authored-By: Claude Opus 4.7 <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.
Summary
Follow-up to #439. Even with
thread_messagesanduser_namein the trigger payload, the subscriber had no explicit signal saying whichthread_tsto use when replying — and for a fresh top-level DMevent.thread_tsisundefined, so the agent could not derive it from the event alone.Bake the reply contract into both the payload and the trigger definition:
reply_in_thread_ts = event.thread_ts ?? event.tsis now computed by the publisher. For thread continuations it's the existing thread; for top-level messages it's the message's own ts, which kicks off a new thread the moment the bot replies. The agent never has to decide start-vs-continue.reply_instruction: a one-line natural-language directive spelling out the exactSLACK_REPLY_IN_THREAD(channel, thread_ts)tool call, so prompt-driven subscribers see the contract inline.trigger-store.tsnow embed the contract in the description that studio (and any agent reading the schema) sees: "To respond, ALWAYS call SLACK_REPLY_IN_THREAD with channel=channel_id and thread_ts=reply_in_thread_ts so every answer lives inside the user's thread."Test plan
triggerOnlymode, send a top-level DM →reply_in_thread_tsin the payload equalsevent.ts.reply_in_thread_tsequals the thread'sthread_ts.SLACK_REPLY_IN_THREAD(channel_id, reply_in_thread_ts, ...)and the reply appears in the right thread.Summary by cubic
Make Slack agents always reply in the user’s thread. Adds
reply_in_thread_tsand areply_instructionto trigger payloads and documents the contract in trigger descriptions.reply_in_thread_ts = event.thread_ts ?? event.tsforslack.message.receivedandslack.app_mention, so agents never decide start vs continue.reply_instructionthat spells the exactSLACK_REPLY_IN_THREAD(channel_id, reply_in_thread_ts)call.Written for commit 78bd494. Summary will update on new commits.