Online evaluators extend trace retention by default. You can opt out for an individual evaluator when the agent environment uses base retention. Other actions can still extend those traces. If extended retention is disabled for the workspace, evaluations continue without new retention upgrades, regardless of saved environment defaults.
View online evaluators
Select your agent, go to Tracing, and select the environment. To view existing online evaluators for that environment, click the Online Evaluators tab.Configure online evaluators
1. Navigate to online evaluators
Select your agent, go to Tracing, and select the environment. Click the Online Evaluators tab, then click + Evaluator to open the Add Evaluator panel. Then choose one of the following:- Create from scratch: Select Code Evaluator.
- Attach an existing evaluator: Select a code evaluator already in your workspace to reuse it.
2. Name your evaluator
Provide a name for your evaluator. This name will be used when referencing the evaluator in your code, and will also be the name of the feedback that is generated by this evaluator.3. Create a filter
For example, you may want to apply specific evaluators based on:- Runs where a user left feedback indicating the response was unsatisfactory.
- Runs that invoke a specific tool call. See filtering for tool calls for more information.
- Runs that match a particular piece of metadata (e.g. if you log traces with a
plan_typeand only want to run evaluations on traces from your enterprise customers). See adding metadata to your traces for more information.
LangSmith has two filtering experiences, and the one you see can differ between pages. Check the filter controls on the page you are using to see which one applies:
- A search bar where you type a query, usually with a scope selector to its left: Refer to Filter traces.
- An Add filter button that builds filter chips: Refer to Filter traces (ClickHouse).
run["feedback"], or include extended stats to read it from run["feedback_stats"]. For example, to run when the answer_usefulness feedback exists, use feedback.answer_usefulness:* in the search bar or eq(feedback_key, "answer_usefulness") in the filter builder. The filter is based on the feedback key, not the evaluator that produced it, so feedback from any source with that key triggers the code evaluator. For more information, see Chain evaluators.
4. (Optional) Configure a sampling rate
Configure a sampling rate to control the percentage of filtered runs that trigger the automation action. For example, to control costs, you may want to set a filter to only apply the evaluator to 10% of traces. In order to do this, you would set the sampling rate to 0.1.5. (Optional) Apply rule to past runs
To apply the rule to past runs, expand Advanced, select Apply to past runs from date… under Backfill, then enter a date. This is only possible upon rule creation. Note: the backfill is processed as a background job, so you will not see the results immediately. To track the backfill’s progress, open the agent environment’s Online Evaluators tab on the Tracing page and click Logs in your evaluator’s row. Online evaluator logs are similar to automation rule logs.- Add an evaluator name
- Optionally filter runs that you would like to apply your evaluator on or configure a sampling rate.
- Select Apply Evaluator
Write your evaluation function
Code evaluators restrictions.Allowed Libraries: You can import all standard library functions, as well as the following public packages (versions are provided by the bundled Pyodide release):Network Access: You cannot access the internet from a code evaluator.To install other packages, make network requests, or authenticate with workspace secrets, use an advanced code evaluator. For more information, see Use advanced code evaluators.
- A
Run(reference). This represents the sampled run to evaluate.
LangSmith passes a dataset example as a second argument when you test the evaluator against a dataset sample and when the evaluator scores an experiment run. Otherwise, it passes only the run. To handle both cases in Python, define the function as
perform_eval(run, example=None). In a default code evaluator, a function that accepts only run fails with TypeError: perform_eval() takes 1 positional argument but 2 were given.- Feedback(s) Dictionary: A dictionary whose keys are the type of feedback you want to return, and values are the score you will give for that feedback key. For example,
{"correctness": 1, "silliness": 0}would create two types of feedback on the run, one saying it is correct, and the other saying it is not silly.
Test and save your evaluation function
Before saving, you can test your evaluator function on a recent run by clicking Test Code to make sure that your code executes properly. Once you Save, your online evaluator will run over newly sampled runs (or backfilled ones too if you chose the backfill option). If you prefer a video tutorial, check out the Online Evaluations video from the Introduction to LangSmith Course.Connect these docs to your agent of choice via MCP for real-time answers.

