bolt-js icon indicating copy to clipboard operation
bolt-js copied to clipboard

Feature Request: Allow users to stop/cancel streaming messages

Open buremba opened this issue 2 months ago • 3 comments

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:

  1. User realizes they asked the wrong question
  2. User wants to stop the agent to save costs/time
  3. User clicks a "Stop" button in Slack
  4. 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:

  1. Slack immediately shows a "Cancelled" indicator on the message
  2. Optional cancellation message appears (e.g., "Stopped by user")
  3. Bot receives confirmation that stream was cancelled
  4. Bot can clean up resources (kill agent process, etc.)

Current Workaround

Currently, bots must:

  1. Track stream state externally
  2. Kill the agent process manually
  3. Call stream.stop() which finalizes (not cancels) the stream
  4. 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:

  • AbortController in web standards
  • CancellationToken in other async frameworks

buremba avatar Oct 23 '25 17:10 buremba

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

github-actions[bot] avatar Nov 24 '25 00:11 github-actions[bot]

As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.

github-actions[bot] avatar Dec 08 '25 00:12 github-actions[bot]

Hi there,

We don't yet have a timeline on these enhancements but we wanted to let you know that they are on the team's radar!

vegeris avatar Dec 09 '25 19:12 vegeris