Repository navigation
feat: stop in-progress runs with the native stop button - #347
Merged
Merged
Conversation
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
cchensh
approved these changes
Dec 3, 2026
cchensh
left a comment
Contributor
There was a problem hiding this comment.
Approving. All three subprojects match bolt-python-personal-agent#22:
- claude-agent-sdk uses an
asyncio.Eventplus an interrupt task, cancelled infinally. - openai-agents-sdk uses a
threading.EventthatStopHookschecks. An exception raised inon_tool_startescapes the run rather than reaching the model as a tool error. - pydantic-ai uses a
CancellationToken, andRunCancelledis caught as anException.
Cleanup runs in finally, stopBefore scopes a stop to older runs, and a stopped run is never reported as an error. The tests pass (27/26/25), and the pydantic-ai test cancels for real through TestModel.
Nits (the first two are the same in the personal-agent twin):
listeners/events/agent_session_stopped.py:7-13(each subproject) posts "Stopped." even when nothing was in flight, so a stop clicked as the reply finishes leaves the answer followed by "Stopped.".- openai-agents-sdk (
agent/support_agent.py:123-127) only checks for a stop before the next model or tool call, so an in-flight model request still completes and is billed. The README says so accurately. - Runs are keyed by channel and thread, while support sessions are per user, so one person's stop cancels another's run in a shared thread. That's probably intended; a README sentence would say so.
- A stopped first mention stores no session, so un-mentioned follow-ups in that channel thread are ignored (for example
claude-agent-sdk/listeners/events/message.py:43-46) until the agent is mentioned again.
Co-authored-by: Cheng Chen <35309699+cchensh@users.noreply.github.com> Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Member
Author
|
🙏 Thanks @cchensh! Taken in order:
|
Member
Author
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 three support agents, following
agent_session_stopped.manifest.jsonsubscribes toagent_session_stopped.app_mentioned.pyandmessage.pyset the session toprocessingwithagents_sessions_setStatusin place of Bolt'sset_status, which callsassistant.threads.setStatus. Slack shows the stop button only for a session set toprocessingthis way, not through theassistant.threads.setStatuscompatibility bridge. The loader reads "Working..." now, sinceagents.sessions.setStatusdoesn't take custom loading messages. After an error warning, the listeners set the session back toactive, since a message no longer clears the status.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. Issue submissions from the App Home modal take the same path, so they stop the same way.claude-agent-sdk: anasyncio.Eventper run. A task waits on it and callsClaudeSDKClient.interrupt().openai-agents-sdk: athreading.Eventper run, checked byRunHooksbefore each model and tool call, since the app is sync.pydantic-ai: aCancellationTokenper run, passed torun_sync().activereset after an error, and that each framework receives the stop.The coding agents' stop handling is the reference, in the shape the starter and personal agents use (bolt-python-starter-agent#317, bolt-python-personal-agent#22). The coding agents also clear pending Approve / Deny buttons on a stop, but the support agents have no approvals, so that part is left out.
Testing
slack runin a workspace with agent sessions.🤖 Generated with Claude Code