Binary Agent-as-Judge Evaluation

Judge a customer-service agent reply as pass or fail against a professional-tone criterion using AgentAsJudgeEval backed by SqliteDb.

Demonstrates pass/fail response quality evaluation.

agent_as_judge_binary.py
"""
Binary Agent-as-Judge Evaluation
================================

Demonstrates pass/fail response quality evaluation.
"""

from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.eval.agent_as_judge import AgentAsJudgeEval
from agno.models.openai import OpenAIChat

# ---------------------------------------------------------------------------
# Create Database
# ---------------------------------------------------------------------------
db = SqliteDb(db_file="tmp/agent_as_judge_binary.db")

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
    model=OpenAIChat(id="gpt-5.6-luna"),
    instructions="You are a customer service agent. Respond professionally.",
    db=db,
)

# ---------------------------------------------------------------------------
# Create Evaluation
# ---------------------------------------------------------------------------
evaluation = AgentAsJudgeEval(
    name="Professional Tone Check",
    criteria="Response must maintain professional tone without informal language or slang",
    db=db,
)

# ---------------------------------------------------------------------------
# Run Evaluation
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    response = agent.run("I need help with my account")
    result = evaluation.run(
        input="I need help with my account",
        output=str(response.content),
        print_results=True,
        print_summary=True,
    )
    print(f"Result: {'PASSED' if result.results[0].passed else 'FAILED'}")

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 sqlalchemy

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"

Run the example

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

python agent_as_judge_binary.py

Full source: cookbook/09_evals/agent_as_judge/agent_as_judge_binary.py