Context
When using the LangSmith SDK to filter runs by name, you may find that the exact match filter syntax doesn't work as expected, even though similar filtering works in the LangSmith web application. This typically occurs when trying to use the eq() operator to match run names exactly.
Answer
Instead of using the eq() operator for filtering by name, use the search() operator which is more reliable for name-based filtering in the LangSmith SDK.
Here's the correct syntax:
from langsmith import Client
client = Client()
all_traces = client.list_runs(
project_name="your-project-name",
limit=10,
filter='search("PARTIES extraction")'
# or filter='search(name, "PARTIES")'
)
for run in all_traces:
print(run.name)
You can use the search operator in two ways:
search("PARTIES extraction")- searches for the exact phrase across run propertiessearch(name, "PARTIES")- searches specifically within the name field for the specified term
For more information about filtering and exporting traces, refer to the LangSmith documentation.