Repository navigation
fix(eval): relabel email triage corpus to schema-2.0 5-bucket taxonomy - #1875
Conversation
The committed ground_truth.json carried the retired 4-way taxonomy (urgent/actionable/informational/low priority) while the agent emits the schema-2.0 5-bucket set (URGENT/NEEDS_RESPONSE/FYI/PROMOTIONAL/PERSONAL), so the benchmark's exact-match category_accuracy collapsed to ~0.04 — a vocabulary artifact, not real quality. The generator already maps to the schema-2.0 strings; regenerating relabels the corpus deterministically (mbox bytes and Gmail-id keys unchanged, so perf/hashing baselines stay comparable). Update the scorer's needs-attention axis (actionable -> needs_response) so the FP/FN axis stays coherent, refresh the corpus assertions, and add a drift guard asserting the corpus vocabulary stays a subset of the production taxonomy. Closes #1874
|
Verified on AMD Strix Halo (Gemma-4-E4B, real 🔍 Verification details + a residual quality noteRun: current 5-bucket email agent over the unchanged
Per-bucket recall (this PR's labels): FYI 52% · NEEDS_RESPONSE 46% · URGENT 40% · PROMOTIONAL 29%. Residual (non-blocking) note: the relabel is a 1:1 rename by count — |
|
🟡 The new Every other test in this repo that touches pytest.importorskip("gaia_agent_email")🔍 Technical details
def test_corpus_vocab_matches_scorer_taxonomy(labels: dict) -> None:
from gaia_agent_email.tools.triage_heuristics import ALL_CATEGORIES
...Without a skip guard, Fix — add as the first line of the function body (or at module level): pytest.importorskip("gaia_agent_email")
from gaia_agent_email.tools.triage_heuristics import ALL_CATEGORIES |
|
🟡 The new 🔍 Technical details
def test_corpus_vocab_matches_scorer_taxonomy(labels: dict) -> None:
from gaia_agent_email.tools.triage_heuristics import ALL_CATEGORIES # no skip guard
Fix: add |
After #1875 relabeled the eval corpus to the schema-2.0 triage taxonomy, the email agent's predictions and the ground-truth labels share one vocabulary, so category_accuracy now measures real agreement: 0.40 over 25 of 220 emails -> aggregate 40.0/100 (was 4.0, a labeling artifact). Fresh gaia eval benchmark run on AMD Strix Halo. Drop the now-resolved #1874 caveat from the adapter methodology + README; align the dataset description to the schema-2.0 taxonomy.
…1873) Closes amd#1862 ## Why this matters Every GAIA hub agent ships a README and changelog, but nothing told a prospective user **how well the agent actually performs** — no accuracy, no test counts, no dataset size. An agent looked like a proof-of-concept, and a quality regression could ship silently. This adds a standardized **per-agent eval scorecard**: a single `SCORECARD.md` per agent (updated in place per release and packaged like `README.md`/`SPEC.md`/`SKILL.md`) recording the eval *recipe*, *measured results*, a per-category breakdown, the run environment, a deterministic aggregate a reader can recompute by hand, and **reproduction steps**. A standalone **release gate** blocks packaging on a missing or regressed scorecard, a **self-hosted refresh loop** keeps it current, and the score is **surfaced on the hub listing + Agent UI**. The email agent is the first end-to-end adopter; the format is agent-agnostic (proven by a generalization test). ## Scope: the scorecard *system*, not the eval *methodology* This PR delivers the **machinery to publish, gate, and display** an agent's quality — the container. It deliberately does **not** try to make the email number high or statistically airtight. That number is honest but noisy on a single run (LLM `needs_llm` decisions, no seed: `0.46 → 0.42` across two identical runs), so producing a *trustworthy* figure — multi-run mean + variance, confidence intervals, determinism, and gate-vs-noise semantics — is its own work, tracked in **amd#1894 (Milestone 40)**. The two are cleanly separable: the card already carries `recipe.environment`, `results.breakdown`, and arbitrary `metrics`/`config` **additively**, so amd#1894 can fill in richer eval data with no schema change here. **This PR = how we *show* quality; amd#1894 = how we *measure* it well.** ## What changed - **Core, harness-agnostic** (`src/gaia/eval/`): `release_scorecard.py` (payload → generator → validator → carry-forward; stdlib + PyYAML only) and `scorecard_gate.py` (standalone gate). Distinct from the per-run `scorecard.py`. - **Single `SCORECARD.md`** per agent, versioned via the publish snapshot (R2 stores `agents/<id>/<version>/SCORECARD.md`). - **Per-category breakdown + environment pinning**: each card carries `results.breakdown` (per-label accuracy + top `expected → predicted` confusions) and `recipe.environment` (gaia commit, Lemonade version, model, hardware *class*) — additive, optional, and provably never affecting the aggregate. - **Email adoption**: real `hub/agents/npm/agent-email/SCORECARD.md` (v0.2.5), linked + surfaced from the canonical npm README; gate wired into `release_agent_email.yml` as a `publish`-blocking job. - **Keep-it-honest loop** (`email_scorecard_refresh.yml`): self-hosted AMD runner re-runs the eval on agent/corpus changes → commits the refreshed card if the score holds/improves, fails on a regression. - **Hub display**: the Cloudflare worker serves `eval_score` + `eval_scorecard_url` (parsed from the published card); publish uploads it to R2; the Agent UI detail modal renders score + link. - **Reproduction + skill + docs**: each card carries a `## Reproduction` section; `.claude/skills/adding-eval-scorecard/` makes adoption invocable; `docs/reference/eval-scorecard.mdx` documents schema (incl. the optional blocks), formula, versioning, the gate, and the refresh loop. ## The number (illustrative — proof the pipeline runs end-to-end) Real `gaia eval benchmark` on **AMD Strix Halo** (Gemma-4-E4B): **aggregate 42.0/100** (`category_accuracy` 0.42) over **100 of 220** labeled emails (the triage tool processes up to 100 per call — recorded distinctly as `test_cases_run: 100` / `dataset.size: 220`). The breakdown surfaces `promotional` as weakest (0.21) and `fyi ↔ needs_response` as the dominant confusion. This demonstrates the whole pipeline — eval → generator → card → gate → display; making the figure statistically robust is amd#1894, not this PR. (An earlier 4.0 was a stale-label artifact; the corpus was relabeled to the schema-2.0 taxonomy by amd#1875, which closed the amd#1874 I filed, and this branch is current with it.) ## How it was tested - **85 scorecard/gate unit tests** (`tests/unit/eval/`) + **69 hub-worker tests**; `tsc --noEmit` clean (worker + webui); `python util/lint.py --all` → ALL QUALITY CHECKS PASSED. - Real eval on Strix Halo produced the committed **v0.2.5** card (42.0/100) with the breakdown + environment blocks — see `hub/agents/npm/agent-email/SCORECARD.md`. - Gate (real exit codes): presence → `exit 0`; lower candidate vs baseline → `exit 1`; `--allow-regression` → `exit 0`. Reader recompute: `round(100 × 0.42, 2) = 42.0` ✓. Generalization (a second agent through the same generator) → gate `exit 0`. ## Notes - `GAIA_AGENT_TOOL_TIMEOUT` is `1800` in the reproduction recipe + refresh workflow: full-corpus triage is one ~17-min tool call that a lower timeout abandons mid-run (→ 0 emails scored, a degenerate FAIL). - The **hub-display worker** goes live only after a manual `wrangler deploy` + an email re-publish; in-PR verification is typecheck/build/worker-tests, not live hub rendering. - The release gate resolves the previous version via `git describe --tags --match 'agent-pkg-email-*'`; confirm the tag pattern matches the email release convention. --------- Co-authored-by: Tomasz Iniewicz <[email protected]> Co-authored-by: Kalin Ovtcharov <[email protected]>
The email-triage eval corpus was scored against the wrong vocabulary. The agent emits the schema-2.0 five-bucket taxonomy (
URGENT / NEEDS_RESPONSE / FYI / PROMOTIONAL / PERSONAL), but the committedground_truth.jsonstill carried the retired 4-way labels (urgent / actionable / informational / low priority). Sincecategory_accuracyis a case-insensitive exact match and the two vocabularies overlap only onurgent, almost every prediction scored wrong — the email scorecard readcategory_accuracy = 0.04purely as a labeling artifact, not real quality. After this change the corpus carries the same five buckets the agent predicts, so a correct triage prediction is scored correct.The corpus generator already maps to the schema-2.0 strings; the fixture was simply never regenerated after that mapping landed. Regenerating is deterministic — the
.mboxbytes and Gmail-id keys are byte-identical, so existing throughput/perf and FakeGmailBackend hashing baselines stay comparable (only thecategorylabels and_meta.taxonomychange).Closes #1874
Test plan
PYTHONPATH=...:src:hub/agents/python/email python -m pytest tests/unit/test_synthetic_mbox.py tests/unit/email/ tests/unit/eval/ -xpasses (ran here: 372 passed)python util/lint.py --allpassespython tests/fixtures/email/generate_mbox.py --verifyprintsVERIFY OK(committed fixtures match deterministic output, mbox hash unchanged)gaia eval benchmark --mbox-path tests/fixtures/email/synthetic_inbox.mbox --ground-truth tests/fixtures/email/ground_truth.json --limit 25 --output-dir <dir>and confirmcategory_accuracymoves from ~0.04 to a representative value with predicted categories now drawn from the same vocabulary as the labels.tests/fixtures/email/baseline_accuracy*.jsonviascore_baseline.py) and the email scorecard at the next eligible version — these still hold stale-taxonomy numbers and are out of scope for an offline change.🔍 Technical details
Root cause.
tests/fixtures/email/generate_mbox.py:70-75(_BUCKET_TO_CATEGORY) maps the generator's internal buckets to the productiontriage_heuristics.ALL_CATEGORIESstrings, and line 365 routes every label through it. The committedground_truth.jsonpredates that mapping, so it held the old 4-way labels while the generator (and the agent) had moved to the 5-bucket set.src/gaia/eval/quality_metrics.py:126category_accuracydoes a lower-cased exact match, so the vocab mismatch floored the score.Changes:
tests/fixtures/email/ground_truth.json— regenerated via the deterministic generator (SEED=23023). Verified the.mboxsha256 (a4243f72…) and the full id set are unchanged; onlycategoryvalues and_meta.taxonomydiffer. New realized counts: URGENT 47, NEEDS_RESPONSE 56, FYI 80, PROMOTIONAL 37 (PERSONAL not yet populated in the synthetic corpus — pre-existing, tracked by test(email): re-record the categorization baseline on the canonical CI backend #1438).src/gaia/eval/quality_metrics.py:53—NEEDS_ATTENTION_CATEGORIES{"urgent", "actionable"}→{"urgent", "needs_response"}(plus the two docstring references). Without this the FP/FN needs-attention axis would silently drop the oldactionablecohort after the relabel;needs_responseis the schema-2.0 successor. Compared lower-cased, matching the scorer.tests/unit/test_synthetic_mbox.py— updatedtest_category_coverage_and_countsandtest_meta_block_presentto the 5-bucket strings, and addedtest_corpus_vocab_matches_scorer_taxonomy(AC Documentation update from v0.7.2 tag. #4) asserting the committed corpus vocabulary and the scorer's attention axis both stay a subset ofALL_CATEGORIES— a drift guard so a future taxonomy change can't silently re-break scoring.Verification run here: 372 email+eval unit tests pass;
generate_mbox.py --verifyself-checks clean; black + isort clean. The inline-GT unit tests intest_quality_metrics.py/test_benchmark.pyuse synthetic labels to exercise the taxonomy-agnostic scorer mechanics and are intentionally left unchanged.