Skip to main content
Assertions turn English-language standards into an automated check. They are short, free-form claims about what a correct answer should or should not include. LangSmith Engine proposes assertions for the traces behind a recurring production issue. You review and edit them in a single-run annotation queue, and LangSmith saves them on a dataset example. Any offline evaluator can then check whether new outputs from your application satisfy each claim. When a run’s output is wrong, assertions let you describe a correct answer instead of writing one by hand.
The Assertions section appears only on run items that LangSmith Engine proposed as offline examples. It does not appear on other runs, on thread items, or in pairwise queues. Assertions are available in the LangSmith UI only.

Review proposed assertions

To review and save the assertions Engine proposes:
  1. On an Engine issue, click Engine proposed N examples, then click Edit in annotation queue. For details, see Add offline examples.
  2. In the annotation queue, find the Assertions section in the side panel. Engine fills it with its proposed assertions, and the run shows a Proposed by Engine banner.
  3. Edit each assertion’s key, a short summary of the claim (for example, must_cite_source or must_not_invent_url), and its one-sentence comment describing the claim. The key is free-form. The must_ and must_not_ prefixes are a naming convention. LangSmith does not treat them specially.
  4. (Optional) Click + Add to add an assertion, or click the delete icon on a row to remove it. While the run has assertions, LangSmith replaces the run’s outputs with a read-only preview of the assertions, labeled as reference outputs. This preview is what gets saved to the dataset. The run’s actual output is not saved, because assertions describe what a correct answer should include, not what this run produced. To edit the run’s Inputs before you save the example, such as to refine the prompt, enable Classic Trace View for the queue. The outputs stay locked to the assertion preview while any assertions remain.
  5. Click Add to Dataset & Next in the side panel footer (keyboard shortcut: ⌘ Enter on macOS or Ctrl Enter elsewhere). LangSmith adds the current run to the queue’s default dataset, or prompts you to pick one if no default is configured. The queue then moves you to the next run.
The saved example’s outputs field is stored as JSON. For example:
The example’s inputs field stores the run’s inputs, or your edited version if you changed them. See Example data format for the full shape of a saved example.

Evaluate against assertions

Write an offline evaluator that reads the saved assertions from reference_outputs["assertions"] and returns one feedback score per assertion. The minimal shape:
How you score each claim is up to you. Three patterns are common and can be combined in a single evaluator:
  • LLM-as-a-judge: For each assertion, prompt a model with the application’s output and the assertion’s comment, and have it return a score. Best when claims are subjective or hard to verify mechanically.
  • Code-based checks: For each assertion, run a deterministic check keyed off the assertion’s key, such as a regex match, schema validation, or substring presence. Best when the claim has a crisp, mechanical answer.
  • Partial-credit scoring: Return a numeric score (for example, between 0.0 and 1.0) instead of a boolean to grade on a scale and give “partial credit” to outputs that fulfill some, but not all, claims.