feat: add Stop button to halt agent without destroying context#1420
Open
abhinav-bhateja wants to merge 2 commits intoagent0ai:mainfrom
Open
feat: add Stop button to halt agent without destroying context#1420abhinav-bhateja wants to merge 2 commits intoagent0ai:mainfrom
abhinav-bhateja wants to merge 2 commits intoagent0ai:mainfrom
Conversation
Closes agent0ai#1099, agent0ai#1208 Adds a proper stop mechanism between pause (too weak) and terminate (too destructive): Backend: - AgentContext.stop() in agent.py: kills process, clears pause/streaming state, preserves history - api/stop.py: new auto-discovered API endpoint Frontend: - Stop button in bottom actions bar (red-tinted, only visible when agent is running) - stopAgent() method in input-store.js - Escape key shortcut in index.js (skips when typing in input/textarea) - globalThis.stopAgent for external access
- TestAgentContextStop: 9 unit tests for the stop() method - clears paused state, streaming agent, calls kill_process - logs info message, preserves conversation history - safe when not running, differs from nudge/reset behavior - TestStopApiHandler: 3 tests for the /stop API endpoint - returns success, raises without context id, actually stops agent
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
Adds a Stop button that immediately halts a running agent while preserving conversation history. This fills the gap between Pause (too weak — just spins in a sleep loop) and Terminate (too destructive — nukes the entire context).
Closes #1099, Closes #1208
What changed
Backend
agent.py— Newstop()method onAgentContext: callskill_process(), clears pause state, resetsstreaming_agent, and logs an info message. History is fully preserved.api/stop.py— New API handler, auto-discovered by the framework. Accepts a context ID and callscontext.stop().Frontend
input-store.js— NewstopAgent()method that POSTs to/stop.bottom-actions-bar.html— Red-tinted Stop button between Pause and Nudge, only visible when the agent is running (x-show="$store.chats?.selectedContext?.running").index.js—globalThis.stopAgent+ Escape key listener that triggers stop only when the agent is running and the user is not focused on a textarea/input.How it works
Testing