Interrupt a running or HITL-parked chat run for a session
Request interruption of an in-progress reply for a session.
Thin HTTP wrapper around :meth:ChatService.interrupt; see that
method for the running vs not-running dispatch. Idempotent — an
idle target session is a silent no-op at the agent layer.
Args: session_id: The session whose reply should be interrupted. agent_id: The agent that owns the session. user_id: Injected authenticated user id. chat_service: Injected chat service.
Returns:
202 with :class:InterruptSessionResponse echoing the
session id.
Raises: HTTPException: 404 if the session does not exist.
Headers
Caller's user ID. Temporary header-based identity; will be replaced by JWT auth.
Path Parameters
Query Parameters
Agent the session belongs to.
Response
Successful Response
Response body for POST /sessions/{sid}/interrupt (HTTP 202).
The interrupt operation is idempotent and always succeeds for an
existing session (only 404 is raised when the session id does
not exist):
- If the session is running, an interrupt signal is published
so the local
:class:
~agentscope.app._manager.CancelDispatchercancels the chat-run task; the agent then runs itsCancelledErrorcleanup path. - If the session is parked on HITL / external execution, a
resume trigger carrying a
:class:
~agentscope.event.UserInterruptEventis enqueued so the agent short-circuits into the same cleanup path. - If the session is idle, the call is a no-op.
Echo of the interrupted session id.