Skip to main content
Agent as Judge evaluations let you define custom quality criteria and use an LLM to score your Agent’s responses. You provide evaluation criteria (like “professional tone”, “factual accuracy”, or “user-friendliness”), and an evaluator model assesses how well the Agent’s output meets those standards.

Basic Example

Here, AgentAsJudgeEval takes the Agent’s input and output and scores the response against the criteria you set.
agent_as_judge.py

Custom Evaluator Agent

You can use a custom agent to evaluate responses with specific instructions:
agent_as_judge_custom_evaluator.py

Params

ParameterTypeDefaultDescription
criteriastr""The evaluation criteria describing what makes a good response (required).
scoring_strategyLiteral["numeric", "binary"]"binary"Scoring mode: "numeric" (1-10 scale) or "binary" (pass/fail).
thresholdint7Minimum score to pass (only used for numeric strategy).
on_failOptional[Callable]NoneCallback function triggered when evaluation fails.
additional_guidelinesOptional[Union[str, List[str]]]NoneExtra evaluation guidelines beyond the main criteria.
nameOptional[str]NoneName for the evaluation.
modelOptional[Model]NoneModel to use for judging (defaults to gpt-5-mini if not provided).
evaluator_agentOptional[Agent]NoneCustom agent to use as evaluator.
print_summaryboolFalsePrint summary of evaluation results.
print_resultsboolFalsePrint detailed evaluation results.
show_spinnerboolTrueShow a progress spinner while the eval runs.
file_path_to_save_resultsOptional[str]NoneFile path to save evaluation results.
debug_modeboolFalseEnable debug mode for detailed logging.
dbOptional[Union[BaseDb, AsyncBaseDb]]NoneDatabase to store evaluation results.
telemetryboolTrueEnable telemetry.
run_in_backgroundboolFalseRun evaluation as background task (non-blocking).

Methods

run() / arun()

Run the evaluation synchronously (run()) or asynchronously (arun()).
ParameterTypeDefaultDescription
inputOptional[str]NoneInput text for single evaluation.
outputOptional[str]NoneOutput text for single evaluation.
casesOptional[List[Dict[str, str]]]NoneList of input/output pairs for batch evaluation.
print_summaryboolFalsePrint summary of evaluation results.
print_resultsboolFalsePrint detailed evaluation results.
Provide either (input, output) for single evaluation OR cases for batch evaluation, not both.

Run in a Suite

To gate many judge checks in CI, declare a Case per input with criteria and run them as a suite. judge_mode and judge_threshold on the Case map to scoring_strategy and threshold here, with the same defaults. See Eval Suites.

Examples

Basic Agent as Judge

Basic usage with numeric scoring and failure callbacks

Agent as Judge as Post-Hook

Automatic evaluation after agent runs

Developer Resources