Custom Evaluator Agent-as-Judge Evaluation
Score agent output with AgentAsJudgeEval using a strict custom evaluator_agent instead of the default judge.
Demonstrates using a custom evaluator agent for judging.
With a custom evaluator, place the criterion and rubric in that agent’s instructions. The outer criteria and additional_guidelines are not automatically added to its prompt. The framework supplies the scoring output schema and applies the threshold to the returned score.
"""
Custom Evaluator Agent-as-Judge Evaluation
==========================================
Demonstrates using a custom evaluator agent for judging.
"""
from agno.agent import Agent
from agno.eval.agent_as_judge import AgentAsJudgeEval
from agno.models.openai import OpenAIChat
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
model=OpenAIChat(id="gpt-5.6-luna"),
instructions="Explain technical concepts simply.",
)
# ---------------------------------------------------------------------------
# Create Evaluator Agent
# ---------------------------------------------------------------------------
custom_evaluator = Agent(
model=OpenAIChat(id="gpt-5.6-luna"),
description="Strict technical evaluator",
instructions="You are a strict evaluator. Only give high scores to exceptionally clear and accurate explanations.",
)
# ---------------------------------------------------------------------------
# Create Evaluation
# ---------------------------------------------------------------------------
evaluation = AgentAsJudgeEval(
name="Technical Accuracy",
criteria="Explanation must be technically accurate and comprehensive",
scoring_strategy="numeric",
threshold=8,
evaluator_agent=custom_evaluator,
)
# ---------------------------------------------------------------------------
# Run Evaluation
# ---------------------------------------------------------------------------
if __name__ == "__main__":
response = agent.run("What is machine learning?")
result = evaluation.run(
input="What is machine learning?",
output=str(response.content),
print_results=True,
)
print(f"Score: {result.results[0].score}/10")
print(f"Passed: {result.results[0].passed}")Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno openaiExport your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"Give the custom judge its criterion
Immediately after creating custom_evaluator and before constructing evaluation, set:
custom_evaluator.instructions = [
"You are a strict technical evaluator.",
"Explanation must be technically accurate and comprehensive",
"Only give high scores to exceptionally clear and accurate explanations.",
"Return an integer score from 1 to 10 and explain the score: "
"1 is incorrect or irrelevant, 5 is partly correct with material gaps, "
"8 is accurate and comprehensive, and 10 is exceptionally clear and complete.",
]Run the example
Save the code above as agent_as_judge_custom_evaluator.py, then run:
python agent_as_judge_custom_evaluator.pyFull source: cookbook/09_evals/agent_as_judge/agent_as_judge_custom_evaluator.py