mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-07-29 10:43:34 +00:00
Introduce a /stop API handler (api/stop.py) and its DOX to cancel an AgentContext run without deleting the context; it clears pause state, progress and logs an info step. Add tests for stopping behavior, chat working animation, and sidebar timestamp/spacing (tests/*). Update helpers/git._format_git_timestamp to emit UTC timestamps without a timezone suffix and add a test for it. Implement stop-related UI/UX: input-store.js gains a stop state, activateSendButton(), and stopAgent() to call /stop; chat-bar-input.html updates the send button markup, aria-label and stop styles. Update sidebar/chat list CSS to add the working-bubble animation, adjust chat row layout and action-button visibility, and left-sidebar/bottom styling (nowrap timestamp). Modify messages.js to hide kvps.finished from display and complete the active process group when finished. Minor welcome-composer and documentation updates to reflect these behaviors.
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
from agent import AgentContext
|
|
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 isinstance(ctxid, str) or not ctxid.strip():
|
|
return Response(
|
|
'{"error": "context is required"}',
|
|
status=400,
|
|
mimetype="application/json",
|
|
)
|
|
|
|
context = AgentContext.use(ctxid.strip())
|
|
if not context:
|
|
return Response(
|
|
'{"error": "Chat context not found"}',
|
|
status=404,
|
|
mimetype="application/json",
|
|
)
|
|
was_running = context.is_running()
|
|
|
|
context.kill_process()
|
|
context.paused = False
|
|
context.log.set_progress("", active=False)
|
|
|
|
msg = "Agent process stopped."
|
|
context.log.log(type="info", content=msg, finished=True)
|
|
|
|
return {
|
|
"message": msg,
|
|
"context": context.id,
|
|
"stopped": was_running,
|
|
}
|