2025-06-27 09:05:16 +02:00
2025-06-25 15:27:34 +02:00
2025-06-27 09:05:16 +02:00
2025-06-25 15:27:34 +02:00
2025-06-26 14:52:36 +02:00
2025-06-26 14:52:36 +02:00
2025-06-26 14:52:36 +02:00

LangGraph Sysadmin AI Agents

This repository demonstrates two different approaches to building AI-powered system administration agents using LangGraph:

<EFBFBD> Two Approaches Available

1. Simple ReAct Agent (simple-react-agent/)

A straightforward single-agent approach using the ReAct (Reasoning and Acting) pattern.

Best for:

  • Learning LangGraph fundamentals
  • Simple log analysis tasks
  • Resource-constrained environments
  • Quick prototyping

2. Multi-Agent Supervisor (multi-agent-supervisor/)

A sophisticated system with multiple agents coordinated by a supervisor.

Best for:

  • Complex system administration tasks
  • Comprehensive system analysis
  • Production environments
  • When you need domain expertise

🤔 Which Approach Should You Choose?

Factor Simple ReAct Multi-Agent Supervisor
Complexity Low High
Setup Time Quick More involved
Resource Usage Light Heavy
Specialization General purpose Domain experts
Parallel Processing No Yes
Risk Assessment Basic Advanced
Debugging Easy More complex
Extensibility Limited Highly extensible

📊 Feature Comparison

Simple ReAct Agent

✅ Single agent handles all tasks
✅ Easy to understand and debug
✅ Low resource usage
✅ Quick setup
✅ Interactive chat with streaming
❌ No specialization
❌ Sequential processing only
❌ Limited scaling for complex tasks

Multi-Agent Supervisor

✅ Specialized domain experts
✅ Parallel processing
✅ Intelligent task delegation
✅ Risk assessment and severity scoring
✅ Comprehensive analysis
✅ Highly extensible
❌ More complex setup
❌ Higher resource usage
❌ Coordination overhead

🛠 Setup

Both approaches require the same base dependencies:

# Install dependencies
pip install langchain-openai langgraph langchain-community

# For multi-agent supervisor, also install:
pip install langgraph-supervisor

# Set your OpenAI API key
export OPENAI_API_KEY="your-api-key-here"

📁 Directory Structure

├── simple-react-agent/          # Single ReAct agent approach
│   ├── main.py                  # Main application
│   ├── log_analyzer.py          # Log analysis tool
│   ├── loghub/                  # → symlink to ../loghub
│   └── README.md               # Detailed documentation
│
├── multi-agent-supervisor/      # Multi-agent supervisor approach
│   ├── main-multi-agent.py     # Multi-agent implementation
│   ├── loghub/                 # → symlink to ../loghub
│   └── README.md               # Detailed documentation
│
├── loghub/                      # Sample log files
│   ├── Apache/
│   ├── Linux/
│   ├── Nginx/
│   └── ... (various system logs)
│
└── README.md                   # This file

🚀 Quick Start

Try the Simple ReAct Agent

cd simple-react-agent
python main.py

Try the Multi-Agent Supervisor

cd multi-agent-supervisor
python main-multi-agent.py

💡 Example Use Cases

Simple ReAct Agent Examples

"Analyze the Apache logs for error patterns"
"Check disk usage on the system"
"List all available log files"
"Find timeline patterns in Linux logs"

Multi-Agent Supervisor Examples

"Nginx returns 502 Bad Gateway - diagnose the issue"
"Perform a comprehensive system health check"
"Analyze all services and provide a risk assessment"
"Check for security vulnerabilities and suggest hardening"

🧪 Sample Logs Available

The loghub/ directory contains sample logs from various systems:

  • Web Servers: Apache, Nginx
  • Operating Systems: Linux, Mac, Windows
  • Big Data: Hadoop, HDFS, Spark
  • Databases: Various database logs
  • Applications: Health apps, mobile apps
  • Security: SSH, authentication logs

🔍 Decision Guide

Choose Simple ReAct Agent if:

  • You're new to LangGraph
  • You need basic log analysis
  • You have limited computational resources
  • You prefer simplicity and transparency
  • You're building a proof of concept

Choose Multi-Agent Supervisor if:

  • You need comprehensive system analysis
  • You're working with multiple services
  • You want parallel processing
  • You need risk assessment capabilities
  • You're building a production system
  • You want to leverage specialized expertise

📚 Learning Path

  1. Start with Simple ReAct to understand LangGraph basics
  2. Examine the code to see how agents and tools work
  3. Try both approaches with the same queries
  4. Compare the results and execution patterns
  5. Choose your approach based on your specific needs

🤝 Contributing

Feel free to:

  • Add new specialized agents to the multi-agent system
  • Enhance the log analysis capabilities
  • Add new tools for system administration
  • Improve error handling and reliability
  • Add tests and documentation

📝 License

This project is for educational and demonstration purposes. Modify and use as needed for your projects.


Happy system administration with AI! 🤖🔧

The custom log_analyzer tool supports:

  • error_patterns: Detects error keywords (error, fail, exception, critical, fatal, denied, refused, timeout)
  • frequency: Identifies most common log patterns by normalizing timestamps, IPs, and UUIDs
  • timeline: Extracts and analyzes timestamp patterns for chronological debugging
  • summary: Provides basic statistics and sample content overview

📁 Project Structure

langgraph-pard0x/
├── main.py              # Main LangGraph agent
├── log_analyzer.py      # Custom log analysis tool
├── loghub/             # Git submodule with log datasets
│   ├── Linux/
│   ├── Apache/
│   ├── OpenSSH/
│   └── ...
├── pyproject.toml      # Project dependencies
└── README.md          # This file

⚠️ Safety Note

This agent has shell access for diagnostic purposes. Use with caution and only in safe environments. The agent is designed to help with debugging, not to make system modifications.

Troubleshooting

"Please set your OPENAI_API_KEY environment variable"

  • Make sure you've set your OpenAI API key using one of the methods above
  • Verify your API key is valid and active

"Error initializing chatbot"

  • Check your internet connection
  • Verify your OpenAI API key has sufficient credits
  • Make sure all dependencies are installed correctly

Loghub submodule not found

  • Run git submodule update --init --recursive to initialize the submodule
  • Ensure you have proper git access to the loghub repository

🤔 Open Questions

This project raises several interesting technical and architectural questions worth exploring:

Conversation History Management

ReAct vs. Custom StateGraph

Tool Architecture Decisions

Description
No description provided
Readme 215 KiB
Languages
Python 100%