The problem
§01Building an AI agent on Dify, n8n, or LangChain is now trivially easy. Keeping it behaving — consistently, safely, accurately — in production is not. AI engineers spend their days hand-tuning temperature, rewriting system prompts to patch one-off hallucinations, and bolting on brittle keyword filters to stop the next prompt injection. The observability tools they reach for — Langfuse, Helicone, Datadog — are excellent at logging the failure and powerless to fix it.
Existing tools act as AI web-application firewalls. When an attack or hallucination occurs, they block it and throw an error — leaving the developer with a broken user experience and the same flawed system prompt sitting in production, waiting to be exploited again.
The thesis
§02The industry is waiting for automation at the meta-layer: an AI application that monitors, evaluates, and automatically fixes other AI applications. Data-governance and logging solutions exist; the self-healing optimisation layer is open white space. The unclaimed value isn't reactive blocking — it's asynchronous, automated system remediation. Self-healing prompt engineering.
- Wedge
- Independent builders and mid-market SaaS teams on Dify / n8n / LiteLLM — too small for Datadog AI Guard or a Cloudflare/Kong gateway, too serious to keep hand-patching prompts.
- Non-negotiable
- Zero added latency on the live request. The platform must sit entirely off the synchronous execution path of the customer's user-facing app.
- Compliance posture
- A UK data processor under UK GDPR / DPA 2018. PII is hashed or redacted at the edge before any payload is written, and logs carry a programmatic time-to-live.
The architecture
§03A three-tier asynchronous “healing engine”. The customer's workflow sends a log to an ingest webhook; the route authenticates, scrubs PII, and schedules the database write with Next.js's after() — so it returns 200 OK the instant it has the payload, never blocking the live app. Evaluation then happens off that path:
- Ingest. A single webhook (
POST /api/v1/ingest), authenticated by anX-API-Key. Tolerant payload parsing accepts flat or OpenAI-stylemessagesshapes from any platform. - Edge PII scrub. Emails, cards, phone numbers, NI numbers and IPs are regex-redacted to typed placeholders before the row is written — data minimisation, not after-the-fact cleanup.
- The judge.A background model grades each exchange against the project's guardrails — hallucination, prompt injection, PII leak, competitor mention — and flags violations.
- Self-heal. On a violation it generates a hardened replacement system prompt. The dashboard shows the diff with a one-click Copy Fix.
The judge is swappable behind one interface. A deterministic heuristic implementation runs with no API key at all (so the product is visibly working from day one); the moment an ANTHROPIC_API_KEY is present it switches itself to live Claude Haiku 4.5 — same shape, real judgement, zero code change.
What it ships
§04Tenants sign in, mint per-project API keys, and watch a live feed of graded calls — every row resolving to passed or violation, each violation carrying an explanation and a copy-pasteable healed prompt. Postgres row-level security scopes every tenant to their own data; evaluation runs inline the instant an agent posts a log, so the dashboard lights up within a second with no scheduler in the loop.
Stack
§05- Next.js 16 App Router on Vercel's edge network
- Host-based subdomain routing (sentinelproxy.tomphillips.uk)
- Glass + Paper dashboard, native cursor restored
- Edge webhook, X-API-Key auth, instant 200
- after() defers the write + evaluation
- Regex PII redaction before persistence
- Supabase Postgres, sentinel_* schema
- Row-level security per organisation
- Partial index on logs awaiting the judge
- Pluggable: demo heuristics ↔ Claude Haiku 4.5
- Auto-switches on ANTHROPIC_API_KEY, no redeploy logic
- Generates hardened prompt diffs per violation
What's next
§06- A guardrail-config UI — the rules table is already honoured by the judge; surface per-project toggles so teams choose what gets enforced.
- PromptBreaker — a public, Gandalf-style playground that red-teams a pasted system prompt live, as a zero-cost acquisition wedge.
- Programmatic log TTL (free: 3 days, pro: 30) via pg_cron, plus ICO registration before commercial tiers open.
- A certified Dify extension to package the log receiver where the high-intent users already are.