Building an Autonomous Site Reliability Agent: Evidence-Driven Incident Investigation with Human-Approved Remediation for Kubernetes

How I built a multi-agent SRE system that investigates Kubernetes incidents from evidence alone, keeps the evidence that Kubernetes forgets, and applies a fix only after human approval and objective verification.

11 November 202611 min read
kubernetessreai-agentsincident-responsellmslackpostgresqlprometheusaiops
Building an Autonomous Site Reliability Agent: Evidence-Driven Incident Investigation with Human-Approved Remediation for Kubernetes

Evidence first, humans in control, and a verifier that is allowed to say "not resolved".

When a production service breaks, most of the incident is not spent fixing it. It is spent understanding it. An on-call engineer pulls pod states, container logs, events, configuration and metrics by hand, and only then forms a hypothesis. Much of that evidence is short-lived. Kubernetes keeps only a container's current and previous run, forgets a deleted pod at once and expires events after about an hour.

SRE Agent is the multi-agent system I built as my major project (BCS705) at BMS Institute of Technology and Management. It takes an incident from the first symptom to a verified fix, and it is validated on a live Kubernetes application into which failures are injected by scripts that never tell the system what broke.

Source code: github.com/UmashankarGouda/SRE_Agent


Why This Project?

Existing tools each stop short of the whole job:

  • Monitoring raises alerts without explaining them.
  • Graph-based root-cause methods name a suspicious service, but not why it failed, and they need metrics that may already be gone.
  • LLM assistants write fluent explanations that cannot always be traced back to the real state of the system.
  • Very few tools carry an incident safely from diagnosis to a verified fix. Remediation is the least explored stage of AIOps.

I wanted a system that treats evidence as the single source of truth, keeps every executable action deterministic, puts a human in control of every change, and reports honestly when a fix did not work.


How It Works

Detection (symptoms only)
   -> Incident context -> Investigation planner <-> Read-only capabilities (Kubernetes / Prometheus)
   -> Facts -> Diagnosis (taxonomy, scoring, dependency chaining) -> Timeline + impact -> Report
   -> Hybrid routing: rules lead  --or--  LLM Investigator Agent leads
   -> Typed remediation plan -> Slack review (per action, bound to the plan digest)
   -> Execute: policy -> claim -> live recheck -> dry run -> ONE typed change
   -> Verification: RESOLVED | NOT_RESOLVED | INCONCLUSIVE (rollback offered on failure)

The Agents and Their Authority

Each agent has a narrow job and limited power:

AgentJobAuthority
DetectorSamples the system every 5 s and opens an incident when a symptom persists over two pollsReports symptoms only, never causes
Evidence recorderKeeps logs of earlier runs, deleted pods, expired events and configuration versions for 24 h in SQLiteRead-only observer
Rule enginePlans which evidence to collect, records facts, diagnoses, rebuilds the timeline and impactDeterministic, read-only
Investigator Agent (LLM)Verifies the rules on familiar incidents and leads on unfamiliar onesRead-only; every citation is checked in code
Remediation plannerTurns the diagnosis into a typed, evidence-backed planExecutes nothing
Remediation AgentReplaces the two Slack clicks, but only for high-confidence, low-risk fixesAt most 3 attempts, automatic revert, circuit breaker
EngineerApproves, rejects or defers each action, and presses ExecuteFinal authority over every change the policy gate does not cover

Key Design Decisions

1. Scenario-Blind Investigation

The investigator never receives a hint about the injected failure. No scenario flag exists anywhere in the investigation path, and a test asserts that. The system has to work out what broke from evidence alone.

2. Facts Before Interpretation

Every observation becomes a fact with an ID, a source, a subject and a time basis. Diagnosis cites facts; it does not invent them. Each component is then scored against a general failure taxonomy of eight categories, including memory exhaustion, application crash, dependency misconfiguration, dependency unavailable, image pull failure and health-check failure.

Confidence is a simple, explicit formula. It takes the score of the primary finding and penalises it by the strongest competing finding, so a diagnosis with a close alternative shows lower confidence:

c = min(0.97, max(0.05, s1 * (1 - 0.5 * s2)))

Here s1 is the primary finding's score and s2 the strongest independent competing finding. The result is multiplied by 0.9 if any capability call failed.

3. Root Cause vs Impact

A consumer that fails because its database is down is impacted, not the cause. Findings are chained along a dependency graph derived from configuration, so the system does not pick the most visible symptom as the root cause when a downstream dependency explains it.

4. Honest Timelines

Kubernetes timestamps are not always exact, and pretending otherwise misleads the reader. Every time is printed only as precisely as it is known:

  • an exact time prints as one time;
  • a bounded time prints as a range;
  • an observed-only time prints as "at or before";
  • an event before the investigation window prints as "before window".

Ordering is claimed only when intervals do not overlap, and "A preceded B" is never reported as "A caused B".

5. Provider-Independent Reasoning

The reasoning code talks to a neutral, read-only capability interface such as get_logs, get_events or get_configuration. Kubernetes and Prometheus sit behind adapters. Architecture tests enforce that provider-specific code and vocabulary stay out of the reasoning layer. Kubernetes is the only provider implemented so far, so the second-provider claim is designed and tested, but not yet demonstrated.


The LLM, Kept on a Short Leash

I used an LLM, but as a verifier and a fallback, not as the source of truth.

  • The Investigator Agent is read-only. It has tools to query the same capabilities as the rule engine.
  • Every citation it produces is validated in code against the facts it actually collected. A citation to a fact that does not exist is rejected.
  • The executable action never comes from the model. It comes from the deterministic planner.
  • Routing is hybrid. If the rules reach at least 75% confidence on a known pattern, they lead and the agent only verifies it, with at most 5 tool calls. Otherwise the agent leads, with at most 14 tool calls.

The cost difference justified this routing. Measured live, leading cost about 180 s and 89k tokens, against about 37 s and 21k for verifying.


Human-Approved Remediation

A diagnosis is not a fix. The remediation loop is deliberately strict:

  1. The planner produces a typed plan. Actions are constrained operations such as scaling a deployment or changing a memory limit, not arbitrary shell commands.
  2. The engineer reviews each action in Slack. Every decision is bound to the digest of the exact plan, so an approval cannot quietly apply to a different plan.
  3. A separate Execute step runs a policy check, a live recheck of the system state and a dry run, then applies exactly one change.
  4. Verification compares the outcome with the plan's own success criteria and reports one of three verdicts: RESOLVED, NOT_RESOLVED or INCONCLUSIVE.

If the fix did not work, the system offers a typed rollback plan. The rollback needs its own approval and its own Execute. Approval alone executes nothing.

The verifier is designed not to turn doubt into success. In one live run the change itself worked, but about 50 seconds later both backend pods stalled together, coinciding with a PostgreSQL checkpoint, and the error ratio peaked at 15.1%. The plan's criterion said errors must stay below 5%, so the correct verdict was NOT_RESOLVED, even though the change had been applied correctly.

A separate Remediation Agent can act without a click, but only for high-confidence, low-risk fixes, with a gate threshold of 85%. It has at most three attempts, reverts any change it cannot verify, and stops after repeated failures.


Live Validation

The test application was a small shop: a frontend, a two-replica backend and PostgreSQL, under a steady 100 requests per second of load. I injected failures with scripts, including out-of-memory kills, a database outage, a wrong database host, stale credentials, a broken image release and a memory limit set too low.

A few results from the live runs:

  • Retained evidence changed the diagnosis. After an out-of-memory incident where both pods were replaced, the live state looked healthy and the diagnosis without history was undetermined. With the recorder's retained kills and memory-warning logs, it became memory exhaustion in the backend, 85%.
  • A wrong diagnosis became correct. For a database outage that had already recovered, the rules first blamed an application crash. With the recorded availability history, the system identified PostgreSQL as the root cause, with the backend affected and the frontend impacted.
  • Stale credentials were found by the agent. The rule engine was only 60% confident and pointed at the wrong setting. The Investigator Agent, leading, read the configuration history and found the rotated Secret, without ever revealing the secret's value.
  • Fixes were verified, and failures were reported as failures. Approved fixes for the database host and for a memory limit were verified as RESOLVED. A deliberately insufficient memory fix was reported as NOT_RESOLVED after eight new kills, then rolled back under a separate approval.
  • The Remediation Agent acted alone twice. It resolved a database outage by scaling the deployment back to one replica, and it raised a memory limit that was set too low. Both happened without a human click. It refused a sustained overload, where a human had to decide.

All 252 automated tests pass offline in about 18 seconds, including architecture tests that enforce the provider and write boundaries.


Tech Stack

Core

  • Python 3.12 for the detector, planner, investigator, executor and verifier
  • Kubernetes (minikube) as the system under investigation
  • Prometheus for request rate, error ratio and memory working set
  • SQLite for the evidence recorder and the audit trail of reviews

Interfaces

  • Slack (Socket Mode) for per-action review
  • Web console on port 8800 that mirrors every Slack decision
  • NVIDIA NIM as the LLM behind the Investigator Agent

Test application

  • Frontend gateway, two-replica backend (orders API and invoice job) and PostgreSQL, with a load generator and failure-injection PowerShell scripts

What I Learned

  • Evidence that disappears is the real problem. Most of the difficulty was not reasoning. It was noticing that the decisive evidence was gone by the time anyone looked, which is why the recorder exists.
  • An honest "undetermined" is better than a confident wrong answer. Confidence drops when competing explanations exist, and the system says "undetermined" rather than guessing.
  • Verification has to be able to fail. A verifier that always says "resolved" is worse than none. The NOT_RESOLVED verdicts are what make the RESOLVED verdicts believable.
  • Pin the human's approval to an exact plan. A click that approves "the fix" is ambiguous. Binding it to a digest makes the approval mean something.
  • LLMs are most useful where rules are weakest. On known patterns the rules were enough. The agent earned its cost on the unfamiliar incident.

Limitations

I want to be direct about what this does not yet do:

  • Only Kubernetes is implemented. Provider independence is enforced in the design, but not yet demonstrated with a second provider.
  • Verification checks the observed state, not the cause. An unrelated stall can produce NOT_RESOLVED, and a recovery unrelated to the change can produce RESOLVED.
  • The live results are demonstrations, not statistics. I have not yet measured mean time to recovery with and without the system.
  • Nothing is recorded while the recorder is not running, and log lines from the last few seconds before a pod is deleted can be lost.
  • Memory metrics are sparse under load, so the application's own memory logs are stronger evidence.

Future Work

The next steps follow the project's roadmap:

  • A second infrastructure provider, such as AWS or GCP, to test the provider-independent design for real
  • Measuring MTTR with and without the system on repeated injected incidents
  • Turning the timeline's "metric threshold crossings" into full timeline entries, which the report lists as not yet implemented

Try It Yourself

The repository has the Kubernetes manifests for the test application, the failure-injection scripts and the full test suite. The README in the SRE_Agent repository has the setup steps.

git clone https://github.com/UmashankarGouda/SRE_Agent.git
cd SRE_Agent
python -m pip install -r requirements.txt
python -m pytest

Conclusion

This project started from a simple frustration: incidents spend most of their time being understood, and the evidence needed to understand them keeps disappearing. The system I built keeps that evidence, reasons from facts it can cite, tells the engineer exactly what it will change, and reports honestly whether the change worked.

It is a research prototype, not a production product. But the core loop works end to end on a live cluster, with failures the system was never told about, and that was the point of building it.