--- name: iblai-vibe-agent-evals description: Add the agent Evals tab (run the agent against a benchmark of test questions, score the answers with LLM-as-Judge reviews or manual scores, export CSV) to your Next.js app, with the benchmark screens that create a benchmark in two steps and add its Q&A typed in or from a CSV file. Use when the user mentions evals, evaluations, benchmarks, test sets, Q&A pairs, LLM-as-Judge, scoring agent answers, or measuring agent quality. For the REST contract see /iblai-api-agent-eval. globs: alwaysApply: false metadata: kind: ui --- # /iblai-vibe-agent-evals Add the agent **Evals tab** -- run the agent against a benchmark (a set of test questions with expected answers) and score every answer, so you can catch weak spots and track improvements. **Scope: benchmarks belong to the organization; evaluations belong to the agent.** One benchmark can be run against many agents, and the table only lists runs of this agent. This is one tab in the agent-settings family indexed by `/iblai-vibe-agent`; it shares the `AgentSettingsProvider` wrapper with every other tab. ## What the tab renders **Evaluations** -- a benchmark picker (the first benchmark is selected), **Manage Benchmarks**, **New Evaluation**, and a table of this agent's runs (Evaluation, Status, Initiated By, Created), as many rows as fit the tab's height, with pagination below, so it never scrolls (between 768 and 1023px wide it shows 10 a page instead). Runs work in the background. Status is an icon that names itself on hover: **Queued**, **Running**, **Complete** or **Failed**. Between 768 and 1440px the table uses narrower columns so it fits without scrolling sideways.  **Row actions** -- **View Results**, **New Review**, **Check Status** (refetch one run and toast its state), **Export CSV**, and **Delete**. View Results, New Review and Export CSV stay off until the run completes, and hovering one says why: "Available once the evaluation completes", or "Not available because the evaluation failed". On a phone a tap opens a sheet that prints the reason under each action that is off.  **On a phone** (below 768px) -- each run is a card, the row actions and the benchmark picker open as sheets from the bottom, and a "Page x of y" pager replaces the page numbers.   **No benchmarks yet** -- an organization without benchmarks gets a **New Benchmark** button in the empty state. It opens the New Benchmark dialog below, and the tab selects the benchmark it creates.  **A benchmark without Q&A cannot be evaluated** -- while the selected benchmark has no questions, **New Evaluation** is off (hovering it says why) and the tab offers one **Add Q&A** button: in the empty state, or on a line above the table when the benchmark already has runs. The tab reads the count with a one-row request; if that request fails, New Evaluation stays on.  **Manage Benchmarks** -- the organization's benchmarks (Name, Description, Created), 10 per page, with a search box that filters the page on screen, **New Benchmark**, and an eye button per row (**View Q&A**). A benchmark created here is selected on the tab.  **New Benchmark** -- two steps, like Create Agent. **Details** asks for a name and a description, then **Next** goes to **Q&A**:  **Q&A** is the same Manual / CSV Upload form as Add Q&A, and it is optional: a note says the benchmark needs one question before an evaluation can run. **Create** saves the benchmark, then its Q&A. The toast says how many pairs were saved, or that Q&A still has to be added.  The name cannot be changed later. A name with a slash (`/`), or made only of dots, is refused, and so is a name another benchmark already has: the dialog goes back to Details and says so under **Name**. If the benchmark is created but its Q&A cannot be saved, the dialog stays open with an error; the button becomes **Save Q&A** to try again and Cancel becomes **Close**. Pairs are saved one at a time, so a save that failed part-way may have stored some, and Save Q&A sends all of them again: open the benchmark's Q&A first, or close and add only what is missing.  **Add Q&A** -- question and answer rows typed in (**Manual**; the answer is optional, **Add Row** adds one), and **Add**:  or a **CSV Upload** and **Upload**: UTF-8, a required `input` column, an optional `expected_output` column, at most 10 MB / 10,000 rows; rows with a blank question are skipped. **Download Sample CSV** saves an example. The dialog refuses a file over 10 MB, or one whose first row has no `input` column, before it uploads anything.  **A benchmark's Q&A** -- the pair count, **Add Q&A**, and each question with its expected answer, 10 per page; the trash button asks before it deletes a pair (**Delete Q&A**).  **New Evaluation** -- the selected benchmark (to use another, close the dialog and pick it on the tab) and an optional **Evaluation Name** (generated when blank). **Start Evaluation** sends every question to this agent in the background.  **Results** -- the run's status, the number of responses (one per question), **Refresh**, **New Review**, the **Reviews** (LLM-as-Judge runs with status, score name, criteria and model; expand one for its full criteria and the scores it produced), and one row per question with its score count. The dialog refreshes itself while responses or reviews are still running.  **A response** -- input, expected output, the agent's actual output, its scores (hover a score for its comment; the trash button deletes it), and **Add a Score**: a name, a value from 0 to 1, and an optional comment.  **New Review** -- criteria for the judge, a score name, max concurrency (1 to 20, default 4), and the judge model. **Start Review** starts it.  **Select LLM** -- the provider grid (names and logos come from the API; a provider without a logo shows its initial); picking a provider opens its models.  **Delete Evaluation** -- asks for confirmation; the run and its scores go.  > **Common setup (brand, conventions, env files, verification):** see [docs/skill-setup.md](https://raw.githubusercontent.com/iblai/vibe/refs/heads/main/docs/skill-setup.md). ## Prerequisites - Auth set up (`/iblai-vibe-auth`, or vibe-starter). - `AgentSettingsProvider` wraps the route (`/iblai-vibe-agent` §1). - `@iblai/iblai-js@^3.1.0` (resolves `@iblai/web-containers` 2.1.0). The screens above are not in releases before 2.77.0, which have a one-step New Benchmark and let an evaluation start on a benchmark without Q&A. Check with `pnpm why @iblai/web-containers`. - A real agent UUID. Ask the user; never invent one. - Evals are for admins: pass `userIsStudent` from the app's admin check (Step 2). ## Step 1: Check Environment Look for `iblai.env` in the project root with `PLATFORM`, `DOMAIN`, and `TOKEN`. If it is missing, tell the user: "You need an `iblai.env` with your platform configuration. Download the template and fill in your values: `curl -o iblai.env https://raw.githubusercontent.com/iblai/vibe/refs/heads/main/iblai.env`" ## Step 2: Mount `AgentEvaluationTab` ```tsx // app/(app)/agents/[mentorId]/evals/page.tsx "use client"; import { AgentEvaluationTab } from "@iblai/iblai-js/web-containers/next"; export default function AgentEvalsPage() { return (