The agentic test pyramid
Key takeaway: Push each check as low and as deterministic as it will go, and never block a merge on a test that can fail by chance.
Martin Fowler’s test pyramid still holds for the deterministic parts of your system. Once a model is part of the system, add layers on top for the parts that won’t answer the same way twice, and never let those layers gate a merge.
The pyramid sorts tests by scope, and it quietly assumes every test gives the same answer every run. Run the same prompt twice and you might get different words, a different number of findings, or a different tool call. You can’t assertEqual through that, and you can’t block a merge on a check that’s red 8% of the time for no reason.
So keep the original layers: pure unit, in-process integration, and real-dependency end-to-end. Mock what’s around the code, never the code under test. Then add two on top. Behavior tests against the live model, like “given read-only mode, the agent must never call the write tool.” And model-graded evals for output that’s actually subjective.
Most suites also lack a layer near the bottom: tripwires. A tripwire reads your own source and asserts a contract with a pattern match, like “nothing under src/ui imports the database client.” It runs in milliseconds. When you write a comment that says “NEVER do X here,” write the tripwire in the same change. Contracts stay deterministic even when behavior doesn’t.
For any test that calls the model, ask whether it can be red for a reason that isn’t a bug. If it can’t, it gates merges. If it can, it runs on a schedule. Grade those against a range, not an exact answer. Plant ten known vulnerabilities and require the review to catch at least eight with no more than three false alarms.
You don’t need all of it on day one. Draw the free/paid line so your default test command never spends money:
{
"scripts": {
"test": "node --test 'test/**/*.test.ts'",
"test:paid": "node --test 'evals/**/*.eval.ts'"
}
}
Then build a wide unit base and start the tripwire habit. Some of your tests are measurements now, not pass/fail checks, so keep track of which.