TracePilot AI organizes every agent run into a structured hierarchy of traces and spans. A trace represents the full lifecycle of a single agent execution. Each individual operation within that run — an LLM call, a tool invocation, or any async step — is captured as a span. Together, these form a tree you can inspect, replay, and debug from the TracePilot dashboard.Documentation Index
Fetch the complete documentation index at: https://tracepilot.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
What is a trace?
A trace is one complete agent run. You start a new trace at the entry point of your agent withtp.startTrace('agent-name'). Every span created after that call belongs to that trace, until the agent finishes.
What is a span?
A span is one captured operation within a trace. TracePilot creates a span every time you calltp.wrapOpenAI() or tp.wrapToolCall(). Each span records:
| Field | Description |
|---|---|
input | The messages or arguments passed into the call |
output | The response returned from the LLM or tool |
tokens | Prompt and completion token counts |
latency | Wall-clock time for the operation in milliseconds |
error | Any exception thrown during the call |
parentSpanId | The ID of the parent span, if any |
wrapOpenAI or wrapToolCall returns a spanId. You pass that ID as the parentSpanId of subsequent calls to link child spans to their parent.
Building a span tree
When your agent has multiple steps, spans form a tree. The root span has no parent. Child spans pass the parent’sspanId as their parentSpanId. This mirrors the actual execution flow and makes it easy to see which step triggered which downstream call.
The stepOrder parameter numbers each span in the tree. TracePilot uses this to display spans in the correct sequence in the dashboard, regardless of when they were captured.
stepOrder does not affect execution. It only controls the display order in the dashboard. Always set it to reflect the logical sequence of your agent’s steps.Span data in the dashboard
Every span in the dashboard is expandable. Click a span to see its full input and output, the exact token breakdown (prompt vs. completion), latency in milliseconds, and any error message if the call failed.LLM spans
Created by
wrapOpenAI. Captures model name, messages in, completion out, and full token usage.Tool spans
Created by
wrapToolCall. Captures tool name, arguments, return value, and latency. Can be marked destructive.Wrapping calls
Start a trace
Call
tp.startTrace('agent-name') at the top of your agent function. This initializes the trace context for all subsequent spans.Wrap LLM calls
Replace direct OpenAI calls with
tp.wrapOpenAI(call, messages, parentSpanId?, stepOrder?). The result field contains the unmodified OpenAI response.Wrap tool calls
Replace tool invocations with
tp.wrapToolCall(toolName, call, parentSpanId, stepOrder, isDestructive?). Pass the spanId from the preceding LLM span as the parentSpanId.