curl --request POST \
--url http://127.0.0.1:8400/v1/work/{work_id}/tool_calls/next \
--header 'Content-Type: application/json' \
--header 'X-Session-Secret: <api-key>' \
--data '{
"block_ms": 0
}'import requests
url = "http://127.0.0.1:8400/v1/work/{work_id}/tool_calls/next"
payload = { "block_ms": 0 }
headers = {
"X-Session-Secret": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Session-Secret': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({block_ms: 0})
};
fetch('http://127.0.0.1:8400/v1/work/{work_id}/tool_calls/next', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8400",
CURLOPT_URL => "http://127.0.0.1:8400/v1/work/{work_id}/tool_calls/next",
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([
'block_ms' => 0
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Session-Secret: <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"
"strings"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8400/v1/work/{work_id}/tool_calls/next"
payload := strings.NewReader("{\n \"block_ms\": 0\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Session-Secret", "<api-key>")
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("http://127.0.0.1:8400/v1/work/{work_id}/tool_calls/next")
.header("X-Session-Secret", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"block_ms\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://127.0.0.1:8400/v1/work/{work_id}/tool_calls/next")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["X-Session-Secret"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"block_ms\": 0\n}"
response = http.request(request)
puts response.read_body{
"tool_call_id": "<string>",
"name": "<string>",
"input": {}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "model_not_mapped",
"tool": "<string>",
"clashes_with": "<string>"
}
}Get the next tool call
Worker side. Long-polls up to block_ms for the next tool call of the
session. Returns 204 when none arrived. A tool call that was handed out but has no result yet
is handed out again after the lease changes hands (at-least-once), with the
same tool_call_id. Run it once per id. Auth: the session secret.
Session finished. When the session will send no more tool calls, the
server answers 204 with the header X-Session-Closed: true. That happens
when the session is archived, or when it has had no turn running and no
pending tool call for sessions.idle_timeout (default 30 seconds). The worker
then calls /complete for the work item. The session’s next turn that
needs a tool queues a new item. A 204 without the header only means
“nothing yet, poll again”.
curl --request POST \
--url http://127.0.0.1:8400/v1/work/{work_id}/tool_calls/next \
--header 'Content-Type: application/json' \
--header 'X-Session-Secret: <api-key>' \
--data '{
"block_ms": 0
}'import requests
url = "http://127.0.0.1:8400/v1/work/{work_id}/tool_calls/next"
payload = { "block_ms": 0 }
headers = {
"X-Session-Secret": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Session-Secret': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({block_ms: 0})
};
fetch('http://127.0.0.1:8400/v1/work/{work_id}/tool_calls/next', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8400",
CURLOPT_URL => "http://127.0.0.1:8400/v1/work/{work_id}/tool_calls/next",
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([
'block_ms' => 0
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Session-Secret: <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"
"strings"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8400/v1/work/{work_id}/tool_calls/next"
payload := strings.NewReader("{\n \"block_ms\": 0\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Session-Secret", "<api-key>")
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("http://127.0.0.1:8400/v1/work/{work_id}/tool_calls/next")
.header("X-Session-Secret", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"block_ms\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://127.0.0.1:8400/v1/work/{work_id}/tool_calls/next")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["X-Session-Secret"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"block_ms\": 0\n}"
response = http.request(request)
puts response.read_body{
"tool_call_id": "<string>",
"name": "<string>",
"input": {}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "model_not_mapped",
"tool": "<string>",
"clashes_with": "<string>"
}
}