slackapi / slackapi/bolt-js

Feature Request: Allow users to stop/cancel streaming messages

Open
#2,698 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triage-skip enhancement server-side-issue
Dominant language
TypeScript
Stars
2.9k
Forks
445
Avg merge
1d 3h
Merged PRs (30d)
28

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:

  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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the chatStream API and the existing stream.stop() behavior in the bolt-js codebase. Trace how streaming state is tracked and how Slack messages are finalized. Done means an in-flight stream can be cancelled through the proposed API, the cancellation state and optional message are reflected in Slack, and the bot receives confirmation for cleanup.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.