Skip to content

feat(slack): add Agent Sessions lifecycle and native stop - #862

Open
bensabic wants to merge 7 commits into
mainfrom
feat/slack-agents
Open

feat(slack): add Agent Sessions lifecycle and native stop#862
bensabic wants to merge 7 commits into
mainfrom
feat/slack-agents

Conversation

@bensabic

Copy link
Copy Markdown
Contributor

Migrates Slack's agent_view integration to the Agent Sessions lifecycle while preserving the legacy assistant_view compatibility path.

  • Adds agents.sessions.setStatus and agents.sessions.rename support for processing, active, suspended, and closed sessions.
  • Handles agent_session_stopped without taking the message lock, clears Slack's processing state, and dispatches onAgentSessionStopped.
  • Adds cross-process turn cancellation through the configured state adapter and exposes the active turn as thread.signal.
  • Handles agent_session_title_changed and automatically titles new agent conversations from their root message, with a configurable resolver.
  • Propagates session_status through native stream completion and supports suspended human-in-the-loop turns.
  • Updates Slack manifests, examples, API docs, fixtures, and migration guidance for the February 2027 assistant_view retirement.

Configure the Agent messaging experience and optional title resolver:

const slack = createSlackAdapter({
  agentView: true,
  sessionTitle: ({ text }) => text.split("\n", 1)[0]?.slice(0, 80) ?? null,
});

Pass the thread signal into model generation so Slack's native stop button cancels upstream work as well as message delivery:

bot.onDirectMessage(async (thread, message) => {
  await thread.startTyping();

  const result = await agent.stream({
    prompt: message.text,
    abortSignal: thread.signal,
  });

  await thread.post(result.fullStream);
});

React to session lifecycle events:

bot.onAgentSessionStopped(async (event) => {
  await releaseExternalResources(event.threadId);
});

bot.onAgentSessionTitleChanged(async (event) => {
  await syncTitle(event.threadId, event.title);
});

Leave a stream suspended when the agent needs user input or approval:

await thread.post(
  new StreamingPlan(result.fullStream, {
    sessionStatus: "suspended",
  })
);

- expose thread-scoped abort signals
- coordinate cancellation through shared state
- support final agent session stream states
- use Agent Sessions APIs under agent_view
- handle native stop and title-change events
- title new agent conversations automatically
- cover session lifecycle and assistant_view sunset
- document native stop and title events
- wire abort signals and manifest events in the example
- exclude generated .swc artifacts
@bensabic
bensabic requested a review from a team as a code owner August 25, 2026 10:11
@vercel

vercel Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat Ready Ready Preview, v0 Aug 26, 2026 3:20am
chat-sdk-nextjs-chat Ready Ready Preview, v0 Aug 26, 2026 3:20am

Comment thread packages/adapter-slack/src/index.ts
Comment thread packages/adapter-slack/src/index.ts Outdated
Comment thread packages/adapter-slack/src/index.ts Outdated
- match the current agent_session_stopped payload
- preserve every stopped streaming message timestamp
- remove the undocumented inner stop-event field
- keep workspace routing on the outer callback envelope
- accept title events without previous_title
- expose previousTitle as optional to handlers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants