Team Post-Hook Agent-as-Judge Evaluation

Register AgentAsJudgeEval in Team.post_hooks to score final-response quality automatically after each team run.

Demonstrates a post-hook judge running on team responses.

The hook judges the Team’s input and final content. It does not pass member traces or tool executions to the judge, so the source criterion about collaboration cannot verify how members worked together. The Researcher also has no retrieval tools; this example does not independently verify research or factual claims.

agent_as_judge_team_post_hook.py
"""
Team Post-Hook Agent-as-Judge Evaluation
========================================

Demonstrates a post-hook judge running on team responses.
"""

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
from agno.team.team import Team

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

# ---------------------------------------------------------------------------
# Create Team and Evaluation Hook
# ---------------------------------------------------------------------------
agent_as_judge_eval = AgentAsJudgeEval(
    name="Team Response Quality",
    model=OpenAIChat(id="gpt-5.2"),
    criteria="Response should be well-researched, clear, comprehensive, and show good collaboration between team members",
    scoring_strategy="numeric",
    threshold=7,
    db=db,
)
researcher = Agent(
    name="Researcher",
    role="Research and gather information",
    model=OpenAIChat(id="gpt-5.6-luna"),
)
writer = Agent(
    name="Writer",
    role="Write clear and concise summaries",
    model=OpenAIChat(id="gpt-5.6-luna"),
)
research_team = Team(
    name="Research Team",
    model=OpenAIChat("gpt-5.6-luna"),
    members=[researcher, writer],
    instructions=["First research the topic thoroughly, then write a clear summary."],
    post_hooks=[agent_as_judge_eval],
    db=db,
)

# ---------------------------------------------------------------------------
# Run Evaluation
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    response = research_team.run("Explain quantum computing")
    print(response.content)

    print("Evaluation Results:")
    eval_runs = db.get_eval_runs()
    if eval_runs:
        latest = eval_runs[0]
        if latest.eval_data and "results" in latest.eval_data:
            result = latest.eval_data["results"][0]
            print(f"Score: {result.get('score', 'N/A')}/10")
            print(f"Status: {'PASSED' if result.get('passed') else 'FAILED'}")
            print(f"Reason: {result.get('reason', 'N/A')[:200]}...")

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_team_post_hook.py, then run:

python agent_as_judge_team_post_hook.py

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