Skip to navigation

Read tool call logs

Summary

This guide reads the tool calls that an agent made. It lists the outcome of each tool call in one call, then reads the runs of one webhook or MCP tool with their filtered arguments and result. It does not cover how to add or change a tool; see Tools and MCP servers.

Facts

ItemValue
OperationslistCallToolOutcomes, listAgentToolRuns
PathsGET /calls/{call_id}/tool-outcomes, GET /agents/{agent_id}/tools/{tool_id}/runs
Capabilitycalls.read
Required headersAuthorization on every request
PayloadslistCallToolOutcomes has no arguments or result. listAgentToolRuns has both
Run kindslistAgentToolRuns reads webhook and MCP tools. Built-in end_call and transfer have no authored tool ID
Outcome page statepending, ready, unavailable, with poll_after_seconds. The list is open
Item statepending, succeeded, failed, indeterminate. The list is open
Item timingduring_call, or pre_call for the run of the agent’s before-call tool. The list is open
Field listsCallToolOutcome and ToolRun in the API Reference
Run filterscall_id; state, repeated for each value, 1 to 16 values; start and end
Time rangestart is inclusive and end is exclusive, in UTC. The default range is the last 30 days; the range is at most 93 days
Page sizelimit: 50 by default, at most 200
OrderOutcomes by started_at, then id; runs newest first by started_at, then id
Payload limitarguments and result are cut at 32,768 bytes; the _truncated field is then true
EnvironmentRASEN_API_BASE (the base URL, ending in /v1), RASEN_API_KEY, CALL_ID, AGENT_ID, TOOL_ID
Python3.10 or later, with the httpx package
TypeScriptNode.js 22 or later (built-in fetch)

Steps

Set CALL_ID to the id of a call from listCalls. Set AGENT_ID to the agent_id of that call.

1. List the tool outcomes of a call

curl --fail-with-body -sS "$RASEN_API_BASE/calls/$CALL_ID/tool-outcomes" \
-H "Authorization: Bearer $RASEN_API_KEY"

Each item is one tool call of the call. state says how it ended, reason gives the registered code of a call that did not succeed, and latency_ms is the time the run took. latency_ms is null until the run has a result. timing is pre_call for the run of the agent’s before-call tool, which the platform sent before it answered an inbound call; every other run is during_call. Choose a webhook or MCP item to inspect, and set TOOL_ID to its tool_id. A built-in end_call or transfer item has a null tool_id and has no runs to read.

If the page state is pending, wait poll_after_seconds, then read the list again. If it is unavailable, the outcomes will not be produced; see Calls and results. If next_cursor is not null, send it as cursor to read the next page.

2. Read the runs of one tool

curl --fail-with-body -sS -G "$RASEN_API_BASE/agents/$AGENT_ID/tools/$TOOL_ID/runs" \
-H "Authorization: Bearer $RASEN_API_KEY" \
--data-urlencode "call_id=$CALL_ID" \
--data-urlencode "state=failed" \
--data-urlencode "state=indeterminate"

The answer lists the failed and indeterminate runs of the tool in that call, newest first. Each run has the same id as its item in listCallToolOutcomes. Leave out call_id to read the runs of the tool across all calls of the agent in the time range.

arguments is what the model sent, and result is what the tool answered, both with credentials filtered out. A run with timing: pre_call has no model arguments, because no model runs before the call. http_status is the status of the webhook response. The ToolRun schema in the API Reference describes each field.

Rules

  • MUST NOT run an indeterminate tool call again automatically. Its effect is unknown: check the other system before you repeat the action.
  • MUST keep unknown kind, state and reason values, and treat them as unknown, never as success.
  • MUST send the same filters and limit with a cursor. A cursor expires after 24 hours.
  • MUST repeat state once for each value. The API refuses an invalid filter with invalid_request; it does not ignore it.
  • MUST read arguments and result as nullable. Both are null for a run recorded while their capture was off, and the matching _truncated field is null too. result is also null for a run that was refused, timed out, was uncertain or was too large.
  • MUST read http_status as nullable. It is null for an MCP tool and when no response arrived.
  • If arguments_truncated or result_truncated is true, the field holds only _truncated_json: a filtered JSON prefix, not a complete object. MUST NOT parse it as the full payload.
  • A run never holds a credential, a resolved header, a URL path or query, or a provider exception.

Verify

curl --fail-with-body -sS -G "$RASEN_API_BASE/agents/$AGENT_ID/tools/$TOOL_ID/runs" \
-H "Authorization: Bearer $RASEN_API_KEY" \
--data-urlencode "call_id=$CALL_ID"

Expected output: the runs of the tool in that call, each with the id of an item from step 1.

{"items": [{"id": "run_01j00000000000000000000000", "call_id": "call_01j00000000000000000000000", "tool_id": "tool_01j00000000000000000000000", "tool_name": "schedule_appointment", "kind": "webhook", "timing": "during_call", "state": "failed", "reason": "tool_call_failed", "latency_ms": 842, "http_status": 503}], "next_cursor": null}

Errors

CodeCauseFix
invalid_requestA filter is invalid or the time range is longer than 93 days. With details.field = "cursor", the cursor is invalid, expired or sent with other filters.Send known state values and a range of at most 93 days. For a cursor error, start again without the cursor.
forbiddenThe key lacks calls.read. details.required_capabilities lists it.Use a key with calls.read.
not_found on step 1The call does not exist, or belongs to another workspace.Check CALL_ID.
not_found on step 2The agent or the tool does not exist, or belongs to another workspace.Check AGENT_ID and TOOL_ID.
rate_limitedThe key sent too many requests.Wait Retry-After seconds, then send the same request.
unavailableThe service could not answer.If the answer has Retry-After, wait that many seconds, then send the same request.