To do agent trajectory analysis, group your agent's runs by the execution path each one took and count how many runs took each path. An agent trajectory, also called an execution path, is the ordered steps of one run (which tools and model calls ran, in what order). Once runs are counted by path, a failure that repeats a thousand times reads as one path with a count of 1,000, and you can rank what to fix by how many runs it hits. There are six steps, from getting your traces in to joining each path to what users did next. Kubit does this in Flows, which draws every path in one Sankey with a count per path, while Polaris, Kubit's in-house small language model, labels and scores every span.
Key facts
A trace already holds the order of every step. In OpenTelemetry, each span carries its parent span ID, so a trace records the structure and order of the operations in one run (OpenTelemetry docs)
Manual error analysis starts from a sample. Langfuse's error-analysis guide has a team review 30 to 50 traces from a sample of about 100 and group the notes into 5 to 10 failure categories (Langfuse docs)
Trajectory evaluation checks one run at a time. LangChain's agentevals package judges an agent's trajectory against an expected trajectory, or with an LLM (agentevals)
Kubit's Flows counts every path. Each path shows how many traces took it, so a failure that repeats a thousand times shows up as one path with a count of 1,000 (Flows)
Polaris labels and scores every span in under 100ms, with no additional LLM cost or sampling. Polaris is up to 98% lower cost and ~15x faster than a frontier LLM judge, with comparable accuracy on public agent benchmarks (Polaris)
What is agent trajectory analysis?
Trajectory analysis looks across all your runs and counts how many took each path, so you can rank failures by how often they happen and see which paths moved after you shipped a change.
Two runs share a path when they called the same steps in the same order, even if their inputs differ. A support agent that called search_orders, then get_refund_policy, then the LLM, took the same path for a user who typed "where's my refund" and for one who pasted an order number. Why grouping by path is the right key is covered in Why we group agent runs by the shape of their execution path. This guide covers how to do it.
It also differs from trajectory evaluation. An evaluator such as LangChain's agentevals compares one run with an expected trajectory, strictly or with the tool calls in any order, and that works well as a test for a task you can predict before you ship. Trajectory analysis starts from production runs, including the paths nobody predicted, and counts them.
How do you do agent trajectory analysis?

1. Get your traces in one place
You need every run in one store you can query, with its spans and their start times. If your agent already emits OpenTelemetry spans, you have the raw material, because each span carries its parent and its start time. Set two attributes while you're there. A release attribute such as service.version, set to the commit, tells runs apart for step 5, and a user ID that matches your product analytics events makes step 6 possible.
Kubit reads OpenTelemetry traces in an Agent workspace. The Quickstart lists the ways to send them, from the agent plugin in Claude Code or Cursor to the stock OTLP exporter. If your traces are already in Snowflake, Databricks, BigQuery or ClickHouse, Kubit reads them there.
2. Name each step
A raw span name is often too vague to group on. If every model call is named chat, a run that classified intent and a run that wrote the final reply look like the same step. Name each step by what it did. A tool call is the tool name, and a model call is the task it was given or the decision it made.
Flows names steps this way from the action Polaris annotates each span with (Flows):
Span | Step name in Flows |
|---|---|
LLM call | The task named from its system prompt, such as |
Tool call | The tool name |
Anything else | The span name |
Keep repeated calls as separate steps. A run that calls search_orders three times in a row should show three search_orders steps, or you'll never see the loop. In Flows they stay separate by default, and the Fold label adjustment merges consecutive spans with one label into one step when you want the shorter view.
3. Group runs by path and count them
Reduce each run to its list of step names in start-time order, then group the runs that share a list. Sort the groups by count. In an illustrative week, a path that 1,200 runs took goes ahead of one that 40 runs took, whoever reported the second one.
Flows draws every path in one Sankey, with the number of traces that took each path. When two runs call the same tools with different arguments, Polaris labels or your eval scores may split them into separate paths, so a run that passed the wrong parameter doesn't hide inside the path of runs that passed the right one.
4. Find the paths that end in an Exception or a Misstep
Now sort the paths by how they end. Two endings matter here, an Exception, where a call failed with a 4xx or 5xx response or a timeout and shows in your error logs, and a Misstep, where the call ran, often with an OK status, and still did the wrong thing, such as wrong_tool or malformed_args. Missteps are why counting paths pays off, because nothing in the span records them. In an illustrative week, a path that ends in a Misstep 300 times looks green in every one of those 300 traces.
Polaris labels and scores every span, and Flows names a failing step after its Exception or Misstep label, so you see where in the path it went wrong. In Activity, the Labels column lists each trace's labels. In a trace, open a span's Polaris tab and click Yes or No to confirm or reject a label, and your verdicts tune that label's threshold. Find Missteps that return OK walks through it, and Misstep vs Exception explains the two labels in full.
5. Compare paths before and after a model upgrade or commit
Take the path counts for the week before a change and the week after, and line them up. Look first for a path that's new since the change, then for a failing path whose share of runs went up.
Triggers compares a metric before and after a model upgrade, or across user segments, and shows when it changes. The docs' example question is "did the Misstep rate on book_appointment go up after the model upgrade?" (Triggers). To get from the change to the code, the /kubit-blame skill in Claude Code or Cursor maps the names and prompts in the traces to files in your repo and returns the top 5 suspect commits in that window (Find what changed before a pattern started).
6. Join paths to what users did next
A path that ends in a confident reply can still lose the user. They ask the same question again, or open a support ticket an hour later. To see that, join each run to the user's events after it, on the same user ID.
Kubit tracks four fixed subjects, User, Session, Trace and Span, and treats a span as the base event for analytics, the same as a clickstream event (Concepts). Put the same User ID on your spans that your product analytics events use, so agent runs join to user behavior (Kubit SDK for Python). Product Analytics reports then join runs to what users did next, such as a funnel of agent runs or retention after a user's first session (Agent Analytics overview).
What should you look for in agent trajectories?

Loops. The same tool called back to back, such as three
search_orderssteps in a row. A loop that ends well still costs tokens on every run. Polaris labels loops as a Warning, such asloop_detectedorrepeated_tool_callSkipped tools. A path that goes from the user's question straight to
replywithout the lookup your agent should make first, such asget_refund_policybefore a refund answer. Put the path you expected next to the paths that ran, and the missing step shows as its own branch. The built-in Right tools eval also checks whether the tools the agent invoked were the right ones for the requestLong tails. A few paths take most runs, then dozens of paths are taken once or twice each. A single path taken once is seldom worth a ticket, and a tail that gets longer after a commit tells you the agent is improvising more often
New paths after a change. A path with no runs last week and hundreds this week came from something you shipped. Start step 5 there
How does Flows do agent trajectory analysis?
Flows groups every agent run by its execution path and draws all paths in one Sankey, with a count per path. Each step takes its name from the label Polaris gave its span, so a Misstep shows up on the step where it happened and a loop on search_orders shows as three steps. Polaris labels and scores every span in under 100ms, with no additional LLM cost or sampling, so the counts cover every run. Polaris is up to 98% lower cost and ~15x faster than a frontier LLM judge, with comparable accuracy on public agent benchmarks.
Other tools group runs by other keys, and grouping by what the user wanted is a good way to see what people come to an agent for. Arize's trace-pattern cookbook groups runs by a one-sentence summary of what the user wanted and how it ended. It doesn't group them by the path they took (Arize cookbook).
Book a demo to see your own agent runs grouped by path in Flows, with a count on every path.
Read next: Why we group agent runs by the shape of their execution path · How to choose an agent analytics tool · Misstep vs Exception
FAQ
How do you do agent trajectory analysis?
Group your agent's runs by the execution path each one took and count how many runs took each path. In practice that's six steps: get your traces in one place, name each step, group runs by path with a count, find the paths that end in an Exception or a Misstep, compare paths before and after a model upgrade or commit, and join paths to what users did next.
What is an agent trajectory?
An agent trajectory, also called an execution path, is the ordered steps of one run (which tools and model calls ran, in what order). Two runs that called search_orders, then get_refund_policy, then the LLM, share one path even if their inputs differ.
What's the difference between trajectory analysis and trajectory evaluation?
Trajectory evaluation checks one run against an expected trajectory, or asks an LLM to judge it, as LangChain's agentevals package does. Trajectory analysis counts how many production runs took each execution path, including paths nobody predicted, so you can rank failures by how often they happen.
How do you find agent loops in traces?
Keep repeated calls as separate steps when you build each run's path, so a run that calls search_orders three times in a row shows three search_orders steps. Then count the runs on each path that repeats a step. Kubit's Polaris labels loops as a Warning, such as loop_detected.
How do you compare agent behavior before and after a model upgrade?
Line up the path counts for the week before and the week after, and look for new paths and for failing paths whose share of runs went up. In Kubit, Triggers compares a metric such as the Misstep rate before and after a model upgrade, and the /kubit-blame skill ranks the commits most likely to have caused a change.






