Accuracy Evaluation with Custom Evaluator Agent

Score an agent's step-by-step calculator math against an expected answer using a custom evaluator agent with an AccuracyAgentResponse output schema.

Demonstrates accuracy evaluation using a custom evaluator agent.

A supplied evaluator_agent owns its model, instructions, and output schema. The outer AccuracyEval.model and additional_guidelines do not configure it. Apply the explicit judging instructions below before running this example.

evaluator_agent.py
"""
Accuracy Evaluation with Custom Evaluator Agent
================================================

Demonstrates accuracy evaluation using a custom evaluator agent.
"""

from typing import Optional

from agno.agent import Agent
from agno.eval.accuracy import AccuracyAgentResponse, AccuracyEval, AccuracyResult
from agno.models.openai import OpenAIChat
from agno.tools.calculator import CalculatorTools

# ---------------------------------------------------------------------------
# Create Evaluator Agent
# ---------------------------------------------------------------------------
evaluator_agent = Agent(
    model=OpenAIChat(id="gpt-5"),
    output_schema=AccuracyAgentResponse,
)

# ---------------------------------------------------------------------------
# Create Evaluation
# ---------------------------------------------------------------------------
evaluation = AccuracyEval(
    model=OpenAIChat(id="o4-mini"),
    agent=Agent(model=OpenAIChat(id="gpt-5.2"), tools=[CalculatorTools()]),
    input="What is 10*5 then to the power of 2? do it step by step",
    expected_output="2500",
    evaluator_agent=evaluator_agent,
    additional_guidelines="Agent output should include the steps and the final answer.",
)

# ---------------------------------------------------------------------------
# Run Evaluation
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    result: Optional[AccuracyResult] = evaluation.run(print_results=True)
    assert result is not None and result.avg_score >= 8

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno openai

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"

Configure the custom accuracy rubric

Replace the evaluator_agent = Agent(...) definition before constructing evaluation:

custom accuracy evaluator
evaluator_agent = Agent(
    model=OpenAIChat(id="gpt-5"),
    instructions=[
        "Compare the agent's output with the supplied expected output and input.",
        "Assign an integer accuracy score from 1 to 10: 1 is wholly incorrect, "
        "5 is partially correct, and 10 is fully correct and complete.",
        "Agent output should include the steps and the final answer.",
        "Explain any incorrect arithmetic, missing steps, or incorrect final answer.",
    ],
    output_schema=AccuracyAgentResponse,
)

Run the example

Save the code above as evaluator_agent.py, then run:

python evaluator_agent.py

Full source: cookbook/09_evals/accuracy/evaluator_agent.py