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:Wildcard pattern matching
like and notlike match a field value against a pattern. How the pattern applies depends on the field:
name,metadata_key, andmetadata_value:%matches any sequence of characters, including none. Matching is case-sensitive. Without%,likematches only the exact value, the same aseq.inputs,outputs, anderror: Matching is case-insensitive and always matches a substring, so%is optional. LangSmith can match each word of the pattern separately rather than as a phrase, so do not rely onliketo match an exact phrase in these fields.
like(metadata_value, "%prod%")matches any value that containsprod, such asproductionoreu-prod-1.notlike(metadata_value, "%staging%")matches any value that does not containstaging.
like and notlike filters. To translate a search bar query, refer to the UI-to-API operator map.
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"].
UI-to-API operator map
The search bar in the LangSmith UI uses its own syntax, documented in Filter traces. The following table maps each search bar operator to the comparator that does the same job in this language:Alert filters
Alert rules accept the same filter query language in theirfilter and denominator_filter fields:
filter: Selects the runs that count toward the alert.denominator_filter: Selects the baseline population for a percentage-based alert. When it is empty, every run counts toward the baseline.
and. Combining conditions with or is not supported.
Example alert filter that matches runs whose env metadata value does not contain staging:
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 your agent of choice via MCP for real-time answers.

