Skip to content

Commit 206f34b

Browse files
committed
feat: add uipath trace CLI command for trajectory visualization
Add a new `uipath trace` command that reads JSONL trace files (from `uipath run --trace-file` or `uipath eval --trace-file`) and eval verbose JSON output, rendering a Rich span tree showing the agent's execution trajectory. Features: - Span tree with timing, status icons, and smart labels (LLM/tool/generic) - Key attributes displayed by default (input, output, tokens, model name) - `--full` mode shows all attributes with no truncation - `--no-input`/`--no-output` for structural overview - `--name` filter prunes the tree to matching spans + ancestors - `--contains` extracts full subtrees where any descendant matches, useful for finding specific eval runs across a trace file - `--span-type` and `--status` filters - `--eval-id` to pick a specific evaluation from verbose JSON output - Auto-detects JSONL vs eval JSON format Includes 66 tests covering loading, tree building, filtering, rendering, and CLI integration.
1 parent 3b4cba5 commit 206f34b

13 files changed

Lines changed: 1517 additions & 1 deletion

File tree

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This [quickstart guide](https://uipath.github.io/uipath-python/) walks you throu
2626
- [Authentication](#authentication)
2727
- [Initialize a Project](#initialize-a-project)
2828
- [Debug a Project](#debug-a-project)
29+
- [Visualize Traces](#visualize-traces)
2930
- [Package a Project](#package-a-project)
3031
- [Publish a Package](#publish-a-package)
3132
- [Project Structure](#project-structure)
@@ -155,6 +156,18 @@ uipath run ENTRYPOINT [INPUT]
155156

156157
Executes a Python script with the provided JSON input arguments.
157158

159+
### Visualize Traces
160+
161+
```bash
162+
# Capture a trace
163+
uipath run main '{"query": "hello"}' --trace-file traces.jsonl
164+
165+
# Visualize the agent trajectory
166+
uipath trace traces.jsonl
167+
```
168+
169+
Renders a tree view of the agent's execution showing tool calls, LLM invocations, inputs/outputs, and timing. Also works with eval traces (`uipath eval --trace-file`) — use `--contains "function_name"` to find specific runs across an eval set.
170+
158171
### Package a Project
159172

160173
```bash

packages/uipath/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This [quickstart guide](https://uipath.github.io/uipath-python/) walks you throu
2626
- [Authentication](#authentication)
2727
- [Initialize a Project](#initialize-a-project)
2828
- [Debug a Project](#debug-a-project)
29+
- [Visualize Traces](#visualize-traces)
2930
- [Package a Project](#package-a-project)
3031
- [Publish a Package](#publish-a-package)
3132
- [Project Structure](#project-structure)
@@ -155,6 +156,18 @@ uipath run ENTRYPOINT [INPUT]
155156

156157
Executes a Python script with the provided JSON input arguments.
157158

159+
### Visualize Traces
160+
161+
```bash
162+
# Capture a trace
163+
uipath run main '{"query": "hello"}' --trace-file traces.jsonl
164+
165+
# Visualize the agent trajectory
166+
uipath trace traces.jsonl
167+
```
168+
169+
Renders a tree view of the agent's execution showing tool calls, LLM invocations, inputs/outputs, and timing. Also works with eval traces (`uipath eval --trace-file`) — use `--contains "function_name"` to find specific runs across an eval set.
170+
158171
### Package a Project
159172

160173
```bash

packages/uipath/docs/cli/index.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,43 @@ uipath run agent '{\"topic\":\"uipath\"}'
143143
```
144144
---
145145

146+
::: mkdocs-click
147+
:module: uipath._cli
148+
:command: trace
149+
:depth: 1
150+
:style: table
151+
152+
Visualize an agent execution trace. Reads JSONL trace files produced by `uipath run --trace-file` or `uipath eval --trace-file`, and renders a span tree showing the agent's trajectory.
153+
154+
<!-- termynal -->
155+
156+
```shell
157+
> uipath trace traces.jsonl
158+
Trace abcdef12…34567890
159+
└── agent (12.5s) ✓
160+
├── input: {"messages": [{"role": "user", "content": "Book a flight..."}]}
161+
├── LLM (gpt-4o) (2.2s) ✓
162+
│ └── tokens: prompt=847, completion=156, total=1003
163+
├── 🔧 search_flights (1.7s) ✓
164+
│ ├── input: {"origin": "SFO", "destination": "NRT"}
165+
│ └── output: {"flights": [...]}
166+
├── LLM (gpt-4o) (1.8s) ✓
167+
│ └── tokens: prompt=1456, completion=203, total=1659
168+
└── 🔧 book_flight (1.2s) ✓
169+
└── output: {"confirmation": {"booking_ref": "BK-UA837"}}
170+
9 spans total
171+
```
172+
173+
/// tip
174+
Use `--contains` to search across eval traces and extract full agent trajectories where a specific function was called:
175+
```console
176+
uipath eval main eval-set.json --trace-file traces.jsonl
177+
uipath trace traces.jsonl --contains "get_random*"
178+
```
179+
///
180+
181+
---
182+
146183
::: mkdocs-click
147184
:module: uipath._cli
148185
:command: pack

packages/uipath/src/uipath/_cli/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"server": "cli_server",
4646
"register": "cli_register",
4747
"debug": "cli_debug",
48+
"trace": "cli_trace",
4849
"assets": "services.cli_assets",
4950
"buckets": "services.cli_buckets",
5051
"context-grounding": "services.cli_context_grounding",

0 commit comments

Comments
 (0)