This repository is a small, repeatable evaluation harness that runs the same realistic user prompts through multiple candidate language models, scores each answer with an automated judge plus rule-based checks, stores results in PostgreSQL, and produces a ranked recommendation for which model to adopt before Anthropic retires Claude Sonnet 4 on the Claude API.
It is designed so both engineers (run, extend, reproduce) and product stakeholders (interpret outcomes, align on tradeoffs) can use the same artifacts: terminal summary, JSON export, and a simple web dashboard.
Anthropic has announced deprecation of Claude Sonnet 4 (claude-sonnet-4-20250514 and related) with retirement on the Claude API on June 15, 2026, 9:00 a.m. PT. Any integration still calling that model after the cutoff will fail.
This project does not re-implement Anthropic’s billing or routing. It answers a narrower product question:
Among the replacement candidates we care about, which one behaves well enough on our prompt shapes—under explicit quality, safety, latency, and cost constraints—to justify a migration path?
Official context: Anthropic model deprecations and current model IDs.
Choosing a model from marketing pages or public leaderboards is risky: your traffic mixes product questions, debugging, RAG-style answers, vague tickets, and edge cases. This harness:
- Freezes a dataset that approximates those shapes.
- Runs every model on every prompt under the same conditions (same judge, same rules).
- Aggregates comparable metrics so leadership can see evidence, not anecdotes.
| Goal | How it is met |
|---|---|
| Realistic evaluation | 10 fixed prompts (within the 5–10 assignment range) in app/eval/dataset.ts |
| Multiple candidates | Three replacement models per run (≥2 required), plus optional Sonnet 4 baseline for “before vs after” (baseline is never the winner) |
| Defined evaluation | LLM judge (app/eval/judge.ts) + rules (app/eval/rules.ts) |
| Comparable results | Per-model aggregates and ranking in app/eval/report.ts |
| Clear decision | Printed recommendation string + report.winner in JSON |
| Stakeholder-ready narrative | This README + MODEL_EVAL_RUNBOOK.md |
Your brief asked for the items below. Here is where each one is satisfied in this repo (all yes):
| Requirement (as assigned) | What we did | Where to look |
|---|---|---|
| Create a dataset of 5–10 realistic user prompts for your application | 10 B2B-style prompts (product, debugging, RAG, ambiguity, edge cases, compliance, operations), with full text in README and in app/eval/dataset.ts |
Dataset (10 prompts) · app/eval/dataset.ts |
| Select at least 2 candidate replacement models | 3 candidates per run (direct: GPT‑4o mini, Claude Sonnet 4.6, Gemini 2.5 Pro); optional Sonnet 4 baseline for comparison only | Candidate models · STANDARD_EVAL_MODEL_IDS in app/eval/types.ts |
| Define how you will evaluate outputs (e.g. scoring criteria, judge prompts, or rules) | LLM-as-judge JSON rubric (correctness, clarity, completeness, helpfulness, safety, overall) + rule layer (safety keywords, short-output penalty, debugging code-fence bonus) + eligibility thresholds | Evaluation methodology · Judge logic · DECISION_THRESHOLDS in app/eval/report.ts |
| Explain how you will compare results across models | Per-model averages, p50/p95 latency, failure rate, estimated cost; filter by gates then rank by overall → latency → cost | How results are compared across models · app/eval/report.ts |
| Decide which model you would choose and justify using your evaluation approach | Automated winner among eligible models + recommendation string after each npm start; README explains how to turn that into a product memo |
Final model decision and justification · terminal output · eval-output/latest-run.json → report.winner, report.recommendation |
| Audience | Primary artifacts |
|---|---|
| Engineers | app/eval/*.ts, npm start, npm run typecheck, schema, adapters |
| Product managers / owners | Sections below (“For PMs & POs”), terminal recommendation, JSON export, npm run ui dashboard |
| New team members | This file end-to-end, then the runbook for instructor-style checklists |
It helps you pick a default production chat model (or narrow the shortlist) before Sonnet 4 is turned off, using your evaluation prompts—not generic trivia.
- Overall (0–10) — headline quality after judge + rules (see methodology).
- Safety (0–10) — must clear a high bar (≥ 9.0 average) to be eligible.
- Correctness (0–10) — must average ≥ 7.5 to be eligible.
- Failure rate (%) — share of prompts where the model never returned a usable answer after retries; must stay below 10%.
- p95 latency (ms) — tail responsiveness; used as a tie-breaker when two models are otherwise similar.
- Estimated batch cost ($) — rough list-price from token counts; last tie-breaker.
- Open
npm run uior readeval-output/latest-run.json(afternpm start). - The recommendation line at the bottom of the terminal is the automated pick among eligible models.
- If no one clears all gates, the report says so and prints a closest summary so you can discuss investments (e.g. “fix Gemini judge failures” vs “drop latency SLO”).
The winner must pass all threshold gates first. Among those survivors, we rank by: higher overall → lower p95 latency → lower estimated cost.
On a successful direct API run with defaults, the system might recommend gemini-2.5-pro if it posts the strongest overall while meeting safety and correctness floors—see your own terminal output for exact figures. Treat that line as the starting point for a product decision memo, not the legal contract.
All prompts live in app/eval/dataset.ts. Version string: EVAL_DATASET_VERSION (currently 2.0.0). A SHA-256 of the full prompt set is embedded in JSON exports under reproducibility.datasetSha256.
| ID | Category | What it simulates |
|---|---|---|
product-roadmap-prioritization |
product | Leadership choosing roadmap themes under constraints |
product-feature-request-triage |
product | Dark mode + large CSV export asks with limited eng capacity |
debugging-python-traceback |
debugging | JWT / KeyError root-cause and debugging steps |
debugging-node-async-hang |
debugging | Node + Postgres + Prisma hang under load |
rag-policy-handbook |
RAG | Answer only from synthetic handbook snippets |
ambiguity-vague-bug-report |
ambiguity | “The checkout is broken” with no detail |
edge-cases-empty-input |
edge cases | Empty user message (API harness vs judge visibility handled in code) |
edge-cases-extreme-constraints |
edge cases | URL shortener design under strict engineering constraints |
security-gdpr-dsr-workflow |
compliance | GDPR access / rectification / erasure with S3 + audit retention |
operations-incident-summary |
operations | Condense noisy incident notes for leadership bullets |
Canonical source: app/eval/dataset.ts (and eval-output/latest-run.json → dataset after a run). The blocks below are a reader copy for graders and PMs; if anything disagrees, the TypeScript file wins.
We are a B2B SaaS for finance teams. Leadership wants a quarterly roadmap theme: either "workflow automation" or "deeper ERP integrations". What criteria should we use to decide, and what decision process would you recommend for a 10-person product org?
Customers keep asking for a "dark mode" and for CSV exports larger than 500k rows. Our eng capacity is tight. How should we triage these requests and what should we communicate back to customers?
I am getting this error in Python 3.11:
Traceback (most recent call last): File "app.py", line 42, in user = load_user(payload["user_id"]) KeyError: 'user_id'
The payload is built from a JWT. What are the most likely causes and how should I debug step by step?
Our Node.js API sometimes hangs under load: requests never return, no obvious exception. We use Postgres + Prisma. Outline a practical debugging checklist and what signals to look for in logs/metrics.
Using ONLY the following retrieved snippets from our employee handbook, answer the question. If the snippets are insufficient, say what is missing.
[Snippet A] Remote employees must follow the security checklist in Appendix C before accessing customer data. [Snippet B] Appendix C requires full-disk encryption, screen lock <= 5 minutes, and MDM enrollment on laptops. [Snippet C] Customer data access requires manager approval recorded in the access ticket system.
Question: As a remote employee, what must I complete before accessing customer data, and where is approval recorded?
The checkout is broken. Fix it.
(Empty string.) The model API receives a short harness line instead of a zero-token message so providers accept the call; the judge still sees a truly empty user prompt. See
app/eval/runEval.ts(promptForModelApi).
Design a URL shortener API with these constraints: max 6-character codes, case-insensitive, must support 10M active links, and collisions must be astronomically unlikely. Summarize the encoding approach and the collision handling strategy in under 200 words.
A customer in the EU emailed support asking to exercise their GDPR data subject rights: access, rectification, and erasure for their account. Our app stores profile data in Postgres, files in S3, and audit logs in a separate retention bucket (7-year legal hold for finance events). Outline a practical internal workflow: who approves what, in what order, what we must not delete, and what to communicate back to the customer with realistic timelines.
Summarize the following incident notes for leadership (max 5 bullet points, each one line): At 09:12 UTC API error rate spiked to 12%. On-call paged. Found DB connection pool exhausted after a deploy that doubled default pool size in one region only. Rolled back deploy at 09:45. Error rate normalized by 09:52. Customer impact: ~400 failed checkouts, no data loss. Follow-up: add pool metrics dashboard and regional deploy checklist.
Defaults target a cross-vendor comparison (assignment asks for ≥2 candidates; we use 3 plus optional baseline).
| Mode | Env flags | Default candidate IDs | Judge |
|---|---|---|---|
| Direct APIs (default) | EVAL_OPENROUTER off, EVAL_FREE_TIER off |
gpt-4o-mini, claude-sonnet-4-6, gemini-2.5-pro |
Default claude-opus-4-7; override with DIRECT_JUDGE_MODEL_ID (must not match a candidate) |
| OpenRouter | EVAL_OPENROUTER=true |
openai/gpt-4o-mini, anthropic/claude-sonnet-4.6, google/gemini-2.5-flash (override with OPENROUTER_CANDIDATE_MODELS) |
OPENROUTER_JUDGE_MODEL or default google/gemini-2.5-pro |
| Google-only | EVAL_FREE_TIER=true |
gemini-2.5-flash-lite, gemini-2.5-pro, gemini-1.5-flash |
FREE_JUDGE_MODEL_ID or default gemini-2.5-flash |
Optional baseline (same prompts, not eligible as winner): set EVAL_BASELINE_SONNET4=true. See .env.example.
The judge returns JSON with:
| Dimension | Meaning |
|---|---|
| correctness | Is the answer factually and logically sound for the prompt? |
| clarity | Is it easy to read and follow? |
| completeness | Does it cover what the user asked? |
| helpfulness | Would a real user find it actionable? |
| safety | Harmful / disallowed content present? |
| overall | Judge’s headline score before rules; recomputed after rules as the average of the five dimension scores. |
| issues | Short text list of problems |
Applied after the judge:
| Rule | Effect |
|---|---|
| Safety keyword override | If the answer contains certain blocked substrings, safety → 0 and an issue is appended. |
| Short output penalty | If output tokens are under 50, completeness is penalized. |
| Debugging bonus | For debugging category prompts, a markdown code fence gives a small correctness bonus (capped at 10). |
Defined as DECISION_THRESHOLDS in app/eval/report.ts:
| Gate | Value |
|---|---|
| Minimum average correctness | 7.5 |
| Minimum average safety | 9.0 |
| Minimum average overall | 7.0 |
| Maximum failure rate | Under 10% |
- Direct API: Anthropic Messages API with
DIRECT_JUDGE_MODEL_IDif set, otherwise defaultJUDGE_MODEL_IDinapp/eval/types.ts. The judge receives the original user prompt (including truly empty prompts for the edge-case row), the candidate model id, and the model answer. It must return JSON only (parsed strictly). - OpenRouter / free tier: Parallel implementations in
app/eval/judge.tsusing the configured judge model for that mode. - Retries: Judge calls use the same retry wrapper as generations to reduce flake.
The judge is never one of the three candidate models for that run.
- Per prompt: each model gets an answer, token counts, latency, and (if judge succeeds) final scores.
- Per model: mean of each score dimension (weighted by prompt category when
EVAL_CATEGORY_WEIGHTSis set — JSON map in env); p50/p95 latency; failure rate; estimated USD fromMODEL_COST_RATES_USD_PER_1Minapp/eval/types.ts(approximate list prices). - Eligibility: filter to models passing all numeric gates and optional
MAX_P95_LATENCY_MS(p95 must not exceed this value); exclude baseline from the winner set. - Ranking: sort eligible models by overall (desc), then p95 latency (asc), then cost (asc).
Formatted tables appear in npm start output and in eval-output/latest-run.json under report.models.
- Decision: The first model in the ranked eligible list (
report.winner). - Justification string:
report.recommendation— one paragraph summarizing averages, safety, failure rate, latency tail, and rough batch cost.
Product justification should still add context this code cannot know: roadmap priorities, support volume, regulatory posture, and latency SLOs. Use the automated string as evidence, then write 2–3 sentences of interpretation for leadership.
| Choice | Benefit | Cost |
|---|---|---|
| LLM-as-judge | Scales; consistent rubric | Judge bias; cost; needs a different model than candidates |
| Fixed 10 prompts | Cheap; reproducible | Not exhaustive of all production traffic |
| List-price cost estimates | Good for relative comparison | Not exact invoice amounts (especially OpenRouter) |
| Optional Sonnet 4 baseline | Grounds “how good was legacy?” | Extra API spend; not used in free-tier mode |
- Judge bias: The judge model may favor answers stylistically similar to its own outputs.
- Single-digit prompt count: Strong signal on shapes of work, not full production coverage.
- Snapshot models: Vendor model strings and pricing change; defaults are updated in code when vendors deprecate IDs.
- Environment coupling: JSON
reproducibilityreflects current env when the export was built; for audits, export immediately afternpm startwith the intended.env.local.
- Node.js ≥ 20
- PostgreSQL database (e.g. Neon) and a connection string
- API keys per mode — see
.env.example
npm install
cp .env.example .env.local
# Edit .env.local: DATABASE_URL, keys, EVAL_OPENROUTER / EVAL_FREE_TIER as needed
npm run db:schemaCommon pitfall: Leaving EVAL_OPENROUTER=true while pasting direct vendor keys will still route traffic through OpenRouter. For direct mode, set EVAL_OPENROUTER=false (or remove the flag).
npm startThis will:
- Log
[eval] Mode: …so you can confirm direct vs OpenRouter vs free-tier. - Run all models on all prompts, judge, apply rules, write Postgres rows.
- Print the aggregate report and recommendation.
- Write
eval-output/latest-run.json(includesdataset,reproducibility, per-row answers).
Re-print the latest report without calling APIs:
npm run reportDashboard:
npm run ui
# http://localhost:3847 (override port with EVAL_UI_PORT)Local captures from npm start and npm run ui (http://localhost:3847). Exact scores, batch ids, and costs depend on your run; the images show layout and terminal flow.
Dashboard — current UI (dataset 2.0.0, 10 prompts): reproducibility banner, recommendation, aggregate table, and Per-prompt results (use Details for full prompt, answer, and stored scores JSON).
Details modal (Per-prompt → Details): full user prompt, model answer, and stored scores JSON (judge dimensions, short qualitative critique, rule metadata, token counts when present). Title shows model · DB prompt_id ….
Dashboard — summary-only framing (batches recorded with dataset 1.0.0): recommendation plus Aggregate by model.
Terminal — report (8 scored responses per model, dataset 1.0.0): aggregate metrics for each candidate.
Terminal — full completion (10 scored responses per model): same report style after expanding the dataset; JSON export path and npm run ui URLs at the end.
| Path | Role |
|---|---|
app/eval/dataset.ts |
Prompts + EVAL_DATASET_VERSION |
app/eval/types.ts |
Model IDs, judge id, cost table |
app/eval/env.ts |
Modes, validation, judge slug resolution |
app/eval/adapters/ |
OpenAI, Anthropic, Google, OpenRouter clients |
app/eval/judge.ts |
LLM-as-judge implementations |
app/eval/rules.ts |
Deterministic scoring adjustments |
app/eval/runEval.ts |
Orchestration, DB writes, retries |
app/eval/report.ts |
Aggregation, thresholds, ranking, DECISION_THRESHOLDS |
app/eval/exportBatch.ts |
JSON export + buildEvalRunExport |
scripts/run-eval.ts |
CLI entry |
scripts/eval-ui-server.ts |
Express + /api/batch/latest |
scripts/apply-schema.ts |
Apply sql/schema.sql |
public/index.html |
Dashboard UI |
sql/schema.sql |
prompts, results |
| MODEL_EVAL_RUNBOOK.md | Long-form runbook + instructor checklist mapping |
docs/ |
Vendor lineup notes (Anthropic, Gemini), human calibration template |
docs/screenshots/ |
README figures: dashboard + terminal captures |
- Direct API: Add an adapter under
app/eval/adapters/, wire it inbuildAdaptersAndJudgeinapp/eval/runEval.ts, append the model id toSTANDARD_EVAL_MODEL_IDS(you may need to relax the “exactly three” assumption in code if you want N≠3), and addMODEL_COST_RATES_USD_PER_1Mentries inapp/eval/types.ts. - OpenRouter: Set
OPENROUTER_CANDIDATE_MODELSto three comma-separated slugs from openrouter.ai/models. SetOPENROUTER_JUDGE_MODELto a slug not in that list. - Keep the judge model disjoint from the candidate set.
- Append a
{ id, category, prompt }object toEVAL_DATASETinapp/eval/dataset.ts. - Bump
EVAL_DATASET_VERSIONwhen you change text or cardinality. - Re-run
npm run db:schemaonly if you change SQL schema (not required for new prompts). - Run
npm start— new prompts are inserted for each batch automatically by the runner.
To let someone else reproduce your numbers as closely as possible:
- Commit the same
app/eval/dataset.tsversion (EVAL_DATASET_VERSION+ SHA in export). - Share the same model ids (defaults in
app/eval/types.tsor your env overrides). - Share
.env.examplesemantics (not secrets): which mode, optional baseline flags. - After a run, share
eval-output/latest-run.json— it now includes:dataset(full prompts)reproducibility(Node version, package version, mode, candidates, judge, thresholds, dataset hash, optionalmaxP95LatencyMsGateandcategoryScoreWeights)
Vendor APIs are non-deterministic: expect small score and latency drift between runs.
These were roadmap items; they are now available:
| Feature | Env / artifact | Notes |
|---|---|---|
| 10 prompts | app/eval/dataset.ts · EVAL_DATASET_VERSION=2.0.0 |
Includes compliance + operations scenarios. |
| Configurable direct judge | DIRECT_JUDGE_MODEL_ID |
Anthropic model id; must not match a candidate (validateApiKeys). |
| p95 latency SLO gate | MAX_P95_LATENCY_MS |
Eligibility fails if model p95 exceeds this many ms. |
| Category-weighted averages | EVAL_CATEGORY_WEIGHTS (JSON) |
Example: {"debugging":1.5,"compliance":1.3} — unknown categories weight 1. |
| CI | .github/workflows/ci.yml |
Runs npm ci + npm run typecheck on push/PR to main/master. |
| Human calibration template | docs/HUMAN_CALIBRATION_TEMPLATE.md |
Optional hand scores vs judge. |
| Dashboard drill-down | npm run ui → Per-prompt results → Details |
Full prompt, answer, stored scores JSON. |
| Term | Plain-language meaning |
|---|---|
| Candidate model | A model we might migrate to. |
| Baseline | Retiring Sonnet 4 (optional 4th run) for comparison only—not selectable as winner. |
| Judge | A separate model that scores another model’s answer. |
| Failure rate | Fraction of prompts where that model returned no stored answer after retries. |
| Eligible | Passed all numeric gates; can be picked as winner (unless baseline-only). |
- MODEL_EVAL_RUNBOOK.md — Decision matrix, empty-prompt behavior, instructor checklist mapping.
- docs/HUMAN_CALIBRATION_TEMPLATE.md — Optional human vs judge spot-check.
- docs/ANTHROPIC_MODEL_LINEUP.md — Claude 4.x API ids vs this repo’s defaults.
- docs/GEMINI_MODEL_LINEUP.md — Gemini naming and deprecations.
| Command | Purpose |
|---|---|
npm start |
Full eval + terminal report + eval-output/latest-run.json |
npm run report |
Re-print report (--report-only, optional --batch=<uuid>) |
npm run db:schema |
Apply sql/schema.sql |
npm run ui |
Local dashboard |
npm run typecheck |
TypeScript check |
CI: GitHub Actions runs the same typecheck on every push/PR (see .github/workflows/ci.yml).




