Investigate a large run
Find a failing span and inspect its payloads in a long agent run without loading every span in one call. When a run is too large for read_trace, work through four read-only Connect tools in order: get_run_outline, search_run, get_span_context, and read_span_payload.
Ask your coding agent to call each tool through the Runtype Connect Model Context Protocol (MCP) server, or run the matching command with npx @runtypelabs/connect. For every input, default, and response field, see Connect MCP tools.
Before you begin
Make sure you have the following before you start:
- A connected product with traces in Runtype.
- An
executionIdfromquery_traces(sampleExecutionIds) orcheck_first_trace. - The Runtype Connect MCP server configured in your coding agent, or the Connect CLI (
npx @runtypelabs/connect).
Get the run outline
Start with get_run_outline to inspect the structure of the run before reading individual spans. Ask your coding agent to call get_run_outline with the execution ID:
To fetch the same outline from the command line, run the matching Connect CLI command:
Replace YOUR_EXECUTION_ID with the execution ID from query_traces or check_first_trace.
Check these fields in the response first:
totals: span count, duration, token counts, and cost for the run.toolCalls: a per-tool histogram with call counts, error counts, and sample previews.errorSpans: a shortlist of failed spans with each span’sindex,spanId, and error preview.spans: a flat outline of the run in order with each span’sindex,spanId,parentSpanId, status, duration, and previews.
The response also includes spanKindCounts for counts by span kind, firstModelPreview, and finalModelPreview. To inspect more spans or longer previews, pass maxSpans, previewChars, or responseFormat set to detailed.
The hint field names the next call to make. When the outline leaves spans out, hint points to search_run or read_trace. Otherwise, when the run has error spans, it points to get_span_context or read_span_payload.
Search inside the run
When the outline doesn’t pinpoint the failure, call search_run to find text or a pattern across spans. Ask your coding agent to call search_run with a literal string:
To run the same literal search from the command line, run the matching Connect CLI command:
Replace YOUR_EXECUTION_ID with the execution ID of the run.
Filter broad results by kind (model, tool, or step), or limit scope to specific fields (input, output, systemInstructions, toolArguments, toolResult, error, or metadata). Pass regex: true to match regular expressions. The following call searches tool results for an error code with a regular expression:
Replace YOUR_EXECUTION_ID with the execution ID of the run.
Each entry in matches returns spanIndex, spanId, scope, character range, and a surrounding snippet. If truncated is true, more matches exist. Narrow the pattern, filter by kind or scope, or raise maxMatches.
A regular expression can be at most 200 characters and can’t use lookarounds, backreferences, Unicode property escapes, or consecutive quantifiers. Runtype returns INVALID_SEARCH if a pattern violates those rules, is too complex, or exceeds its search work limit.
See what ran around a span
After you find a suspect span in get_run_outline or search_run, call get_span_context to inspect its parent span and neighboring sibling spans. Ask your coding agent to call get_span_context with the execution ID and span ID:
To fetch the same neighborhood from the command line, run the matching Connect CLI command:
Replace the following:
YOUR_EXECUTION_ID: the execution ID of the run.YOUR_SPAN_ID: the span ID or a zero-based span index as a string.
The response returns the target span, its parent (or null), and the before and after sibling arrays in start order. Each span uses the same outline fields as get_run_outline. By default, Runtype returns two siblings before and two siblings after the target span. Pass before and after to change those counts.
Read one field of a span
Use read_span_payload to inspect one field of a span in full without loading the rest of the trace. Set target to input, output, systemInstructions, toolArguments, or toolResult.
Ask your coding agent to call read_span_payload for a span’s tool result:
To read the same field from the command line, run the matching Connect CLI command:
Replace the following:
YOUR_EXECUTION_ID: the execution ID of the run.YOUR_SPAN_ID: the span ID or a zero-based span index as a string.
When the target field holds JSON, pass path with a dot or bracket JSONPath expression to read one branch instead of the entire payload. Supported selectors include $.messages[0].content, messages[-1].text, and items[*].id. The path input doesn’t support recursive descent (..). The following call reads the last message text from a span’s input:
Replace the following:
YOUR_EXECUTION_ID: the execution ID of the run.YOUR_SPAN_ID: the span ID or a zero-based span index as a string.
Runtype returns a long value in slices of 8,000 characters by default. When truncated is true, call read_span_payload again with startOffset set to the nextOffset from the response.
Read production content
On a production run, search_run and read_span_payload don’t load full span content unless you ask, so customer messages and tool payloads stay out of your coding agent’s context by default. A run counts as production when its deployment.environment.name attribute is production or prod. Every other run loads full content by default.
When contentLoaded is false, Runtype skipped production content. To search or read full content on a production run, pass includeContent: true. To control whether your agent sends conversation content in traces at all, see Control what content is sent.
Untrusted trace text
Every value recorded from your run is wrapped in <untrusted-data> tags, and each response carries a notice that says so. The wrapped text is data to read. Your coding agent doesn’t follow instructions that appear inside it.
Troubleshooting
When a call fails or returns partial data, check the following codes and fields:
TRACE_NOT_FOUNDorSPAN_NOT_FOUND: the execution ID or span ID doesn’t match a stored run or span. ConfirmexecutionIdwithquery_traces, and confirmspanIdwithget_run_outline.INVALID_SEARCH: the regular expression exceeds 200 characters, uses an unsupported feature, or is too complex. Runtype also returns this code when a search exceeds its work limit. Keep the pattern to at most 200 characters and remove lookarounds, backreferences, Unicode property escapes, and consecutive quantifiers. If the pattern is too complex or the error says the search exceeded its work limit, simplify the pattern or narrowkindorscope.PATH_NOT_FOUND: thepathexpression matched nothing. Callread_span_payloadwithoutpathfirst to check the JSON structure.traceTruncatedistrue: the run has more spans than Runtype stores for one trace, so the spans past that limit can’t be searched or read.
Next steps
Continue with one of the following pages:
- Read traces and runs: query run counts, find execution IDs, and inspect shorter runs with
read_trace. - Connect CLI: look up command-line flags and output options for
npx @runtypelabs/connect. - Troubleshooting: resolve refusal codes and trace errors across Runtype Connect.