🛡 Harden Your Agent

Free · 6 lessons + epilogue · TypeScript · A real agent

Your agent works.
Now harden it.

Take a small TypeScript agent for a guesthouse and add, one lesson at a time, the defences a real product needs: boundaries, an intent anchor, a render and fetch policy, identity, idempotency, and memory you can trust. Each defence is a small module, switchable, and proved by a test you can run.

npm run lesson5
you    Refund Lena the £15 cot fee on BK-1043.

── Once OFF ─────────────────────────────
tool → issue_refund(BK-1043, £15)  ← Refunded £15.00 (R-0001)
tool → issue_refund(BK-1043, £15)  ← Refunded £15.00 (R-0002)
ledger: 2 refunds, £30.00        the guest was paid twice

── Once ON ──────────────────────────────
tool → issue_refund(BK-1043, £15)  ← Refunded £15.00 (R-0001)
tool → issue_refund(BK-1043, £15)  ✗ Already done. Nothing new refunded.
ledger: 1 refund, £15.00        safe to retry

A real agent, not snippets

A staff assistant for a small guesthouse: an inbox, partner pages, bookings, a refunds ledger and notes on disk. Run it with npm start.

No API key to start

Every lesson and the app run in replay mode with pre-written model turns. The loop, the tools and all six defences are the real code. Add a key to run it live.

Each defence is a test

npm run harden-check runs a corpus of fixtures through the code-level defences with a pass/fail table, meant for CI.

The lessons

Run it in a minute

git clone https://github.com/georgehanu/harden-your-agent.git
cd harden-your-agent
npm install
npm run lesson1

Node.js 20 or newer. Then try npm start and open http://localhost:3100.

Hi, I'm George.

I'm a senior web developer. I teach developers to build software with AI, from useful scripts to app features. Small examples, explained clearly. This builds on The Agent Loop: there you build an agent; here you make one safe enough to ship. If it helped, the best thanks is a follow.

Follow @georgehanu on X