feat(slack): append triggering message to thread context body#1230
feat(slack): append triggering message to thread context body#1230jkahuja wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
1 issue found across 2 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
When a thread reply spawns a task, the agent receives the full thread history but has no indicator of which message triggered this specific task. This can cause the agent to act on earlier messages instead of the one that spawned it. Append a short instruction at the end of the thread context body telling the agent to respond to the last user message. This uses the highest-attention position (end of prompt) without duplicating text. Co-Authored-By: Claude Opus 4.6 <[email protected]>
acc182d to
7b317bb
Compare
| "channel", innerEvent.Channel, "threadTS", innerEvent.ThreadTimeStamp) | ||
| } else { | ||
| msg.Body = body | ||
| msg.Body = body + "\n---\nThe last user message in this thread is what triggered this task. Respond to it specifically. Prior messages and agent responses are context.\n" |
There was a problem hiding this comment.
I think you can add this instruction to the task's prompt.
not sure about adding a specific instruction to msg.Body is right thing to do.
There was a problem hiding this comment.
@gjkim42 yeah that did read more like a prompt. My thought here is we could update our own slack agent prompts to let it know what the triggering message is, but then everyone using the slack integration would have to do that. I'm trying something different here now -- the last message in the thread is marked as being the "triggering message". The entire slack thread is passed as the body but marking one as "triggering message" would help the agent know which one to pay attention to.
…trigger Replace the natural-language instruction appended to thread context body with a [TRIGGERING MESSAGE] prefix on the last message. This keeps prompt engineering in the spawner's promptTemplate where it belongs, while still making it unambiguous which message spawned the task. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…full pre-pass Walk backward from the end to find the last non-empty message instead of calling formatAttachments() on every message in a forward pre-pass. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Summary
When a thread reply spawns a task, the agent receives the full thread history in
{{.Body}}but has no indicator of which message triggered this specific task. This can cause the agent to act on earlier messages in the thread instead of the triggering one.This appends a short instruction at the end of the thread context body telling the agent to respond to the last user message:
handleMessageEvent— no spawner YAML updates neededTest plan
spec.promptcontains the trailing instruction🤖 Generated with Claude Code