-
Notifications
You must be signed in to change notification settings - Fork 419
Open
Labels
auto-triage-skipPrevent this issue from being closed due to lack of activityPrevent this issue from being closed due to lack of activityenhancementM-T: A feature request for new functionalityM-T: A feature request for new functionalityserver-side-issue
Description
Summary
Add API support for canceling in-flight streaming messages, enabling Slack bots to stop AI agents upon user request. Currently, once a stream starts, there's no way for users to interrupt it.
Use Case
When an AI agent is processing a long-running task and streaming results:
- User realizes they asked the wrong question
- User wants to stop the agent to save costs/time
- User clicks a "Stop" button in Slack
- Bot should be able to cancel the stream and stop the underlying agent
Current limitation: No API exists to cancel a stream after chatStream() is called. Calling stream.stop() only finalizes the stream - it doesn't interrupt it.
Proposed API
Accept cancellation signal via action
// Bot receives button click event
app.action("stop_agent", async ({ ack, body }) => {
await ack();
// Cancel the stream associated with this thread
await client.chatStream.cancel({
channel: body.channel.id,
thread_ts: body.message.thread_ts,
message: "Stopped by user request"
});
});Expected Behavior
When a stream is cancelled:
- Slack immediately shows a "Cancelled" indicator on the message
- Optional cancellation message appears (e.g., "Stopped by user")
- Bot receives confirmation that stream was cancelled
- Bot can clean up resources (kill agent process, etc.)
Current Workaround
Currently, bots must:
- Track stream state externally
- Kill the agent process manually
- Call
stream.stop()which finalizes (not cancels) the stream - Post a new message saying "Cancelled"
This creates a poor UX because the stream still shows as "completed" rather than "cancelled".
Environment
@slack/bolt: 4.5.0@slack/web-api: 7.11.0- Platform: Slack Desktop App (macOS) / Slack Web
Related APIs
Similar cancellation patterns exist in:
AbortControllerin web standardsCancellationTokenin other async frameworks
Metadata
Metadata
Assignees
Labels
auto-triage-skipPrevent this issue from being closed due to lack of activityPrevent this issue from being closed due to lack of activityenhancementM-T: A feature request for new functionalityM-T: A feature request for new functionalityserver-side-issue