Comparison Accuracy Evaluation
Score an agent that must use CalculatorTools to answer whether 9.11 or 9.9 is bigger, with an o4-mini judge.
Demonstrates accuracy evaluation for numeric comparison tasks.
"""
Comparison Accuracy Evaluation
==============================
Demonstrates accuracy evaluation for numeric comparison tasks.
"""
from typing import Optional
from agno.agent import Agent
from agno.eval.accuracy import AccuracyEval, AccuracyResult
from agno.models.openai import OpenAIChat
from agno.tools.calculator import CalculatorTools
# ---------------------------------------------------------------------------
# Create Evaluation
# ---------------------------------------------------------------------------
evaluation = AccuracyEval(
name="Comparison Evaluation",
model=OpenAIChat(id="o4-mini"),
agent=Agent(
model=OpenAIChat(id="gpt-5.6-luna"),
tools=[CalculatorTools()],
instructions="You must use the calculator tools for comparisons.",
),
input="9.11 and 9.9 -- which is bigger?",
expected_output="9.9",
additional_guidelines="Its ok for the output to include additional text or information relevant to the comparison.",
)
# ---------------------------------------------------------------------------
# Run Evaluation
# ---------------------------------------------------------------------------
if __name__ == "__main__":
result: Optional[AccuracyResult] = evaluation.run(print_results=True)
assert result is not None and result.avg_score >= 8Run 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"Run the example
Save the code above as accuracy_9_11_bigger_or_9_99.py, then run:
python accuracy_9_11_bigger_or_9_99.pyFull source: cookbook/09_evals/accuracy/accuracy_9_11_bigger_or_9_99.py