Email triage with Jev
September 20, 2026 · View on GitHub
A small script that runs Jev, TypeSafe's decision model, over a JSON file of emails. Jev answers four questions per email: category, importance, brand-deal, scam. The calls go through the Vercel AI Gateway with one key.
Inspired by Riley Brown's video Jev: the model that can't write, where he triages his inbox with Jev. This repo is that idea, run over 90 days of a real inbox and documented step by step with Claude Code. The companion repo jev-model-router uses Jev to pick which LLM answers a chat message.
- Development journey: https://az9713.github.io/jev-email-triage/ — how the mail was fetched, the four questions, every input and output file (redacted), four mis-ranks and their causes, and 17 unknown unknowns.
- Reliability upgrade: https://az9713.github.io/jev-email-triage/reliability-upgrade.html — what changed, why it changed, how resumable atomic processing works, and the new evaluation evidence.
How it works
triage.mjsreads a JSON array of{ id, date, from, subject, snippet }.- For each email it sends one
experimental_evaluatecall totypesafe-ai/jevwith four questions:
| Question | Type | Answer |
|---|---|---|
category | choice | one of security_alert, receipt, service_notice, newsletter, personal_reminder, business_inquiry, other |
importance | score | 0 to 5 on a six-step rubric from ignore to insane |
brand_deal | boolean | probability that the email is a sponsorship or brand-deal offer |
scam | boolean | probability that the email is a scam or phishing |
- It writes
<input>.triage.jsonand prints a table sorted by importance.
Change the questions in the QUESTIONS block at the top of triage.mjs.
Run it
Needs Node 20.6 or later and a Vercel AI Gateway key on the paid tier. The free tier limits Jev to a few calls.
npm install
echo AI_GATEWAY_API_KEY=your_key > .env
node --env-file=.env triage.mjs emails.json [--limit N] [--raw] [--resume]
Full runs checkpoint to a separate partial file after every email and replace the final output only after completion. --resume continues an interrupted full run. --limit N runs the first N records without writing output. --raw prints each full answer and metadata.
npm test runs the free deterministic checks and the held-out evaluation contract. npm run eval:live runs the same 12 cases against Jev and saves JSONL results under eval/.
The 41 emails from the journey came from the Gmail MCP search_threads tool: INBOX, last 90 days, snippets only. They are not in this repo.
Cost
About $0.00003 per email on the gateway. The 41-email run cost about $0.001.