Repository navigation
Conversation
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request adds support for the native stop button to all four starter agents, following
agent_session_stopped.manifest.jsonsubscribes toagent_session_stopped. The starters already set the session toprocessingwithset_status, so Slack now shows a stop button in place of a loader the user can't interact with.agent_session_stopped.pylistener stops the thread's in-flight runs, moves the session back toactivewithagents_sessions_setStatus, then posts "Stopped." in the thread. Slack doesn't change the status on a stop, so the app has to.app_mentioned.pyandmessage.pyregister each run before setting the status. A run that was stopped posts nothing more: no reply, and no ":warning: Something went wrong" for the stop.claude-agent-sdk(async): anasyncio.Eventper run. When the stop button sets it,ClaudeSDKClient.interrupt()is called.openai-agents-sdk(sync, so listeners run on worker threads): athreading.Eventper run.StopHooksinagent/agent.pychecks it inon_llm_startandon_tool_start, so the run ends before its next model or tool call.pydantic-ai(sync): aCancellationTokenper run, passed torun_sync. The token is thread-safe and also cancels a model call that's already under way.vercel-ai-sdk: on Vercel, the stop event arrives in a different function invocation than the run it stops, so in-memory state can't reach the run. The stop is recorded in Runtime Cache (thread_context/stops.py) with itsevent_ts. The run checks it at eachStreamStartand ends before the next step. It also checks before posting. A run counts as stopped only when the stop is newer than its message, so later messages start fresh. A model call that's already under way finishes before the run stops, along with any tools it calls, Slack MCP tools included. A cache that can't be read counts as not stopped, so a run's own reply or error still posts.The coding agents' stop handling is the reference. They also clear pending Approve / Deny buttons on a stop, but the starters have no approvals, so that part is left out.
Testing
slack run(andvercel-ai-sdkdeployed to Vercel) in a workspace with agent sessions.🤖 Generated with Claude Code