AegisHeal: Building an AI Agent That Heals Production Services by Itself
2026-11-23 · 4 min read
The 3 AM problem
Most incident response still looks the same: an alert fires, someone wakes up, digs through logs, restarts something, and hopes it holds. Monitoring tools are very good at saying something broke. A human still has to work out why and what to do.
I wanted to see how much of that loop an AI agent could close safely. The result is AegisHeal, an open-source platform that monitors running services, detects failures, lets an agent analyse the root cause, picks a predefined recovery action, runs it, and only calls it fixed once the service is verifiably healthy.
The 7-step loop
- Monitor — three real micro-services run as separate OS processes. Health, response time, CPU, memory, error rate, failed jobs and dependency state are probed every 2 seconds.
- Detect — 7 rules: crash, error-rate spike, memory leak, CPU saturation, high latency, dependency loss and failing background jobs.
- Collect — logs, metrics and deployment history for the affected service.
- Analyse — an offline reasoning engine scores 7 failure signatures with evidence and a confidence score. Claude analysis is optional, with strict schema validation and a local second opinion.
- Decide — pick from 6 predefined actions: restart, roll back, clear cache, reconnect a dependency, retry failed operations, throttle workload.
- Recover — run the action.
- Verify — a recovery only counts after N consecutive healthy checks. If it fails, the agent tries the next best action or escalates to a human.
In the guided demo I break three services at once — a crash, a memory leak and a faulty release — and each one is diagnosed and recovered in roughly 2–5 seconds.
Guardrails matter more than intelligence
An agent that can restart production is scary. So most of the engineering went into what it is not allowed to do:
- Whitelisted actions only. The agent can never run an arbitrary command.
- Confidence threshold. Below it, the agent proposes instead of acting.
- Autonomy modes. Autonomous, Supervised (a human approves each action) and Observe-only.
- High-risk approval, max attempts, cooldowns, a circuit breaker and a blast-radius limit.
- A full audit log of every decision.
The lesson I keep coming back to: detecting failures is easy, fixing them automatically is hard, and fixing them safely is the real product.
It learns which fix works
Every incident records the success rate for each (failure, action) pair, and that re-ranks future decisions. If clearing the cache keeps fixing a particular memory pattern faster than a restart, it rises to the top of the playbook.
Engineering details
- React dashboard with live charts over Server-Sent Events, a 7-step pipeline view and an incident timeline.
- Node.js + Express API, JWT in httpOnly cookies, bcrypt, RBAC (admin / operator / viewer), zod validation on every input.
- A chaos lab that injects 7 real fault types.
- 143 automated tests, including end-to-end "break it and heal it" tests. It runs locally with no database server, no Docker and no API key.
What I'd build next
Real integrations (Kubernetes, systemd, cloud deploy APIs) behind the same guardrails, and richer verification that checks business metrics, not just health endpoints.
The code is open source under the MIT license on GitHub.