Steer
Send tool results
Send results for the agent’s pending custom tool calls so the session continues.
POST
/
api
/
v2
/
sessions
/
{id}
/
tool_results
from hai_agents import Client, ToolRequest, ToolResultEvent
client = Client()
client.sessions.send_session_tool_results(
session_id,
request=ToolResultEvent(
tool_req=ToolRequest(tool_name="lookup_order", args={"order_id": "A1"}, id="call_1"),
result="shipped",
),
)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
await client.sessions.sendSessionToolResults({
id: sessionId,
body: {
kind: "tool_result",
toolReq: { toolName: "lookup_order", args: { order_id: "A1" }, id: "call_1" },
result: "shipped",
},
});
curl -X POST https://agp.eu.hcompany.ai/api/v2/sessions/$SESSION_ID/tool_results \
-H "Authorization: Bearer $HAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"kind": "tool_result",
"tool_req": { "tool_name": "lookup_order", "args": { "order_id": "A1" }, "id": "call_1" },
"result": "shipped"
}'
Behavior
When the agent calls a custom tool, the session waits onawaiting_tool_results until you post a result for every pending call. The SDK run helpers call this endpoint for you.
Results are relayed to the agent as-is: the API doesn’t check tool_req.id against the pending calls, so echo the request faithfully. Settling a call on a paused session leaves it paused, so resume it separately.
Path parameters
string
required
The session ID.
Request body
Send either a single settled call or a batch. A single call is atool_result on success or an error_event on failure, discriminated by kind. Each call echoes back the full pending tool_req from pending_tool_calls ({ tool_name, args, id }), not only its ID.
Tool result (success)
string
required
"tool_result".object
required
any
JSON-serializable tool output, shown to the model.
Tool error (failure)
string
required
"error_event".string
required
Error text shown to the model.
string
required
Component that produced the error, for example
"custom_tools".object
The pending tool call this answers, echoed back from
pending_tool_calls. Optional in the schema, but send it so the agent can match the error to its call.Batch
string
required
"batch".object[]
required
At least one
tool_result or error_event object.Response
202 Accepted. The agent resumes once every pending call has a result.
from hai_agents import Client, ToolRequest, ToolResultEvent
client = Client()
client.sessions.send_session_tool_results(
session_id,
request=ToolResultEvent(
tool_req=ToolRequest(tool_name="lookup_order", args={"order_id": "A1"}, id="call_1"),
result="shipped",
),
)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
await client.sessions.sendSessionToolResults({
id: sessionId,
body: {
kind: "tool_result",
toolReq: { toolName: "lookup_order", args: { order_id: "A1" }, id: "call_1" },
result: "shipped",
},
});
curl -X POST https://agp.eu.hcompany.ai/api/v2/sessions/$SESSION_ID/tool_results \
-H "Authorization: Bearer $HAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"kind": "tool_result",
"tool_req": { "tool_name": "lookup_order", "args": { "order_id": "A1" }, "id": "call_1" },
"result": "shipped"
}'
More examples
Send a batch of results
from hai_agents import Client, ErrorEvent, ToolRequest, ToolResultBatch, ToolResultEvent
client = Client()
client.sessions.send_session_tool_results(
session_id,
request=ToolResultBatch(
results=[
ToolResultEvent(
tool_req=ToolRequest(tool_name="lookup_order", args={}, id="call_1"),
result="shipped",
),
ErrorEvent(
error="Order not found",
origin="custom_tools",
tool_req=ToolRequest(tool_name="lookup_order", args={}, id="call_2"),
),
],
),
)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
await client.sessions.sendSessionToolResults({
id: sessionId,
body: {
type: "batch",
results: [
{
kind: "tool_result",
toolReq: { toolName: "lookup_order", args: {}, id: "call_1" },
result: "shipped",
},
{
kind: "error_event",
error: "Order not found",
origin: "custom_tools",
toolReq: { toolName: "lookup_order", args: {}, id: "call_2" },
},
],
},
});
curl -X POST https://agp.eu.hcompany.ai/api/v2/sessions/$SESSION_ID/tool_results \
-H "Authorization: Bearer $HAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "batch",
"results": [
{"kind": "tool_result", "tool_req": {"tool_name": "lookup_order", "args": {}, "id": "call_1"}, "result": "shipped"},
{"kind": "error_event", "error": "Order not found", "origin": "custom_tools", "tool_req": {"tool_name": "lookup_order", "args": {}, "id": "call_2"}}
]
}'
Errors
| Status | Cause |
|---|---|
404 | Not found, or not in your organization. |
409 | The session already finished. Its pending calls were resolved when it ended. |
422 | Malformed request body. |
Was this page helpful?
⌘I
from hai_agents import Client, ToolRequest, ToolResultEvent
client = Client()
client.sessions.send_session_tool_results(
session_id,
request=ToolResultEvent(
tool_req=ToolRequest(tool_name="lookup_order", args={"order_id": "A1"}, id="call_1"),
result="shipped",
),
)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
await client.sessions.sendSessionToolResults({
id: sessionId,
body: {
kind: "tool_result",
toolReq: { toolName: "lookup_order", args: { order_id: "A1" }, id: "call_1" },
result: "shipped",
},
});
curl -X POST https://agp.eu.hcompany.ai/api/v2/sessions/$SESSION_ID/tool_results \
-H "Authorization: Bearer $HAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"kind": "tool_result",
"tool_req": { "tool_name": "lookup_order", "args": { "order_id": "A1" }, "id": "call_1" },
"result": "shipped"
}'