curl --request POST \
--url https://api.trajectory.ai/api/v1/trajectories/{trajectory_id}/complete \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"termination_reason": "ENV_DONE"
}
'import requests
url = "https://api.trajectory.ai/api/v1/trajectories/{trajectory_id}/complete"
payload = { "termination_reason": "ENV_DONE" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({termination_reason: 'ENV_DONE'})
};
fetch('https://api.trajectory.ai/api/v1/trajectories/{trajectory_id}/complete', 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.trajectory.ai/api/v1/trajectories/{trajectory_id}/complete",
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([
'termination_reason' => 'ENV_DONE'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.trajectory.ai/api/v1/trajectories/{trajectory_id}/complete"
payload := strings.NewReader("{\n \"termination_reason\": \"ENV_DONE\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.trajectory.ai/api/v1/trajectories/{trajectory_id}/complete")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"termination_reason\": \"ENV_DONE\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trajectory.ai/api/v1/trajectories/{trajectory_id}/complete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"termination_reason\": \"ENV_DONE\"\n}"
response = http.request(request)
puts response.read_body{
"trajectory_id": "<string>",
"status": "<string>"
}{
"error": {
"type": "invalid_request_error",
"code": "resource_not_found",
"message": "<string>",
"doc_url": "<string>",
"context": {},
"param": "<string>"
}
}{
"error": {
"type": "dependency_error",
"code": "service_unavailable",
"message": "<string>",
"doc_url": "<string>",
"context": {},
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"context": {},
"param": "<string>"
}
}Complete a trajectory
Finish a trajectory after its model calls, reward writes, and event writes have ended. The termination reason records how the interaction ended; normal completion does not imply a positive reward.
curl --request POST \
--url https://api.trajectory.ai/api/v1/trajectories/{trajectory_id}/complete \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"termination_reason": "ENV_DONE"
}
'import requests
url = "https://api.trajectory.ai/api/v1/trajectories/{trajectory_id}/complete"
payload = { "termination_reason": "ENV_DONE" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({termination_reason: 'ENV_DONE'})
};
fetch('https://api.trajectory.ai/api/v1/trajectories/{trajectory_id}/complete', 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.trajectory.ai/api/v1/trajectories/{trajectory_id}/complete",
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([
'termination_reason' => 'ENV_DONE'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.trajectory.ai/api/v1/trajectories/{trajectory_id}/complete"
payload := strings.NewReader("{\n \"termination_reason\": \"ENV_DONE\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.trajectory.ai/api/v1/trajectories/{trajectory_id}/complete")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"termination_reason\": \"ENV_DONE\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trajectory.ai/api/v1/trajectories/{trajectory_id}/complete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"termination_reason\": \"ENV_DONE\"\n}"
response = http.request(request)
puts response.read_body{
"trajectory_id": "<string>",
"status": "<string>"
}{
"error": {
"type": "invalid_request_error",
"code": "resource_not_found",
"message": "<string>",
"doc_url": "<string>",
"context": {},
"param": "<string>"
}
}{
"error": {
"type": "dependency_error",
"code": "service_unavailable",
"message": "<string>",
"doc_url": "<string>",
"context": {},
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"context": {},
"param": "<string>"
}
}Authorizations
Short-lived token scoped to one rollout trajectory
Path Parameters
Body
How the attempt ended. Use ENV_DONE only when it finished normally.
- ENV_DONE: finished normally, including a graded wrong answer.
- ERROR: model requests failed after retries, or the environment or grader failed (including sandbox loss, crash, or startup timeout).
- TIMEOUT: the harness stopped the agent at its own time limit.
- TRUNCATION: a turn, step, output-token, or context limit stopped the attempt.
- STALE: stopped because the policy became stale. Deprecated inputs: MAX_STEPS, LIMIT_REACHED and MISSING_SUBMIT map to TRUNCATION; GOLDEN_PATCH maps to ENV_DONE.
Training admits ENV_DONE; all incomplete attempts require train_on_truncation. train_on_error admits ERROR; train_on_timeout admits TIMEOUT. Admitted TRUNCATION, TIMEOUT and ERROR attempts train with reward 0; recorded rewards are unchanged. An ungraded ENV_DONE is excluded unless train_on_error is enabled. Admitted samples can still be rejected by other training filters. In evaluation, TRUNCATION uses 0 if ungraded and caps positive rewards at 0, and ERROR is a failed attempt.
TIMEOUT, ENV_DONE, TRUNCATION, STALE, ERROR, MAX_STEPS, LIMIT_REACHED, MISSING_SUBMIT, GOLDEN_PATCH Response
Successful Response
Trajectory status after completion was accepted: completed once its capture is readable, or finalizing while the capture is still being built. Finalization continues durably: wait the Retry-After header's seconds, then poll GET /api/v1/trajectories/{trajectory_id}?include_steps=false until its status is completed.