mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-23 21:06:39 +00:00
Closes #1099, #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
14 lines
444 B
Python
14 lines
444 B
Python
from helpers.api import ApiHandler, Request, Response
|
|
|
|
|
|
class Stop(ApiHandler):
|
|
async def process(self, input: dict, request: Request) -> dict | Response:
|
|
ctxid = input.get("context", "")
|
|
if not ctxid:
|
|
raise Exception("No context id provided")
|
|
context = self.use_context(ctxid)
|
|
context.stop()
|
|
return {
|
|
"message": "Agent stopped.",
|
|
"context": context.id,
|
|
}
|