Evaluators API Reference¶
Check that the reply contains expected substrings or matches regex patterns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
any_of
|
list[str]
|
Reply must contain at least one of these strings. |
list()
|
all_of
|
list[str]
|
Reply must contain every one of these strings. |
list()
|
matches_any
|
list[str]
|
Reply must match at least one of these regex patterns ( |
list()
|
matches_all
|
list[str]
|
Reply must match every one of these regex patterns ( |
list()
|
case_sensitive
|
bool
|
When False (the default), substring and regex checks ignore case. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If a regex pattern in matches_any/matches_all does not compile. |
Example
Source code in src/pytest_agent_eval/evaluators/contains.py
__post_init__() -> None
¶
Validate every pattern at construction time.
Source code in src/pytest_agent_eval/evaluators/contains.py
evaluate(ctx: TurnContext) -> EvalResult
async
¶
Evaluate substring and regex checks against the reply.
Source code in src/pytest_agent_eval/evaluators/contains.py
Validate that specific tools were (or were not) called.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
must_include
|
list[str]
|
Tool names that must appear in tool_calls. |
list()
|
must_exclude
|
list[str]
|
Tool names that must NOT appear in tool_calls. |
list()
|
ordered
|
bool
|
If True, must_include tools must appear in the given order. |
False
|
Example
Source code in src/pytest_agent_eval/evaluators/tool_call.py
evaluate(ctx: TurnContext) -> EvalResult
async
¶
Evaluate tool call presence and ordering.
Source code in src/pytest_agent_eval/evaluators/tool_call.py
Assert the arguments a tool was called with.
When the tool was called more than once in a turn, the check passes if ANY of those calls matches the expected arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool
|
str
|
Name of the tool to check. |
required |
args
|
JsonMapping
|
Expected arguments. |
required |
mode
|
ToolCallArgsMode
|
|
'subset'
|
Example
Source code in src/pytest_agent_eval/evaluators/tool_call.py
__post_init__() -> None
¶
Reject an unknown comparison mode at construction time.
Source code in src/pytest_agent_eval/evaluators/tool_call.py
evaluate(ctx: TurnContext) -> EvalResult
async
¶
Evaluate the expected arguments against every call of the tool this turn.
Source code in src/pytest_agent_eval/evaluators/tool_call.py
Bases: _JudgeEvaluatorBase
Use an LLM to evaluate a tool's call arguments against a rubric.
Deterministic short-circuits run before any LLM call: if the tool was never called, or was called but no arguments were captured, the evaluator fails with a precise message and no judge tokens are spent. Otherwise the judge receives the tool name and the JSON arguments of every call to it this turn, and passes if any call satisfies the rubric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool
|
str
|
Name of the tool whose arguments to judge. |
required |
rubric
|
str
|
Natural language rubric describing acceptable arguments. |
required |
model
|
str | Model | None
|
pydantic-ai model string (e.g. |
None
|
retries
|
int
|
Number of retry attempts on API failure before returning a FAIL verdict. |
2
|
timeout
|
float
|
Seconds before the judge call times out. |
30.0
|
Example
Source code in src/pytest_agent_eval/evaluators/judge.py
evaluate(ctx: TurnContext) -> EvalResult
async
¶
Judge the tool's captured arguments, short-circuiting when there is nothing to judge.
Source code in src/pytest_agent_eval/evaluators/judge.py
Bases: _JudgeEvaluatorBase
Use an LLM to evaluate the reply against a rubric.
Uses pydantic-ai under the hood; supports any pydantic-ai compatible model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rubric
|
str
|
Natural language rubric describing what a passing reply looks like. |
required |
model
|
str | Model | None
|
pydantic-ai model string (e.g. |
None
|
retries
|
int
|
Number of retry attempts on API failure before returning a FAIL verdict. |
2
|
timeout
|
float
|
Seconds before the judge call times out. |
30.0
|
Example
Source code in src/pytest_agent_eval/evaluators/judge.py
evaluate(ctx: TurnContext) -> EvalResult
async
¶
Run the LLM judge against the turn and return its verdict.