Skip to main content
POST
/
sessions
/
{session_id}
/
interrupt
Interrupt a running or HITL-parked chat run for a session
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

x-user-id
string
required

Caller's user ID. Temporary header-based identity; will be replaced by JWT auth.

Path Parameters

session_id
string
required

Query Parameters

agent_id
string
required

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.CancelDispatcher cancels the chat-run task; the agent then runs its CancelledError cleanup path.
  • If the session is parked on HITL / external execution, a resume trigger carrying a :class:~agentscope.event.UserInterruptEvent is enqueued so the agent short-circuits into the same cleanup path.
  • If the session is idle, the call is a no-op.
session_id
string
required

Echo of the interrupted session id.