Inspiration

On 5 November a bug report reached the top of Hacker News: a popular AI coding agent had been sending its users' email addresses to the websites it visited. It had been doing so for a while. Nobody noticed, because the only account of what an agent does is the one the agent gives.

That is the gap. Developers now hand an agent their code, their keys and their accounts, and let it work for hours. They are left with two choices: approve a prompt every half minute, or switch the prompts off and hope. Anthropic has said people approve 93 percent of those prompts anyway. And the agent that has been fooled by a hidden instruction on a web page is the same one deciding whether to ask.

I wanted a second pair of eyes that sits outside the agent.

What it does

Rehearsal wraps any AI coding agent in one command:

rehearse claude

You use the agent as usual. Rehearsal sits between it and the internet.

  • It holds what reaches outside your machine. Pushes, publishes, deletions on remote services, and any request carrying one of your secrets are held. The agent is told they worked, so it keeps going. When it finishes, you see one list, each action described in plain words and ranked by risk. Only what you tick is performed.
  • It shows who learned what about you. Every server the agent contacted, and which of your details, keys and planted canary values reached each one, in plain or encoded form.
  • It checks the agent's story. What the agent's last message claimed is set against the commands it was seen to run.
  • It sorts what the agent changed into parts to read, parts to skim and mechanical ones, with the rule that put each there.
  • It keeps a record that cannot be edited without it showing. Entries are hash-chained and the session is signed. Change one character and the check names the entry.
  • It investigates afterwards. rehearse investigate reconstructs what happened: where an address came from, what left, in what order. Every statement links to the raw log entries it rests on, with the supporting part marked.

A model running on your own computer writes the plain-language descriptions and answers questions about the record. It can raise a risk rating and never lower one, and any answer that cites no log entry is discarded. With no model at all, everything still works: the decisions are rules.

How I built it

  • The core is a Go program. It runs the agent with a local intercepting proxy in front of it and with stand-ins for git, gh, npm and pip on its path, so both network requests and commands pass through it.
  • Each held action is classified by rules, which set a minimum risk the model cannot lower.
  • The record is an append-only log in which every entry carries the hash of the one before. An Ed25519 signature seals it when the session ends. Only the standard library's cryptography is used.
  • Secrets are never stored. A salted hash of each watched value is kept, and outgoing data is hashed in plain, URL-encoded, base64 and hexadecimal forms to find a match.
  • The local model is reached through Ollama with structured output, so its answers always have the same shape.
  • The interface is a Vue page served by the program: a sidebar of sessions, the held actions with a detail pane beside them, and an Investigate view where each finding opens the log entries it rests on.
  • A demo world of three local servers (a cloud host with a deletable database, an attacker's inbox, a package registry with a malicious package) makes the whole thing safe to show.

Challenges

  • Telling an agent "that worked" when it didn't. Some held requests are ones the agent needs a real answer to. Those are labelled, and it remains a real limit.
  • False alarms. A tool that holds too much gets switched off. Early versions held every link an agent followed from a web page. Getting ordinary work through untouched took as long as catching the attacks.
  • Keeping the model away from the facts. It was tempting to let the model decide what is risky. I kept it to describing and to raising ratings, and wrote tests in which a planted instruction tells the model to mark everything as safe.
  • Evidence without storing secrets. Proving that an encoded value left the machine, when the record must never contain that value, needed two hashes computed separately.
  • An interface that says the most serious thing first. The decision screen opens with one sentence naming the worst thing the agent tried, before any list.

Accomplishments

  • On the scenarios in the repository, rehearse bench reports 16 of 16 attacks stopped and none of 11 ordinary sessions wrongly held as high risk.
  • The investigation rebuilt the chain of events in 16 of 16 attack scenarios. A plain-text search for the leaked value finds 8 of the 10 leaks; the rules find all 10, including the two that left encoded.
  • The sorting of changes put 23 of 23 parts labelled "read" where a person would read them.
  • I ran real Claude Code on the demo project three times. It recognised the hidden instruction and refused it each time, and all three session records verified.

These scenarios are synthetic and I wrote them. They show that the rules do what they were written to do. They are not a measure of how the tool fares against an attack nobody wrote down, and the README says so.

What I learned

  • An agent cannot be its own supervisor, however capable it is. The useful question is not how intelligent the checker is but where it stands.
  • People do not read. A safety tool has to be safe for someone who looks at one sentence and presses the button.
  • Being exact about what was measured, and what was not, made the project easier to defend than any larger claim would have.

What's next

  • Run it against more agents and publish what each one sends, by version.
  • A one-file format so anyone can add a new thing to catch.
  • HOLD, VETO and STOP across every agent on a machine, whichever company made it.
  • macOS support, and a score on sessions written by someone else.

Built With

Share this project:

Updates

Submission history