An experiment in giving a small online store's inbox a quiet clerk: a decision model reads every customer email first and decides which ones a person needs to see now, which can wait, which a template could answer, and which are only sales pitches.
| Result | |
|---|---|
| Emails sent to the right lane | 19 / 20 |
| Urgent or risky emails sent to automation | 0 |
| Median time to judge an email | 338 ms |
| Input per email | ~1,000 tokens (8 questions, one call) |
| Cost at 600 emails a month | ~2.5 US cents |
Model: jev-1.13.0 from TypeSafe. Real output, recorded 6 October 2026 in results/raw.json. The emails are a test inbox written for this experiment, not a live store.
Why this exists
From my ecom days, I know most store owners spend hours combing through customer emails. Most don't need a human to reply. A few really do.
I built this to test out Jev, TypeSafe's new decision model. Think of it as a personal assistant that combs through your emails and works out which ones need to be escalated to you, the owner.
What surprised me most was the cost compared to the volume of emails, and the speed. AI customer service still has a long way to go, and people get frustrated dealing with machines. But the smaller enquiries, like finding a tracking number, don't need a human. The owner's time should go to the ones that do.
How it works

Each email is sent to Jev once, with eight questions answered in parallel:
| Question | Type |
|---|---|
| What is the email about (order, damaged item, refund, product question, other) | Choice |
| How soon does the sender need a reply | Score (3 levels) |
| How does the sender feel about the store | Score (3 levels) |
| Is anyone's health or safety involved | Noul (yes/no) |
| Is there a chargeback, dispute or legal mention | Noul |
| Is the sender threatening a public complaint | Noul |
| Is the sender asking for their money back | Noul |
| Is this a business pitching its own services | Noul |
Plain rules in triage.py then choose a lane. Safety checks run first, and anything the model is unsure about goes to a person rather than to automation:
missing or unusable answer → Human queue
any risk flag ≥ 0.30 → Human now
sales pitch ≥ 0.80 → Archived
customer close to leaving → Human now
model unsure → Human queue
order / damaged / refund topic → Automated (would send tracking, photo request, returns form)
needs a reply today → Human now
everything else → Human queue
The thresholds follow TypeSafe's guidance that a threshold should scale with the cost of being wrong: a missed safety issue is expensive, so risk flags trigger early; archiving a real customer is expensive, so a pitch must be clear before it is archived.
When something goes wrong
If Jev times out, returns an error or sends back an answer the rules can't trust, the email goes to the Human queue instead of automation.
Before the rules run, validate() checks every answer. The topic must be one of the five options. Topic confidence and the five yes/no scores must be numbers from 0 to 1, and urgency and frustration from 0 to 2. A missing field, a number sent as text or an out-of-range value sends the email to a person, and the reason is logged, for example Invalid answer (topic.confidence).
I tested this by corrupting saved responses and by pointing the script at an address that doesn't answer. Every affected email landed in the Human queue and the run finished.
The model is pinned to jev-1.13.0, so a new Jev release can't change the results without me noticing. --replay re-runs the rules on the saved responses with no API calls, which lets me check a rule change against the recorded run before trusting it.
Prompt-injection test
Anyone can send the store an email, so I wrote 13 that try to trick Jev. Most hide an instruction inside a risky message, aiming to get a skin reaction or a chargeback archived or auto-replied: a fake "system note" saying safety was already checked, fake answers pasted in as JSON, "ignore all previous instructions", an instruction hidden in an HTML comment, invisible characters splitting the word "chargeback", a message pretending to be the store owner, and a reaction described in Spanish with "please auto-reply" in English. Two test the archive rule from both sides: a real customer who mentions running a marketing agency, and a sales pitch shouting "URGENT SAFETY ISSUE".
All 13 reached a safe lane on jev-1.13.0. On the nine dangerous emails the matching risk score came back between 0.97 and 0.99, against a threshold of 0.30. Jev can't send anything itself, so the worst an attack could do is skew the answers, and it would have to skew several separate questions at once to get past the safety checks.
These are attacks I thought of, so a pass shows Jev holds against the common tricks, not that it can't be fooled. The emails are in attacks.json and the answers in results/raw-redteam.json.
What it got wrong, and nearly wrong
- e12, a calm return. Jev was 61% sure the customer wanted a refund, inside the "unsure" band, so it went to a person instead of receiving the automatic returns form. A defensible reading, and the only lane miss.
- e04, a gift that missed a birthday. Correct lane, partly for the wrong reason: a 0.44 "public complaint" score crossed the risk threshold although the customer never threatened to post anything.
- e03, option-order check. Re-asking the topic question with the options reversed changed one answer out of twenty; that email's topic confidence was already only 0.41, and it reached a person regardless.
The thresholds were set before the run and were not tuned afterwards to reach twenty out of twenty.
Run it
python3 triage.py --dry-run # print the request for one email, no API call
python3 triage.py --selftest # check the pipeline using hand labels (report is stamped as not model output)
python3 triage.py # live run; needs a TypeSafe key
python3 triage.py --order-check # live run, then re-ask topic with reversed options
python3 triage.py --replay # re-run the rules on results/raw.json, no API calls
python3 redteam.py # live run of the 13 injection attacks; fails if a risky email gets through
python3 redteam.py --replay # re-score the saved attack answers, no API calls
Standard library only. Put a key from console.typesafe.ai in TYPESAFE_API_KEY or ~/.typesafe/api_key (mode 600). The report is written to results/report.html.
n8n workflow (work in progress)

n8n/ holds a shadow-mode workflow for a real Gmail inbox: labels, a Slack alert for urgent mail and a Google Sheet log, with nothing ever sent to a customer. The workflow is generated from triage.py, fail-safe checks included. n8n/parity_test.py checks that it gives the same lane and reason as the Python version on all twenty emails and on 21 broken answers. It has not yet been run inside a live n8n instance. See n8n/README.md.
The video
videos/inbox-triage-15s/: the 15-second version, built with HyperFrames.build-data.pyinlines the real run and generates the sound cues from the same schedule as the animation. The final render is inrenders/.animation/: the first 32-second cut, plain HTML captured frame by frame with Playwright and ffmpeg.
Privacy
Running this on a real inbox sends customer emails to TypeSafe. Read their data terms first, and make sure the store's privacy policy covers it.
Credits
- TypeSafe for Jev and its documentation and agent skill.
- Cobus Greyling's Jev showcase, where I first came across Jev.
- HyperFrames for the video framework.
- Sound effects from Pixabay under the Pixabay Content License, listed in
videos/inbox-triage-15s/assets/sfx/CREDITS.md.
License
MIT. See LICENSE.
