> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.rasen.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.rasen.ai/_mcp/server.

# Read tool call logs

> List the tool calls of one call, then read the filtered arguments, result and HTTP status of each run of one webhook or MCP tool.

## 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](/guides/tools).

## Facts

| Item                 | Value                                                                                                                    |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| Operations           | `listCallToolOutcomes`, `listAgentToolRuns`                                                                              |
| Paths                | `GET /calls/{call_id}/tool-outcomes`, `GET /agents/{agent_id}/tools/{tool_id}/runs`                                      |
| Capability           | `calls.read`                                                                                                             |
| Required headers     | `Authorization` on every request                                                                                         |
| Payloads             | `listCallToolOutcomes` has no arguments or result. `listAgentToolRuns` has both                                          |
| Run kinds            | `listAgentToolRuns` reads webhook and MCP tools. Built-in `end_call` and `transfer` have no authored tool ID             |
| Outcome page `state` | `pending`, `ready`, `unavailable`, with `poll_after_seconds`. The list is open                                           |
| Item `state`         | `pending`, `succeeded`, `failed`, `indeterminate`. The list is open                                                      |
| Item `timing`        | `during_call`, or `pre_call` for the run of the agent's before-call tool. The list is open                               |
| Field lists          | `CallToolOutcome` and `ToolRun` in the [API Reference](/api-reference)                                                   |
| Run filters          | `call_id`; `state`, repeated for each value, 1 to 16 values; `start` and `end`                                           |
| Time range           | `start` is inclusive and `end` is exclusive, in UTC. The default range is the last 30 days; the range is at most 93 days |
| Page size            | `limit`: 50 by default, at most 200                                                                                      |
| Order                | Outcomes by `started_at`, then `id`; runs newest first by `started_at`, then `id`                                        |
| Payload limit        | `arguments` and `result` are cut at 32,768 bytes; the `_truncated` field is then `true`                                  |
| Environment          | `RASEN_API_BASE` (the base URL, ending in `/v1`), `RASEN_API_KEY`, `CALL_ID`, `AGENT_ID`, `TOOL_ID`                      |
| Python               | 3.10 or later, with the `httpx` package                                                                                  |
| TypeScript           | Node.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`**

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

**`Python`**

```python Python
import os

import httpx

BASE = os.environ["RASEN_API_BASE"]
KEY = os.environ["RASEN_API_KEY"]
CALL_ID = os.environ["CALL_ID"]

response = httpx.get(
    f"{BASE}/calls/{CALL_ID}/tool-outcomes",
    headers={"Authorization": f"Bearer {KEY}"},
)
response.raise_for_status()
page = response.json()
print(page["state"], page["poll_after_seconds"])
for outcome in page["items"]:
    print(outcome["tool_name"], outcome["timing"], outcome["state"], outcome["reason"], outcome["latency_ms"])
print(page["next_cursor"])
```

**`TypeScript`**

```typescript TypeScript
const { RASEN_API_BASE, RASEN_API_KEY, CALL_ID } = process.env;

const response = await fetch(`${RASEN_API_BASE}/calls/${CALL_ID}/tool-outcomes`, {
  headers: { Authorization: `Bearer ${RASEN_API_KEY}` },
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const page = await response.json();
console.log(page.state, page.poll_after_seconds);
for (const outcome of page.items) {
  console.log(outcome.tool_name, outcome.timing, outcome.state, outcome.reason, outcome.latency_ms);
}
console.log(page.next_cursor);
```

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](/guides/calls#results).
If `next_cursor` is not `null`, send it as `cursor` to read the next page.

### 2. Read the runs of one tool

**`curl`**

```bash curl
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"
```

**`Python`**

```python Python
import os

import httpx

BASE = os.environ["RASEN_API_BASE"]
KEY = os.environ["RASEN_API_KEY"]
AGENT_ID = os.environ["AGENT_ID"]
TOOL_ID = os.environ["TOOL_ID"]
CALL_ID = os.environ["CALL_ID"]

response = httpx.get(
    f"{BASE}/agents/{AGENT_ID}/tools/{TOOL_ID}/runs",
    headers={"Authorization": f"Bearer {KEY}"},
    params={"call_id": CALL_ID, "state": ["failed", "indeterminate"]},
)
response.raise_for_status()
page = response.json()
for run in page["items"]:
    print(run["state"], run["reason"], run["http_status"], run["latency_ms"])
    print(run["arguments"])
    print(run["result"])
print(page["next_cursor"])
```

**`TypeScript`**

```typescript TypeScript
const { RASEN_API_BASE, RASEN_API_KEY, AGENT_ID, TOOL_ID, CALL_ID } = process.env;

const query = new URLSearchParams({ call_id: CALL_ID! });
query.append("state", "failed");
query.append("state", "indeterminate");

const response = await fetch(
  `${RASEN_API_BASE}/agents/${AGENT_ID}/tools/${TOOL_ID}/runs?${query}`,
  { headers: { Authorization: `Bearer ${RASEN_API_KEY}` } },
);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const page = await response.json();
for (const run of page.items) {
  console.log(run.state, run.reason, run.http_status, run.latency_ms);
  console.log(run.arguments);
  console.log(run.result);
}
console.log(page.next_cursor);
```

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](/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

```bash
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.

```json
{"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

| Code                  | Cause                                                                                                                                                     | Fix                                                                                                           |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `invalid_request`     | A 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. |
| `forbidden`           | The key lacks `calls.read`. `details.required_capabilities` lists it.                                                                                     | Use a key with `calls.read`.                                                                                  |
| `not_found` on step 1 | The call does not exist, or belongs to another workspace.                                                                                                 | Check `CALL_ID`.                                                                                              |
| `not_found` on step 2 | The agent or the tool does not exist, or belongs to another workspace.                                                                                    | Check `AGENT_ID` and `TOOL_ID`.                                                                               |
| `rate_limited`        | The key sent too many requests.                                                                                                                           | Wait `Retry-After` seconds, then send the same request.                                                       |
| `unavailable`         | The service could not answer.                                                                                                                             | If the answer has `Retry-After`, wait that many seconds, then send the same request.                          |

## Related

* [Tools and MCP servers](/guides/tools)
* [Add a before-call tool](/guides/before-call-tool)
* [Calls and results](/guides/calls)
* [Pagination](/concepts/pagination)
* [Filters and limits](/concepts/filters)
* [Error codes](/concepts/error-codes)