Compact Agent Session
curl --request POST \
--url https://api.example.com/v1/agent_sessions/{session_id}/compact \
--header 'Content-Type: application/json' \
--data '
{
"model": {
"providerType": "custom",
"providerId": "<string>",
"modelName": "<string>"
}
}
'import requests
url = "https://api.example.com/v1/agent_sessions/{session_id}/compact"
payload = { "model": {
"providerType": "custom",
"providerId": "<string>",
"modelName": "<string>"
} }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({model: {providerType: 'custom', providerId: '<string>', modelName: '<string>'}})
};
fetch('https://api.example.com/v1/agent_sessions/{session_id}/compact', 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/v1/agent_sessions/{session_id}/compact",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => [
'providerType' => 'custom',
'providerId' => '<string>',
'modelName' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/agent_sessions/{session_id}/compact"
payload := strings.NewReader("{\n \"model\": {\n \"providerType\": \"custom\",\n \"providerId\": \"<string>\",\n \"modelName\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
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/v1/agent_sessions/{session_id}/compact")
.header("Content-Type", "application/json")
.body("{\n \"model\": {\n \"providerType\": \"custom\",\n \"providerId\": \"<string>\",\n \"modelName\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/agent_sessions/{session_id}/compact")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": {\n \"providerType\": \"custom\",\n \"providerId\": \"<string>\",\n \"modelName\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"parts": [
{
"text": "<string>",
"type": "text",
"providerMetadata": {}
}
],
"metadata": {
"phoenix": {
"type": "assistant",
"sessionId": "<string>",
"turnTraceContext": {
"traceId": "<string>",
"rootSpanId": "<string>",
"startedAt": "2023-11-07T05:31:56Z"
},
"usage": {
"tokens": {
"prompt": 123,
"completion": 123,
"total": 123
},
"promptDetails": {
"cacheRead": 123,
"cacheWrite": 123
}
},
"interrupted": false
},
"pydantic_ai": {
"timestamp": "2023-11-07T05:31:56Z"
}
}
}
}"<string>""<string>""<string>""<string>"{
"message": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}"<string>""<string>"Agent Sessions
Compact Agent Session
POST
/
v1
/
agent_sessions
/
{session_id}
/
compact
Compact Agent Session
curl --request POST \
--url https://api.example.com/v1/agent_sessions/{session_id}/compact \
--header 'Content-Type: application/json' \
--data '
{
"model": {
"providerType": "custom",
"providerId": "<string>",
"modelName": "<string>"
}
}
'import requests
url = "https://api.example.com/v1/agent_sessions/{session_id}/compact"
payload = { "model": {
"providerType": "custom",
"providerId": "<string>",
"modelName": "<string>"
} }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({model: {providerType: 'custom', providerId: '<string>', modelName: '<string>'}})
};
fetch('https://api.example.com/v1/agent_sessions/{session_id}/compact', 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/v1/agent_sessions/{session_id}/compact",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => [
'providerType' => 'custom',
'providerId' => '<string>',
'modelName' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/agent_sessions/{session_id}/compact"
payload := strings.NewReader("{\n \"model\": {\n \"providerType\": \"custom\",\n \"providerId\": \"<string>\",\n \"modelName\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
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/v1/agent_sessions/{session_id}/compact")
.header("Content-Type", "application/json")
.body("{\n \"model\": {\n \"providerType\": \"custom\",\n \"providerId\": \"<string>\",\n \"modelName\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/agent_sessions/{session_id}/compact")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": {\n \"providerType\": \"custom\",\n \"providerId\": \"<string>\",\n \"modelName\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"parts": [
{
"text": "<string>",
"type": "text",
"providerMetadata": {}
}
],
"metadata": {
"phoenix": {
"type": "assistant",
"sessionId": "<string>",
"turnTraceContext": {
"traceId": "<string>",
"rootSpanId": "<string>",
"startedAt": "2023-11-07T05:31:56Z"
},
"usage": {
"tokens": {
"prompt": 123,
"completion": 123,
"total": 123
},
"promptDetails": {
"cacheRead": 123,
"cacheWrite": 123
}
},
"interrupted": false
},
"pydantic_ai": {
"timestamp": "2023-11-07T05:31:56Z"
}
}
}
}"<string>""<string>""<string>""<string>"{
"message": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}"<string>""<string>"Path Parameters
Body
application/json
Request a model-generated checkpoint for a persisted conversation.
The model the client believes the session is set to. As on the chat route this is a precondition: the summary is generated with the session's persisted selection, and a mismatch is rejected with HTTP 409 and code agent_session_model_stale.
- CustomProviderModelSelection
- BuiltInProviderModelSelection
Show child attributes
Show child attributes
Response
Successful Response
The checkpoint message this request created. A 200 always means a new
checkpoint was persisted; every other outcome is an HTTP 409 whose body's
code says why (see AgentSessionConflictError).
UIMessage with metadata narrowed to the Phoenix wire shapes.
Show child attributes
Show child attributes
Was this page helpful?
⌘I

