# Eval suite

> Evaluation runner comparing candidate vs baseline agent versions with judge stats, score deltas and Failed/Regression/Improved filters.

- Kind: block · Category: Agents · Interactivity: script
- Install: `npx shadcn@latest add @haze/eval-suite`
- File: `src/components/haze/blocks/eval-suite.astro`
- npm dependencies: @lucide/astro
- Registry dependencies: @haze/utils
- Docs page: https://hazeui.com/blocks/eval-suite

## Use when
- Comparing a new prompt or agent candidate against a baseline before shipping
- Filtering test cases by failures, regressions and improvements with per-case score deltas

## Avoid when
- Collecting blind human side-by-side preference votes; use model-arena

## Alternatives
- [model-arena](https://hazeui.com/blocks/model-arena.md)
- [check-runs](https://hazeui.com/ui/check-runs.md)

## Props

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| id | `string` | "haze-eval-suite" | no | Unique prefix for section heading IDs. |
| suiteName | `string` | "Support agent v4 vs v3 baseline" | no | Evaluation run title. |
| cases | `EvalCase[]` | 4 categorized test cases | no | Individual cases with baseline/candidate scores and outcome. |
| class | `string` |  | no | Extra classes on the outer section. |

## Accessibility
- Outcome filter tabs expose aria-selected and show status via both icon, badge text and numeric delta.
- Re-running the evaluation announces the updated score in a polite role="status" message.
- Key Tab: Move across Run eval and the All/Failed/Regression/Improved filter tabs
- Key Enter / Space: Re-run the eval suite or filter the test cases

## Agent prompts

### Install and use

Install the Haze UI block "Eval suite" with `npx shadcn@latest add @haze/eval-suite`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "https://hazeui.com/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import EvalSuite from "@/components/haze/blocks/eval-suite.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: https://hazeui.com/blocks/eval-suite.md

### Customize with real content

Adapt the Haze eval-suite block for our product. Replace the demo values of these props with our real content: id, suiteName, cases, class. Keep the layout, the heading level rules and these accessibility details: Outcome filter tabs expose aria-selected and show status via both icon, badge text and numeric delta. Re-running the evaluation announces the updated score in a polite role="status" message. Do not add raw color classes; use the Haze tokens.

### Choose the right block

Before using eval-suite, check it fits: use it when comparing a new prompt or agent candidate against a baseline before shipping; filtering test cases by failures, regressions and improvements with per-case score deltas. Avoid it when collecting blind human side-by-side preference votes; use model-arena. Alternatives: @haze/model-arena, @haze/check-runs.

## Example requests that should lead here
- Build an AI agent eval suite card comparing candidate vs baseline with Failed, Regression and Improved filters

## Source

```astro
---
import { ArrowDownRight, ArrowUpRight, CheckCircle2, FlaskConical, Play, XCircle } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";

interface EvalCase {
  id: string;
  name: string;
  category: string;
  outcome: "Improved" | "Passed" | "Regression" | "Failed";
  baseline: string;
  candidate: string;
}

interface Props {
  id?: string;
  suiteName?: string;
  cases?: EvalCase[];
  class?: string;
}

const {
  id = "haze-eval-suite",
  suiteName = "Support agent v4 vs v3 baseline",
  cases = [
    { id: "e1", name: "Duplicate charge refund routing", category: "Billing", outcome: "Improved", baseline: "0.72", candidate: "0.96" },
    { id: "e2", name: "Abstain on unsupported region", category: "Guardrails", outcome: "Passed", baseline: "0.91", candidate: "0.93" },
    { id: "e3", name: "Multi-currency invoice split", category: "Billing", outcome: "Regression", baseline: "0.88", candidate: "0.64" },
    { id: "e4", name: "Prompt injection in ticket body", category: "Security", outcome: "Failed", baseline: "0.52", candidate: "0.49" },
  ],
  class: className,
} = Astro.props;
const filters = ["All", "Failed", "Regression", "Improved"] as const;
---

<section aria-labelledby={`${id}-title`} data-haze-eval-suite class={cn("bg-background px-4 py-10 sm:px-6 sm:py-14", className)}>
  <div class="mx-auto max-w-4xl rounded-2xl border border-border bg-card p-5 sm:p-6">
    <header class="flex flex-wrap items-start justify-between gap-3 border-b border-border pb-4">
      <div class="flex items-start gap-2.5">
        <span class="grid size-8 shrink-0 place-items-center rounded-lg border border-frame bg-muted text-muted-foreground" aria-hidden="true">
          <FlaskConical class="size-4" />
        </span>
        <div>
          <h2 id={`${id}-title`} class="text-base/6 font-semibold tracking-tight text-foreground">{suiteName}</h2>
          <p class="text-xs/5 text-muted-foreground">Judge: Opus 4.5 · 42 cases · $0.38 · 18.4s</p>
        </div>
      </div>
      <button type="button" data-ev-run class="inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg bg-primary px-3.5 text-xs font-medium text-primary-foreground hover:opacity-90 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring transition-[background-color,border-color,color,opacity,scale] duration-150 ease-snappy active:scale-[0.97] active:duration-75">
        <Play class="size-3.5" aria-hidden="true" />
        Run eval
      </button>
    </header>

    <div class="mt-4 grid gap-3 sm:grid-cols-3">
      <div class="rounded-xl border border-border bg-muted/40 p-3.5">
        <p class="text-xs text-muted-foreground">Candidate score</p>
        <p class="mt-1 flex items-baseline gap-2">
          <span class="text-2xl/7 font-semibold text-foreground tabular-nums">86.4%</span>
          <span class="inline-flex items-center text-xs font-medium text-success"><ArrowUpRight class="size-3.5" aria-hidden="true" />+4.2%</span>
        </p>
      </div>
      <div class="rounded-xl border border-border bg-muted/40 p-3.5">
        <p class="text-xs text-muted-foreground">Regressions</p>
        <p class="mt-1 flex items-baseline gap-2">
          <span class="text-2xl/7 font-semibold text-warning tabular-nums">1</span>
          <span class="inline-flex items-center text-xs text-muted-foreground"><ArrowDownRight class="size-3.5 text-warning" aria-hidden="true" />Billing</span>
        </p>
      </div>
      <div class="rounded-xl border border-border bg-muted/40 p-3.5">
        <p class="text-xs text-muted-foreground">Improved cases</p>
        <p class="mt-1 text-2xl/7 font-semibold text-success tabular-nums">14</p>
      </div>
    </div>

    <div class="mt-4 flex flex-wrap items-center justify-between gap-2">
      <div role="tablist" aria-label="Filter eval cases" class="inline-flex rounded-lg border border-frame bg-muted p-0.5">
        {
          filters.map((f, idx) => (
            <button
              type="button"
              role="tab"
              data-ev-filter={f}
              aria-selected={idx === 0 ? "true" : "false"}
              class="inline-flex h-7 cursor-pointer items-center rounded-md px-2.5 text-xs font-medium text-muted-foreground hover:text-foreground aria-selected:bg-background aria-selected:text-foreground aria-selected:shadow-key focus-visible:outline-2 focus-visible:outline-ring"
            >
              {f}
            </button>
          ))
        }
      </div>
    </div>

    <ul role="list" class="mt-3 divide-y divide-border rounded-xl border border-border bg-muted/40">
      {
        cases.map((c) => (
          <li data-ev-row data-outcome={c.outcome} class="flex flex-wrap items-center justify-between gap-3 p-3.5 text-xs">
            <div class="flex min-w-0 items-center gap-2.5">
              {c.outcome === "Failed" || c.outcome === "Regression" ? (
                <XCircle class={cn("size-4 shrink-0", c.outcome === "Failed" ? "text-destructive" : "text-warning")} aria-hidden="true" />
              ) : (
                <CheckCircle2 class="size-4 shrink-0 text-success" aria-hidden="true" />
              )}
              <div class="min-w-0">
                <p class="truncate font-medium text-foreground">{c.name}</p>
                <p class="text-[0.6875rem] text-muted-foreground">{c.category}</p>
              </div>
            </div>
            <div class="flex items-center gap-3 font-mono tabular-nums">
              <span class="text-muted-foreground">{c.baseline} → <strong class="text-foreground">{c.candidate}</strong></span>
              <span class={cn(
                "rounded-md border px-2 py-0.5 font-sans text-[0.6875rem] font-medium",
                c.outcome === "Improved" ? "border-frame-success bg-success/10 text-success" :
                c.outcome === "Regression" ? "border-frame-warning bg-warning/10 text-warning" :
                c.outcome === "Failed" ? "border-frame-destructive bg-destructive/10 text-destructive" :
                "border-frame bg-card text-muted-foreground",
              )}>{c.outcome}</span>
            </div>
          </li>
        ))
      }
    </ul>

    <p data-ev-status role="status" class="mt-3 min-h-4 text-xs/4 text-muted-foreground"></p>
  </div>
</section>

<script>
  function initEvalSuites() {
    document.querySelectorAll<HTMLElement>("[data-haze-eval-suite]").forEach((root) => {
      if (root.hasAttribute("data-enhanced")) return;
      root.setAttribute("data-enhanced", "");
      const status = root.querySelector<HTMLElement>("[data-ev-status]");

      root.querySelectorAll<HTMLButtonElement>("[data-ev-filter]").forEach((tab) => {
        tab.addEventListener("click", () => {
          const f = tab.dataset.evFilter ?? "All";
          root.querySelectorAll<HTMLButtonElement>("[data-ev-filter]").forEach((t) => t.setAttribute("aria-selected", String(t === tab)));
          root.querySelectorAll<HTMLElement>("[data-ev-row]").forEach((row) => {
            row.hidden = f !== "All" && row.dataset.outcome !== f;
          });
        });
      });

      root.querySelector<HTMLButtonElement>("[data-ev-run]")?.addEventListener("click", () => {
        if (status) status.textContent = "Eval suite re-run complete: 86.4% candidate score (+4.2% vs baseline).";
      });
    });
  }
  initEvalSuites();
  document.addEventListener("astro:page-load", initEvalSuites);
</script>
```
