Autonomous agent for Kubernetes incident detection, diagnosis, and mitigation using LLMs and modular workflows. Integrates LangChain, LangGraph, and MCP servers to enable automated SRE tasks in cloud-native environments.
Agent-Based SRE: Automated Diagnosis and Mitigation in K8s
sre-agent is an autonomous multi-agent system designed to automate Incident Response in Kubernetes environments. By leveraging Large Language Models (LLMs) and a Divide & Conquer strategy, it significantly reduces the Mean Time to Resolution (MTTR) for complex microservice faults.
This system integrates with AIOpsLab for realistic fault injection and uses a custom Model Context Protocol (MCP) server to interface with observability tools (Prometheus, Jaeger, Kubernetes API) securely and efficiently.
๐ Repository Structure
SRE-agent/
โโโ sre-agent/ # ๐ง Main Multi-Agent System implementation (LangGraph)
โโโ MCP-server/ # ๐ Custom Model Context Protocol server for observability tools
โโโ notebooks/ # ๐ Jupyter notebooks for analysis and development
โโโ Results/ # ๐ Experiment outputs, logs, and reports
โโโ archive/ # ๐ฆ Archive of previous project iterations
โโโ assets/ # ๐ผ๏ธ Diagrams and static assets
๐ค SRE Agent Architecture
The agent implements a parallel multi-agent workflow to diagnose faults efficiently:

Core Components
- ๐ Triage Agent (Hybrid)
- ๐ Planner Agent (Topology-Aware)
- ๐ฌ RCA Workers (Parallel Execution)
- ๐ Supervisor Agent
Key Features
- Datagraph: A graph representation of the cluster topology (Infrastructure & Data dependencies) that guides the agent, preventing irrelevant resource exploration.
- Custom MCP Server: Standardizes tool interaction and performs "pre-digestion" of data (e.g., retrieving only relevant metrics or error logs) to optimize context window usage and reduce token costs.
๐งช Automated Evaluation Pipeline
The repository includes a robust pipeline for automated experimentation and benchmarking.
Framework
- Integration: Built on top of AIOpsLab to deploy testbeds (Hotel Reservation, Social Network) and inject realistic faults (Network delays, Pod failures, Misconfigurations).
- Batch Execution:
automated_experiment.pyorchestrates end-to-end batch runs: Cluster Setup โ Fault Injection โ Agent Execution โ Evaluation โ Cleanup.
Metrics
The system is evaluated on:- Detection Accuracy: Correct identification of an anomaly.
- Localization Accuracy: Correct identification of the root cause resource (Service/Pod).
- RCA Score: Semantic evaluation of the diagnosis using LLM-as-a-Judge (1-5 scale with rationale).
๐ ๏ธ Setup & Usage
Prerequisites
- Python 3.13+ & Poetry
- Docker & Kind (Kubernetes in Docker)
- Make (for AIOpsLab commands)
- OpenAI API Key (for GPT-5-mini)
Installation
# Clone the repository
git clone https://github.com/martinimarcello00/SRE-agent.git
cd SRE-agent
Install dependencies
poetry install
Configure environment
cp .env.example .env
Edit .env and add your API keys:
nano .env
Running the Agent
You can run the agent interactively via LangGraph Studio or as a script.
Option A: LangGraph Studio (Recommended for Dev)
cd sre-agent poetry run langgraph dev
Option B: Python Script
# Run a specific experiment scenario python sre-agent/sre-agent.py
Running Automated Experiments
To execute a batch of experiments defined in your configuration:
# Ensure your .env file is configured
python automated_experiment.py
This script will sequentially provision the cluster, inject faults, run the agent, and save the results in Results/.