Skip to main content
Assertions are the building blocks of apastra evaluations. You can attach them inline to dataset cases or quick eval files — no separate evaluator file required for simple checks.
Each assertion has a type and an optional value. When you run an eval, the agent applies every assertion in the assert array to the model output for that case and records pass (1) or fail (0).

Deterministic assertions

Deterministic assertions run without calling a model. They are fast, free, and should be your first line of defense.
is-json and contains-json do not require a value field. The dataset-case schema marks value as required on the assertion object, but for these two types you can omit it or pass null.

Examples


Model-assisted assertions

Model-assisted assertions use a judge model to evaluate output quality when deterministic checks are not sufficient (tone, coherence, factual accuracy, relevance).

similar threshold

For similar, include a threshold field alongside value:
A threshold of 0.8 means the output must be at least 80% semantically similar to the reference. Lower thresholds allow more variation.

Writing good rubrics for llm-rubric

When using llm-rubric, specificity matters:
Vague rubrics (“Is the output good?”) produce unreliable scores. Ask for binary or numeric scales, and version your rubrics — changing rubric text changes what the metric means.

Examples


Performance assertions

Performance assertions check system-level properties rather than output content.

Examples

Use latency and cost assertions in release-candidate suites to enforce SLAs before shipping a prompt to production.

Negation

Any assertion type can be negated by prepending not- to the type name. The result is inverted: the assertion passes when the original assertion would fail.

Examples


Assertion precedence

If a suite references evaluator files AND dataset cases contain inline assert blocks, both apply. They are additive:
  • Evaluator files are per-suite — they score every case in the suite.
  • Inline assert blocks are per-case — they score only that specific case.
The case’s assert_pass_rate = (assertions passed) / (total assertions in the assert array). This is reported separately from evaluator metric scores.

Quick eval assertions

In a quick eval file, assertions are embedded directly in each case:

Decision table

Use this table to choose the right assertion for what you want to check.

Assertion type pattern

The dataset-case schema validates assertion types against this pattern:
Any type not matching this pattern will fail schema validation.