import os
from qaip import Qaip
client = Qaip(
api_key=os.environ.get("QAIP_API_KEY"), # This is the default and can be omitted
)
agent_run = client.agent.cancel_run(
run_id="run_id",
)
print(agent_run.context_start_run_id)curl --request POST \
--url https://developer.qaip.com/api/v1/agent/runs/{run_id}/cancel \
--header 'x-api-key: <api-key>'const options = {method: 'POST', headers: {'x-api-key': '<api-key>'}};
fetch('https://developer.qaip.com/api/v1/agent/runs/{run_id}/cancel', 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://developer.qaip.com/api/v1/agent/runs/{run_id}/cancel",
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-api-key: <api-key>"
],
]);
$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://developer.qaip.com/api/v1/agent/runs/{run_id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://developer.qaip.com/api/v1/agent/runs/{run_id}/cancel")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://developer.qaip.com/api/v1/agent/runs/{run_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"run_id": "<string>",
"thread_id": "<string>",
"workflow_type": "<string>",
"provider": "ANTHROPIC_DIRECT",
"execution_mode": "LOCAL",
"status": "QUEUED",
"input_history_mode": "legacy_full",
"context_start_run_id": "<string>",
"context_truncated": true,
"runtime_arn": "<string>",
"mcp_session_id": "<string>",
"trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
"idempotency_key": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"started_at": "2023-11-07T05:31:56Z",
"finished_at": "2023-11-07T05:31:56Z",
"input": {},
"parent_run_id": "<string>",
"result": {},
"error": {}
}{
"error": {
"message": "<string>",
"type": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>"
}
}Cancel agent run
Start asynchronous cancellation. A running AgentCore session enters CANCELLING until StopRuntimeSession is confirmed or the bounded stop policy records a terminal failure.
Required scope: inference:run
import os
from qaip import Qaip
client = Qaip(
api_key=os.environ.get("QAIP_API_KEY"), # This is the default and can be omitted
)
agent_run = client.agent.cancel_run(
run_id="run_id",
)
print(agent_run.context_start_run_id)curl --request POST \
--url https://developer.qaip.com/api/v1/agent/runs/{run_id}/cancel \
--header 'x-api-key: <api-key>'const options = {method: 'POST', headers: {'x-api-key': '<api-key>'}};
fetch('https://developer.qaip.com/api/v1/agent/runs/{run_id}/cancel', 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://developer.qaip.com/api/v1/agent/runs/{run_id}/cancel",
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-api-key: <api-key>"
],
]);
$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://developer.qaip.com/api/v1/agent/runs/{run_id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://developer.qaip.com/api/v1/agent/runs/{run_id}/cancel")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://developer.qaip.com/api/v1/agent/runs/{run_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"run_id": "<string>",
"thread_id": "<string>",
"workflow_type": "<string>",
"provider": "ANTHROPIC_DIRECT",
"execution_mode": "LOCAL",
"status": "QUEUED",
"input_history_mode": "legacy_full",
"context_start_run_id": "<string>",
"context_truncated": true,
"runtime_arn": "<string>",
"mcp_session_id": "<string>",
"trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
"idempotency_key": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"started_at": "2023-11-07T05:31:56Z",
"finished_at": "2023-11-07T05:31:56Z",
"input": {},
"parent_run_id": "<string>",
"result": {},
"error": {}
}{
"error": {
"message": "<string>",
"type": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>"
}
}Authorizations
API key for authentication
Path Parameters
Query Parameters
Scope by principal. If omitted, only a run with no principal (principal_id is null) is addressed; a run whose principal differs yields 404.
Response
Cancellation accepted. Active runs are returned in CANCELLING state.
ANTHROPIC_DIRECT, BEDROCK, OPENAI, VERTEX_AI LOCAL, AGENTCORE Agent run lifecycle state.
QUEUED, RUNNING, CANCELLING, SUCCEEDED, FAILED, CANCELLED How the request supplied conversation history for this run.
legacy_full, delta_v1 Oldest run included in the reconstructed rolling context, or null when none was needed.
Whether older turns were omitted to stay within the server context budget.
保存済みW3C trace contextから導出したlowercase OpenTelemetry trace ID。移行前の行はnull。
^[0-9a-f]{32}$"4bf92f3577b34da6a3ce929d0e0e4736"
Server-enriched agent input used to reconstruct the thread transcript.
Run this run branched from within the thread (null for the thread root).

