Skip to main content
Single-step agents are easy to debug. Multi-step agents — where an LLM reasons, triggers a tool, then reasons again based on the result — are not. TracePilot AI builds a visual execution tree from your spans by linking each step to its parent using the spanId returned by the previous step. You can see the full chain of decisions in the dashboard and fork any step to investigate a failure.

How the tree is built

Every wrapOpenAI and wrapToolCall call returns a spanId. Pass that spanId as parentSpanId to the next call that logically follows from it. TracePilot uses these links to render a nested tree rather than a flat list. The stepOrder parameter controls the display order of sibling spans under the same parent. Always pass it — the dashboard sorts siblings by stepOrder, not by wall-clock time, so the tree stays readable even when steps run concurrently.

Full example: research agent

The following agent follows three steps: an LLM produces a research plan, a web search tool executes the plan, and a second LLM synthesizes the search results into a final answer. Each step is linked to the one before it.

What the execution tree looks like

After this agent runs, the dashboard renders the following tree:
Each node in the tree is clickable. Select any span to inspect its input messages, output, token count, latency, and cost.
Always pass stepOrder — even when steps run sequentially. The dashboard uses it to sort siblings within the same parent, which keeps the tree readable if steps arrive out of order due to network or async timing differences.

Understanding each parentSpanId linkage

The three linkages in the example create a strict chain of causality: If you pass the wrong parentSpanId — for example, linking step 3 to planSpanId instead of searchSpanId — the tree still renders, but the relationship between the search and the answer becomes invisible. Be deliberate about which span is the logical cause of the next one.

Forking a failing step

If step 3 returns a bad answer, open the dashboard, find the step 3 span, and click Fork & Rerun. Edit the followUp messages directly in the UI — for example, adjust the tool output passed as context — and run the span again. The new result appears immediately without redeploying your agent.
When an agent runs multiple tools in parallel from a single LLM call, give each tool span the same parentSpanId (the LLM span) and unique stepOrder values. They appear as siblings in the tree.
The dashboard renders:
You can nest spans as many levels deep as your agent requires. Each call returns a spanId you can use as the parentSpanId for the next level. There is no hard limit on tree depth.
parentSpanId accepts the spanId from either wrapOpenAI or wrapToolCall. You can freely interleave LLM spans and tool spans as parents and children in the same tree.