curl --request POST \
--url https://api.example.com/sessions/{session_id}/interrupt \
--header 'x-user-id: <x-user-id>'import requests
url = "https://api.example.com/sessions/{session_id}/interrupt"
headers = {"x-user-id": "<x-user-id>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'x-user-id': '<x-user-id>'}};
fetch('https://api.example.com/sessions/{session_id}/interrupt', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/sessions/{session_id}/interrupt",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"x-user-id: <x-user-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/sessions/{session_id}/interrupt"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("x-user-id", "<x-user-id>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/sessions/{session_id}/interrupt")
.header("x-user-id", "<x-user-id>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/sessions/{session_id}/interrupt")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-user-id"] = '<x-user-id>'
response = http.request(request)
puts response.read_body{
"session_id": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}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.
curl --request POST \
--url https://api.example.com/sessions/{session_id}/interrupt \
--header 'x-user-id: <x-user-id>'import requests
url = "https://api.example.com/sessions/{session_id}/interrupt"
headers = {"x-user-id": "<x-user-id>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'x-user-id': '<x-user-id>'}};
fetch('https://api.example.com/sessions/{session_id}/interrupt', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/sessions/{session_id}/interrupt",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"x-user-id: <x-user-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/sessions/{session_id}/interrupt"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("x-user-id", "<x-user-id>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/sessions/{session_id}/interrupt")
.header("x-user-id", "<x-user-id>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/sessions/{session_id}/interrupt")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-user-id"] = '<x-user-id>'
response = http.request(request)
puts response.read_body{
"session_id": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}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.