Filter arguments
Performance tip: Passing the
select parameter and excluding inputs and outputs from the list can significantly improve query performance and reduce response sizes, especially for large runs.Filter query language
LangSmith supports filtering capabilities with a filter query language to permit complex filtering operations when fetching runs. This is especially useful when querying traces programmatically via the SDK or API. For example, in evaluation pipelines, monitoring scripts, or agentic workflows that inspect prior traces.Comparators
The filtering grammar is based on comparator functions applied to fields of the run object:Logical operators
Useand and or to combine multiple comparators:
Filterable fields
Value formatting
- Strings: wrap in double or single quotes,
eq(name, "MyChain")oreq(name, 'MyChain'). - Timestamps: ISO 8601 format,
"2024-06-01T00:00:00Z". - Durations: seconds, as either a number or a string with the
ssuffix,"5s","1.5s","90s", or1.5. Other unit suffixes (m,h) are not supported. - Lists: JSON array syntax,
["session_id", "thread_id"].
Quick reference examples
The following examples show the filter string only. Pass the string as thefilter, trace_filter, or tree_filter argument in client.list_runs() or the /runs/query API endpoint.
Filter by run name
Filter by error status
Filter by latency
Filter by time range
Filter by tags
Filter by metadata key or value
Filter by thread ID
Filter by feedback score
Full-text search across all string fields
Combining conditions
Using trace_filter and tree_filter
filter applies to the returned run. trace_filter applies to the root run of the trace. tree_filter applies to any run anywhere in the trace tree.
tree_filter applies the same query syntax to runs anywhere in the trace tree. For predicates over arbitrary nested child-run fields, such as returned inputs, outputs, or extra payload paths, first narrow candidates with server-side filters, then hydrate root traces with child runs and traverse them locally. See Query trace trees with child-run predicates.Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

