Skip to main content
Assertions use a single entrypoint and an expressive catalog. Prefer structural checks for stability, and combine them with judges only when necessary.
Use one entrypoint:
Catalog source: catalog.py

Immediate vs deferred

  • Immediate: content and judge (given response)
  • Deferred (requires final metrics): tools, performance, path

Content

  • Expect.content.contains(text, case_sensitive=False)
  • Expect.content.not_contains(text, case_sensitive=False)
  • Expect.content.regex(pattern, case_sensitive=False)
Examples:

Tools

  • Expect.tools.was_called(name, min_times=1)
  • Expect.tools.called_with(name, {args})
  • Expect.tools.count(name, expected_count)
  • Expect.tools.success_rate(min_rate, tool_name=None)
  • Expect.tools.failed(name)
  • Expect.tools.output_matches(name, expected, field_path?, match_type?, case_sensitive?, call_index?)
  • Expect.tools.sequence([names], allow_other_calls=False)
Notes:
  • field_path supports nested dict/list access, e.g. content[0].text or content.0.text
Examples:

Performance

  • Expect.performance.max_iterations(n)
  • Expect.performance.response_time_under(ms)
Example:

Judge

  • Expect.judge.llm(rubric, min_score=0.8, include_input=False, require_reasoning=True)
  • Expect.judge.multi_criteria(criteria, aggregate_method="weighted", require_all_pass=False, include_confidence=True, use_cot=True, model=None)
Examples:

Path

  • Expect.path.efficiency(optimal_steps?, expected_tool_sequence?, allow_extra_steps=0, penalize_backtracking=True, penalize_repeated_tools=True, tool_usage_limits?, default_tool_limit=1)
Evaluators source: evaluators/

Examples

Tips

  • Prefer structural checks (output_matches) for tool outputs when possible for stability
  • Use name in assert_that(..., name="...") to label checks in reports
  • Combine judge + structural checks for high confidence
Combine a minimal judge (e.g., rubric with min_score=0.8) with one or two structural checks (like output_matches) for resilient tests.
Deferred assertions are evaluated when the session ends or when when="end" is used. If an assertion depends on final metrics (e.g., success rate), defer it.