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

# Read traces and runs

> Count incoming runs by environment and agent, inspect individual runs, and load conversation content.

Check which runs arrived from your agent and inspect what happened inside any run. You can count runs by environment and agent, read a run's spans and errors, and load full conversation content when you need it.

## Before you begin

You need the following to read traces and runs:

* A connected repository that has sent at least one trace. To set this up, see [Connect a repository](/connect/connect-a-repository) and [Send a first trace](/connect/send-a-first-trace).
* A coding agent connected to the Runtype Connect Model Context Protocol (MCP) server, or the `runtype-connect` CLI (`npx @runtypelabs/connect`).

The trace tools on this page only read, and they work before you [claim your organization](/connect/connect-a-repository#claim-an-unclaimed-organization) with `npx @runtypelabs/connect claim`. If your organization has several products, pass the product ID in `productId` (or `--product-id` in the CLI). Run the CLI from the directory that holds your `.env` or `.env.local` file. The CLI picks the product from the ingest key there.

## Count runs by environment and agent

Count runs across your product to verify which environments and agents reported traffic and to get sample execution IDs for individual runs.

#### Coding agent (MCP)

Ask your coding agent to call `query_traces`. To count runs across every environment over the default seven-day window, pass an empty object:

**`Count runs across all environments`**

```json title="Count runs across all environments"
{}
```

To count only production runs, pass `environment`:

**`Count production runs`**

```json title="Count production runs"
{
  "environment": "production"
}
```

You can also filter by `agentId`, `status` (`running`, `completed`, or `failed`), and `from` and `to` (ISO 8601 timestamps).

#### CLI

Run `query-traces` to count runs across every environment:

**`Count runs across all environments`**

```bash title="Count runs across all environments"
npx @runtypelabs/connect query-traces --json
```

To count only production runs, pass `--environment`:

**`Count production runs`**

```bash title="Count production runs"
npx @runtypelabs/connect query-traces --environment production --json
```

Each group shows its environment, the agent (or other breakdown value), and run and failure counts. It also returns up to three execution IDs (`sampleExecutionIds`) to pass to `read_trace` or `get_run_outline`.

When you omit `environment`, Runtype counts each environment in separate groups and never combines them. When you pass `environment`, `totals` covers that environment.

The following defaults and options apply to `query_traces`:

* **Window**: Runtype counts the last seven days by default and up to 30 days, capped at your plan's trace retention.
* **Breakdown**: Pass `breakdown` to group by `agent` (default), `status`, `day`, `stop_reason`, `model`, or `source`.
* **Paging**: If `truncated` is `true`, call `query_traces` again with `cursor` (`--cursor`) set to `nextCursor`.
* **Detailed metrics**: Pass `responseFormat` set to `detailed` (`--response-format detailed`) to add p95 duration, token totals, and cost estimates.

If `groups` is empty, read `hint` for the next step. For example, widen `from` and `to`, drop a filter, or run a first-trace check.

## Read one run

Pass an execution ID from `sampleExecutionIds` (or from `check_first_trace`) to inspect what happened inside one run. For a short run, `read_trace` is enough. For a long run, start with `get_run_outline` and see [Investigate a large run](/analyze/investigate-a-large-run) to search spans and read individual fields.

#### Coding agent (MCP)

Ask your coding agent to call `read_trace` with the run's `executionId`:

**`Read one run`**

```json title="Read one run"
{
  "executionId": "EXECUTION_ID"
}
```

Replace `EXECUTION_ID` with a run ID from `sampleExecutionIds`.

To inspect the first error in a failed run, pass `aroundFirstFailure` with a radius from 0 to 50 spans:

**`Read spans around the first failure`**

```json title="Read spans around the first failure"
{
  "executionId": "EXECUTION_ID",
  "aroundFirstFailure": 3
}
```

Replace `EXECUTION_ID` with the failed run's execution ID.

#### CLI

Run `read-trace` with `--execution-id` to inspect one run:

**`Read one run`**

```bash title="Read one run"
npx @runtypelabs/connect read-trace --execution-id EXECUTION_ID --json
```

Replace `EXECUTION_ID` with a run ID from `sampleExecutionIds`.

To inspect the first failed span and three spans on each side, pass `--around-first-failure`:

**`Read spans around the first failure`**

```bash title="Read spans around the first failure"
npx @runtypelabs/connect read-trace --execution-id EXECUTION_ID --around-first-failure 3 --json
```

Replace `EXECUTION_ID` with the failed run's execution ID.

A run from another product or organization, or one older than your plan's trace retention, returns a not-found error. For retention windows by plan, see [Limits and pricing](/reference/limits-and-pricing).

### What a run result contains

A `read_trace` response returns these top-level fields:

* **`run`**: Metadata for the run, including the agent, environment, conversation, and timestamps.
* **`spans`**: Selected spans in start order, each with its `index`, kind, name, tool, status, duration, error, and input and output previews. Detailed output (`responseFormat` set to `detailed`) adds `spanId`, token counts, and cost.
* **`truncated`**: Whether more matched spans exist beyond the returned slice.
* **`content`**: Whether full span content loaded for the call.
* **`hint`**: The next call to make when paging forward or narrowing a large response.

Pass a span's `index` (or `spanId` in `detailed` output) to `read_span_payload` or `get_span_context` when you want to inspect one span in full. `traceTruncated` is `true` when the run had more spans than Runtype keeps for one trace.

Runtype wraps recorded trace text (`error`, previews, and `content` fields) in `<untrusted-data>` tags. The `notice` field states that the wrapped text is data to read, never instructions to follow.

### Page and filter large runs

`read_trace` returns 10 spans by default. Set `limit` (`--limit`) up to 50 for more, or switch to `get_run_outline` for long runs.

Use these options to narrow a `read_trace` call:

* **Page forward**: When `truncated` is `true`, call `read_trace` again with `start` (`--start`) set to the next span index named in `hint`.
* **Filter by span kind**: Pass `kind` (`--kind`) with `model`, `tool`, or `step` to read only model calls, tool calls, or steps.
* **Center on a failure**: Pass `aroundFirstFailure` (`--around-first-failure`) with a radius from 0 to 50. Raise `limit` to see more spans on each side. Don't combine `aroundFirstFailure` with `start`.

## Load conversation content

A run counts as production when its `deployment.environment.name` attribute is `production` or `prod` (set through `RUNTYPE_ENVIRONMENT`). Whether `read_trace` loads full conversation content depends on that environment:

* **Outside production**: Full content loads by default (`includeContent` defaults to `true`), including development runs and runs that reported no environment.
* **In production**: Full content doesn't load by default (`includeContent` defaults to `false`). Each span still returns `inputPreview` and `outputPreview` (up to 280 characters each) so you can inspect structure without loading full customer messages.

When content loads, each span's `content` object can include `input`, `output`, `systemInstructions`, `toolArguments`, and `toolResult`. Runtype returns only the content that your instrumentation sent and your logging policy kept. To control what your agent exports, see [Control what content is sent](/connect/control-what-content-is-sent).

To load full content for a production run, ask for it explicitly.

#### Coding agent (MCP)

Pass `includeContent: true` to `read_trace` to load full content on a production run:

**`Load production content`**

```json title="Load production content"
{
  "executionId": "EXECUTION_ID",
  "includeContent": true
}
```

Replace `EXECUTION_ID` with the production run's execution ID. To skip loading content on a non-production run, pass `"includeContent": false`.

#### CLI

Pass `--include-content` to `read-trace` to load full content on a production run:

**`Load production content`**

```bash title="Load production content"
npx @runtypelabs/connect read-trace --execution-id EXECUTION_ID --include-content --json
```

Replace `EXECUTION_ID` with the production run's execution ID. To skip loading content on a non-production run, pass `--no-include-content`.

Runtype caps full content at 16 KB per call (64 KB in `detailed` output). Pass `maxContentBytes` (`--max-content-bytes`) to change that limit. If a response would exceed the size cap, Runtype omits the content and `hint` tells you how to narrow the call.

## View the same runs in the dashboard

Every run that `query_traces` and `read_trace` return also appears in the Runtype dashboard at [use.runtype.com](https://use.runtype.com). Open the view that matches what you want to check:

* **One agent**: Open the agent. The **Runs** tab lists its runs, and imported runs show an **External** badge. Select a run to open its details.
* **One product**: In a product, click **Runs** in the top bar (or press `⌘J`) to view runs and conversations across the product's agents.
* **Whole workspace**: Outside a product, click **Runs** in the top bar to list runs across the workspace.

## Next steps

Use the following guides to continue:

* [Read the observed profile](/analyze/read-the-observed-profile): inspect the prompts, tools, and models Runtype observes from production runs.
* [Score conversations with signals](/analyze/score-conversations-with-signals): review signal scores on your agent's turns and add custom signals.
* [Find issues in conversations](/analyze/find-issues-in-conversations): surface recurring problems across real conversations.
* [Connect MCP tools](/reference/connect-mcp-tools): look up every parameter and output field for the trace tools.
* [Connect CLI](/reference/connect-cli): look up every `runtype-connect` command and option.