← All projects

Letter approval agent

An AI agent that reviews historical letters for Humanym. It decides about 8 in 10 on its own and asks me about the rest.

Why I built it

Humanym keeps a collection of historical letters, and we publish them on our website. Before a letter goes on the site, someone has to check it. Is it in the public domain? Is it really by the person named on it? Is it actually a letter? Could anything in it offend a reader? That someone was me, reading every letter by hand, and more than a thousand were waiting.

What it does

The agent does that reading first. It rejects letters that clearly break the rules, picks the ones that clearly pass, and asks me only about the rest, with the worrying passage highlighted. It never publishes anything itself. In trials on letters I had already marked, it decided about 8 in 10 without me, and the site went from 51 letters I had checked by hand to 322.

The agent's review screen: a letter waiting on me, with the score that made the agent ask and the passages behind it highlighted
A letter waiting on me. My answer goes back into the agent and it carries on.

How the agent works

  • Code checks the facts (the writer died before 1900, the edition was printed before 1931, it isn’t a duplicate) before any model reads the letter.
  • Claude reads the whole letter and finds quotes for and against each rule. Code drops any quote that isn’t really in the letter.
  • Jev, TypeSafe AI’s typed-decision model, answers 16 small yes/no questions. My thresholds turn those answers into reject, pick or ask me.
The writer graph, the letter graph and the picking step, with which nodes are code, which use Claude, which use Jev, and where the reviewer answers
Two LangGraph.js graphs, one per writer and one per letter, sharing one checkpointer.

How I built it

I wrote every rule in my own words, with my own examples of what is fine and what isn’t, and made it strict on purpose, so when it is in doubt it asks me. Before it could publish letters I hadn’t read, it had to pass a trust test: approve none of a set of letters I had marked not fine. Then I tuned it one change at a time. I reworded rules, split broad ones into narrower questions and adjusted thresholds, and after each change I tested it against letters I had already marked and read the letters behind the numbers. My own wording moved more letters than any threshold did.

Claude Code wrote most of the code, the tests and the trial tools. I built the core of the graph myself, typing it in one piece at a time while Claude walked me through each part. There are 257 tests, and they run in about 2 seconds.