agent-zero/api/stop.py.dox.md
frdel 2ec52e1968 Add /stop API and stop-button UI/behavior
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.
2026-07-28 09:26:06 +02:00

1.2 KiB

stop.py DOX

Purpose

  • Own the authenticated WebUI endpoint that stops an active agent run without deleting or resetting its chat context.

Ownership

  • stop.py resolves the requested in-memory context and cancels its current process.

Runtime Contracts

  • Stop derives from ApiHandler, retaining the default authentication and CSRF protections.
  • Input uses the selected chat ID in context; the endpoint never creates a missing context.
  • Stopping cancels the context task through AgentContext.kill_process(), clears pause state, preserves chat history and queued messages, and does not start another run.
  • The endpoint clears active progress and logs a terminal Agent process stopped. info step so the WebUI closes the interrupted process group.
  • The response contains message, context, and a stopped boolean indicating whether the context was running when requested.

Work Guidance

  • Keep this endpoint aligned with the composer stop-button state and the existing AgentContext task lifecycle.

Verification

  • Run pytest tests/test_stop_agent.py and smoke-test stopping during model streaming and tool execution.

Child DOX Index

No child DOX files.