Skip to main content
These methods query traces and list the runs inside a trace. For deprecation dates, minimum SDK versions, and the agent prompt that applies to every method, see Migrate to SmithDB-backed APIs.

Traces: query

Returns a list of traces (root runs) for a single tracing project. Each item carries the trace’s root run plus optional trace-wide aggregates (total_tokens, total_cost, first_token_time) under trace_aggregates, so clients never have to merge by trace_id. Traces are scanned within a start_time window: min_start_time defaults to 24 hours before the request, max_start_time defaults to the request time. Set either explicitly to widen or narrow the window. Supports filters (trace_filter, tree_filter) and field projection (selects).

Main changes

Method name

client.traces.query() is async and returns a paginator. Iterate it with async for to get individual traces across all pages, or await it to get the first page.
See the reference for the full parameter and field list.

Query parameters

  • session (a list of project UUIDs) becomes project_id, a single UUID; traces.query scopes to exactly one project per call.
  • is_root is removed: traces.query is always scoped to root runs implicitly.
  • The generic filter (evaluated against any run) has no direct equivalent; use trace_filter or tree_filter instead.
  • trace_filter and tree_filter carry over unchanged; both already existed on list_runs.
  • trace_ids is new: a fast-path restriction to a known set of trace UUIDs, more efficient at scale than an equivalent trace_filter.
  • start_time (no default) becomes min_start_time, which defaults to 24 hours ago when omitted.
  • max_start_time is new, defaulting to the request time; list_runs’s end_time filtered by a run’s own end timestamp, not a scan-window bound.
  • select is renamed selects; entries route to trace_aggregates (total_tokens, total_cost, first_token_time) or root_run (everything else).

Response fields

  • root_run carries the same Run shape as Runs: query (id, name, run_type, status, and so on), gated by selects.
  • total_tokens/total_cost move off root_run onto trace_aggregates, summed across every run in the trace instead of just the root run. trace_aggregates is omitted entirely from the response when no aggregate field was selected.
  • trace_aggregates.first_token_time is new

Examples

List traces (root runs)

Fetch every trace (root run) in a project, replacing list_runs(is_root=True).
Before

Get a trace’s total tokens and cost

Read a trace’s token and cost totals from trace_aggregates instead of the root run, where v1 kept them.
Before

Find traces by status, or fetch traces by ID

Filter traces by status (for example, errored) with trace_filter, or skip filtering and fetch known traces directly and faster with trace_ids.
Before

Traces: list runs

Returns runs for a trace ID within min/max start time. Optional filter; repeatable selects to select fields to return.

Main changes

Method name

client.traces.list_runs() is now async. Call it with await.
See the reference for the full parameter and field list.

Query parameters

  • trace_id/trace moves from a query param to a path param.
  • project_id is new and required (the SmithDB partition key); list_runs(trace_id=...) did not need it.
  • filter is unchanged.
  • min_start_time/max_start_time are new. Unlike traces.query, neither has a default: omit both and runs are not filtered by time at all. They are individually optional but must be passed together if either is set.
  • select is renamed selects, using the same 44-value enum as traces.query.

Response fields

The response has a single items field: a list of Run objects in start_time order, same shape as the Runs: query response.

Examples

List every run in a trace

Fetch all the runs that belong to one trace, given its trace ID.
Before

Get only the LLM calls in a trace

Narrow a trace’s runs down to a specific run type, for example just the LLM calls.
Before

See also