Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
ag2ai avatar

Ag2 Evaluation

  • 28 installs
  • 8 repo stars
  • Updated July 27, 2026
  • ag2ai/ag2-skills

ag2-evaluation is a Claude Code skill that evaluates, tests and tracks a single AG2 beta agent offline with a task suite and scorers.

About

ag2-evaluation is a Claude Code skill that evaluates, tests and tracks an AG2 beta agent offline. It builds a Suite of tasks, runs the agent with run_agent, and grades answers with prebuilt scorers or a custom scorer including an LLM judge. A developer uses it to score correctness, tool use, cost or quality, build a CI regression gate, or diff runs to catch regressions. For head-to-head or leaderboard comparison it points to ag2-eval-comparison.

  • Builds a Suite of tasks and grades an AG2 agent with run_agent and prebuilt or custom scorers
  • Gates results in CI with deterministic TestConfig cassettes that need no API key
  • Persists runs to diff for regressions and grades existing production traces

Ag2 Evaluation by the numbers

  • 28 all-time installs (skills.sh)
  • Ranked #1,361 of 2,153 Testing & QA skills by installs in the Skillselion catalog
  • Data as of Aug 1, 2026 (Skillselion catalog sync)
At a glance

ag2-evaluation capabilities & compatibility

Free skill; live runs need an LLM API key, but CI with TestConfig cassettes needs none.

Capabilities
agent evaluation · scoring · ci gate · regression detection · trace grading
Works with
openai
Use cases
testing · ci cd · orchestration
Pricing
Bring your own API key
From the docs

What ag2-evaluation says it does

Evaluate, test, and track an AG2 beta Agent offline.
SKILL.md
Swap the model for a `TestConfig` cassette (a canned reply per task) so CI is free and repeatable.
SKILL.md
npx skills add https://github.com/ag2ai/ag2-skills --skill ag2-evaluation

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs28
repo stars8
Last updatedJuly 27, 2026
Repositoryag2ai/ag2-skills

What it does

Evaluate, grade and CI-gate a single AG2 agent for correctness, tool use, cost or quality.

Who is it for?

Developers building a CI or regression gate for an AG2 agent, scoring correctness, tool use, cost or quality.

Skip if: Comparing two or more builds head-to-head or on a leaderboard, which is ag2-eval-comparison.

When should I use this skill?

The user wants to evaluate, test, grade or benchmark an agent or build a CI regression gate.

What you get

A scorecard with pass rates and stats, a deterministic CI gate, and regression diffs across runs.

By the numbers

  • 6 prebuilt scorers (final_answer_matches, tool_called, no_tool_errors, token_budget, failure_attribution, agent_judge)
  • 3 scorer return types map to 3 aggregations

Files

SKILL.mdMarkdownGitHub ↗

Evaluation — run, grade, and track an agent

When to use

  • Evaluate / test / benchmark an AG2 beta Agent, or build a regression / CI gate
  • Grade answers for correctness, tool use, cost, or subjective quality
  • Track a metric across versions (did this change help or regress?)

To compare two-plus builds head-to-head or on a leaderboard, use ag2-eval-comparison.

Install

pip install "ag2[openai,tracing]"

run_agent reconstructs each task's trace from OpenTelemetry spans, so the tracing extra is required. Run this install before delivering the code. If you cannot run commands, state the exact pip install command.

The loop — dataset, agent, scorers, run_agent

import asyncio
from autogen.beta import Agent
from autogen.beta.config import OpenAIConfig
from autogen.beta.eval import Suite, run_agent
from autogen.beta.eval.scorers import final_answer_matches

suite = Suite.from_list([
    {"task_id": "france", "inputs": {"input": "Capital of France?"}, "reference_outputs": {"answer": "Paris"}},
    {"task_id": "japan",  "inputs": {"input": "Capital of Japan?"},  "reference_outputs": {"answer": "Tokyo"}},
])
agent = Agent("geographer", prompt="Answer with the capital city.", config=OpenAIConfig(model="gpt-4o-mini"))

async def main():
    result = await run_agent(
        suite, agent=agent,
        scorers=[final_answer_matches(field="answer", matcher="contains")],
        store_dir="./runs",
    )
    print(result.summary())                            # the scorecard
    print(result.pass_rate("final_answer_matches"))    # 1.0

asyncio.run(main())

inputs["input"] is the prompt; reference_outputs is the gold answer (a dict — omit it for trace-only checks). Each scorer is a column, looked up by its key.

Scorers

A scorer asks ONE question. Its RETURN TYPE picks the aggregation:

returnaggregationaccessor
boolpass rateresult.pass_rate(key)
int / floatmean / p50 / p95result.score_stats(key)
strvalue countsresult.value_counts(key)

Prebuilt (autogen.beta.eval.scorers): final_answer_matches(field=, matcher="contains"|"casefold"|"exact"), tool_called(name), no_tool_errors(), token_budget(n), failure_attribution(...), agent_judge(...).

Custom — decorate a function that declares what it needs by name (outputs, trace, reference_outputs, inputs, task):

from autogen.beta.eval import scorer

@scorer
def answered_briefly(outputs) -> bool:
    return len(outputs["body"]) < 100      # outputs["body"] = final answer text

agent_judge grades quality you can't check with == (use a different model than the agent under test):

from autogen.beta.eval.scorers import agent_judge
judge = agent_judge(OpenAIConfig(model="gpt-4o"), criterion="Helpful and accurate.", key="quality")

CI — deterministic, no API key

Swap the model for a TestConfig cassette (a canned reply per task) so CI is free and repeatable. model_config is a dict[task_id, ModelConfig] — one cassette per task — and overrides the agent's own config for that task:

from autogen.beta.testing import TestConfig

agent = Agent("geographer", prompt="Answer with the capital city.")   # an Agent instance, not a factory

canned = {"france": TestConfig("Paris"), "japan": TestConfig("Tokyo")}
result = await run_agent(suite, agent=agent, scorers=scorers, model_config=canned, store_dir="./runs")
assert result.pass_rate("final_answer_matches") == 1.0      # the gate

Persist, track, grade existing traces

store_dir= writes one JSON per run. Reload a past run and diff for regressions; or grade traces you already have (e.g. production telemetry) without re-running the agent:

from autogen.beta.eval import load_run, evaluate_traces, DirectoryTraceSource

assert not result.diff(load_run("./runs/<run_id>.json")).regressions   # scorers that flipped pass -> fail
graded = await evaluate_traces(DirectoryTraceSource("./traces"), scorers=scorers, store_dir="./runs")

Common pitfalls

  • Missing `tracing` extrarun_agent can't reconstruct traces. Install ag2[<provider>,tracing].
  • Return type vs aggregationbool for pass/fail, a number for stats, a str for categories; look results up by the scorer's key.
  • Same model answers and judges — biases agent_judge; use a different judge model.

Going deeper

  • website/docs/beta/evaluation/getting-started, scorers (catalog + custom + return-type rules), runs, persistence
  • ag2-eval-comparison — leaderboard (run_variants) + head-to-head (run_pairwise)

Related skills

FAQ

Can I run the evaluation in CI without an API key?

Yes. Swap the model for a TestConfig cassette with a canned reply per task, so CI is free and repeatable.

How does a scorer's return type matter?

A bool gives a pass rate, an int or float gives mean/p50/p95 stats, and a str gives value counts.

Testing & QAagentsllm

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.