Compact Session Context (beta)
Beta. Ask the session’s running agent to summarize its context before its next model call. Returns 409 when the session has no running run or that run did not start with modelParams.context.
POST
/
sessions
/
{session_id}
/
compact
Compact Session Context (beta)
const options = {method: 'POST', headers: {'X-Browser-Use-API-Key': '<api-key>'}};
fetch('https://api.browser-use.com/api/v4/sessions/{session_id}/compact', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://api.browser-use.com/api/v4/sessions/{session_id}/compact \
--header 'X-Browser-Use-API-Key: <api-key>'import requests
url = "https://api.browser-use.com/api/v4/sessions/{session_id}/compact"
headers = {"X-Browser-Use-API-Key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text){
"sessionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"requested": true
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Was this page helpful?
⌘I
Compact Session Context (beta)
const options = {method: 'POST', headers: {'X-Browser-Use-API-Key': '<api-key>'}};
fetch('https://api.browser-use.com/api/v4/sessions/{session_id}/compact', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://api.browser-use.com/api/v4/sessions/{session_id}/compact \
--header 'X-Browser-Use-API-Key: <api-key>'import requests
url = "https://api.browser-use.com/api/v4/sessions/{session_id}/compact"
headers = {"X-Browser-Use-API-Key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text){
"sessionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"requested": true
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}