Skip to main content
The AgentJudge evaluates and critiques outputs from other AI agents, providing structured feedback on quality, accuracy, and areas for improvement. It supports single-shot evaluations and iterative refinement through multiple evaluation loops with context building. Based on the research paper: Agent-as-a-Judge: Evaluate Agents with Agents

Architecture

Parameters

The constructor raises ValueError when max_loops is 0 or None, or when model_name is None.

Methods

step()

Processes a single task and returns the agent’s evaluation. task is the output to evaluate. It is wrapped in an evaluation prompt that asks for strengths, weaknesses, suggestions and factual errors. messages are earlier chat turns sent before it.

run()

Executes evaluation in multiple iterations with context building. Each iteration sends the judge’s earlier verdicts back to it as chat turns, so later iterations refine earlier ones.
Returns str (the judge’s conversation as text) if return_score=False, or int if return_score=True. With return_score=True, the int is 1 when the conversation text contains “correct”, “good”, “excellent” or “perfect” (case-insensitive), and 0 otherwise. The conversation includes the task you passed in, so a task that contains one of those words always scores 1.

run_batched()

Calls run() on each task in order.
step() and run() raise AgentJudgeExecutionError when evaluation fails.
judge.conversation is not cleared between calls. Each run() result, including each run_batched() result, contains every earlier task and verdict from the same judge, and later evaluations see them as context. Create a new AgentJudge for each independent evaluation.

Examples

Basic Evaluation

Custom Evaluation Criteria

Scoring Mode

Batch Processing

Reference