CoolFace
Apppublic

GANESH756/AI-OPS-RL-ENVIRONMENT-SYSTEM

sourceHugging Facemitupdated 5mo agoView on Hugging Face
0likes
App README

<h1 align="center"><u> πŸ’» AI OPS RL Intelligence Environment System ♾️ </u></h1>

<div align="center">

TitleAI Ops System
EmojiπŸ€–
Color Fromblue
Color Togreen
SDKdocker
Python Version3.10
App port7860
App Fileapp.py
TagOPENENV

</div>

Autonomous Incident Detection & Recovery using Reinforcement learning environment for Task Prioritization.

  • β€”β€œFrom tasks to intelligence β€” building systems that learn to decide.”
  • β€”Category: AI Systems β€’ Reinforcement Learning β€’ DevOps Automation β€’ OpenEnv Environment β€’ Autonomous System
  • β€”This project implements an intelligent AI Ops environment where a reinforcement learning agent autonomously detects, analyzes, and resolves system incidents through a structured decision pipeline. It simulates real-world infrastructure behavior under dynamic conditions and demonstrates adaptive, explainable, and reproducible decision-making for system recovery.

πŸ”— Overview :

  • β€”OpenEnv-compatible AI Ops environment for autonomous incident management
  • β€”Simulates real-world system behavior (CPU, memory, traffic, errors)
  • β€”Reinforcement learning agent performs step-by-step decision making
  • β€”Structured pipeline: detection β†’ analysis β†’ decision β†’ execution β†’ recovery
  • β€”Adaptive reward mechanism enables continuous improvement
  • β€”Stochastic environment models real-world uncertainty
  • β€”Deterministic mode ensures reproducible evaluation (seed-based)
  • β€”Generates transparent, explainable execution logs for each step
  • β€”Designed for scalable, self-healing infrastructure systems

πŸ”— Why This Matters :

  • β€”Modern systems face unpredictable failures that require rapid and intelligent response
  • β€”Manual incident handling is slow, error-prone, and not scalable
  • β€”Traditional rule-based systems lack adaptability in dynamic environments
  • β€”Reinforcement learning enables autonomous, data-driven decision making
  • β€”Simulated environments allow safe testing without impacting real infrastructure
  • β€”Adaptive systems can continuously improve performance over time
  • β€”Explainable AI builds trust by making decisions transparent and traceable
  • β€”Enables the vision of self-healing, autonomous infrastructure systems --- ## πŸ”— What the System Works to provide ?

This system is designed as a step toward building intelligent, autonomous infrastructure capable of managing itself without constant human intervention. It aims to shift traditional operations from reactive monitoring to proactive and adaptive decision-making using reinforcement learning.

  • β€”Moving from manual incident handling to fully autonomous system management
  • β€”Enabling self-healing infrastructure that can detect and resolve failures independently
  • β€”Improving system reliability and uptime through intelligent, real-time decisions
  • β€”Reducing operational complexity in large-scale and distributed environments
  • β€”Building adaptive systems that learn and evolve with changing conditions
  • β€”Laying the foundation for future AI-driven DevOps and cloud automation platforms

πŸ”— Environment at glance :

  • β€”OpenEnv-compatible RL environment tailored for real-world AI Ops scenarios
  • β€”Models dynamic system states (CPU, memory, error rate, latency) under varying load conditions
  • β€”Supports multi-scenario incident simulation (traffic spikes, resource saturation, system instability)
  • β€”Action space designed for autonomous recovery (analysis, detection, scaling, stabilization)
  • β€”Reward function shaped by system improvement, efficiency, and recovery success
  • β€”Adaptive reward mechanism learns from historical action effectiveness
  • β€”Stochastic behavior introduces real-world uncertainty and non-determinism
  • β€”Deterministic mode (seed-based) enables reproducible and consistent evaluation
  • β€”Handles both success and failure episodes with clear termination logic
  • β€”Designed to simulate self-healing infrastructure through sequential decision-making

πŸ”— Core Intelligence & Capabilities :

  • β€”Autonomous Incident Resolution: End-to-end pipeline for detecting, analyzing, and resolving system failures without human intervention
  • β€”Reinforcement Learning Decision Engine: Sequential action selection using reward-driven optimization (State β†’ Action β†’ Reward β†’ Next State)
  • β€”Multi-Scenario Simulation: Handles diverse system conditions including CPU spikes, memory pressure, traffic surges, and latency issues
  • β€”Stochastic Environment Modeling: Introduces real-world uncertainty for robust and realistic agent behavior
  • β€”Adaptive Reward Mechanism: Continuously adjusts rewards based on action effectiveness and system improvement
  • β€”Deterministic Mode (Reproducibility): Seed-based execution ensures consistent and verifiable results
  • β€”Explainable AI Execution Logs: Transparent step-by-step reasoning for every decision and action taken
  • β€”Failure-Aware Execution: Supports action failures and recovery retries for realistic system behavior
  • β€”Phase-Based Decision Pipeline: Structured flow across detection, analysis, decision, execution, and recovery stages
  • β€”Performance-Driven Optimization: Measures system improvement through CPU, memory, error rate, and latency reduction
  • β€”OpenEnv Compliance: Fully aligned with required output format and evaluation standards
  • β€”Scalable & Modular Design: Easily extendable to real-world infrastructure and deployment scenarios

πŸ”— System Architecture :

The system operates through a structured, step-by-step pipeline where a user-triggered event initializes the environment with current system metrics such as CPU usage, memory, error rate, and latency. The AI agent first detects any anomalies and performs a detailed analysis to identify the root cause of the issue. Based on the observed state, the reinforcement learning agent selects the most optimal action using its learned policy and reward feedback.

<div align="center">

[USER INPUT / TRIGGER]
 ↓
[ENVIRONMENT INITIALIZATION]
(State: CPU, Memory, Error, Latency)
 ↓
[PHASE 1: DETECTION]
Identify system anomaly (e.g., HIGH_CPU)
 ↓
[PHASE 2: ANALYSIS]
Analyze system state and root cause
 ↓
[PHASE 3: DECISION]
RL Agent selects optimal action
 ↓
[PHASE 4: EXECUTION]
Execute action (scale / balance / mitigate)
 ↓
[PHASE 5: RECOVERY]
System stabilizes and metrics improve
 ↓
[REWARD CALCULATION]
Evaluate performance improvement
 ↓
[STATE UPDATE]
Update system metrics (next state)
 ↓
[TERMINATION CHECK]
Stable? β†’ YES β†’ END  
Else β†’ Continue next step
 ↓
[FINAL OUTPUT]
[END] + Summary + System Metrics

</div>


πŸ”— Workflow :

The system operates through a structured, step-by-step pipeline where a user-triggered event initializes the environment with current system metrics such as CPU usage, memory, error rate, and latency. The AI agent first detects any anomalies and performs a detailed analysis to identify the root cause of the issue. Based on the observed state, the reinforcement learning agent selects the most optimal action using its learned policy and reward feedback.

<div align="center">

[USER TRIGGER / TASK INPUT]
 ↓
[INITIALIZE ENVIRONMENT STATE]
(CPU, Memory, Error Rate, Latency)
 ↓
[DETECT SYSTEM EVENT]
Identify anomaly (e.g., HIGH_CPU)
 ↓
[ANALYZE CURRENT STATE]
Evaluate system condition & root cause
 ↓
[RL DECISION ENGINE]
Select optimal action based on policy & reward
 ↓
[EXECUTE ACTION]
(Scale resources / Load balance / Stabilize)
 ↓
[SYSTEM FEEDBACK]
Update metrics based on action impact
 ↓
[REWARD EVALUATION]
Calculate reward from system improvement
 ↓
[STATE TRANSITION]
Move to next updated system state
 ↓
[TERMINATION CHECK]
Stable? β†’ YES β†’ END  
Else β†’ Continue loop
 ↓
[FINAL OUTPUT]
Structured logs + Summary + Final system metrics

</div>


πŸ”— Reward System (Core Logic) :

The system evaluates each decision using a weighted scoring model: it transforms simple system metrics into intelligent, learning behavior that consistently makes the right decisions at the right time. This reward system represents cutting-edge RL engineering that combines theoretical excellence with practical validation compliance, creating an AI environment that learns, adapts, and improves with every interaction!

  • β€”Learns from experience: Good actions get better over time.
  • β€”Penalizes mistakes: Wrong decisions lose points
  • β€”Rewards speed: Faster solutions earn more
Final reward = (0.4 Γ— priority_score) + (0.4 Γ— action_score) + (0.2 Γ— speed_bonus)

Example :
High CPU incident + AI scales resources quickly:

reward = (0.4 Γ— 0.99) + (0.4 Γ— 0.99) + (0.2 Γ— 0.8)
        = 0.396 + 0.396 + 0.16
        = 0.95

πŸ”— Reward Progression Logic :

<div align="center">

StepActionRewardStatus
1analyzesystemstate0.40Detection
2detecthighcpu0.40Analysis
3evaluate_scaling0.44Decision
4scale_resources0.66Execution
5stabilize_system0.66Recovery
FinalAverage Score0.51Success

</div>


πŸ”— Performance Adjustment :

<div align="center">

Performance LevelReward AdjustmentNew Range
Excellent (>70%)+0.020.42 – 0.99
Good (40–70%)Β±0.000.40 – 0.99
Poor (<30%)-0.020.38 – 0.97

</div>

</div>


πŸ”— Score Calculation :

Final score is computed as: Normalized average of rewards across all steps Ensures score remains in range (0, 1) as required by evaluation

final_score = sum(all_step_rewards) / number_of_steps
###  Example

Step 1: 0.40
Step 2: 0.40  
Step 3: 0.44
Step 4: 0.66
Step 5: 0.66

final_score = (0.40 + 0.40 + 0.44 + 0.66 + 0.66) / 5
             = 2.56 / 5
             = 0.51
final_score = max(0.01, min(final_score, 0.99))

πŸ”— Score Meaning :

Higher Score = Smarter AI = Better System Recovery! <div align="center">

Score RangePerformance LevelMeaning
0.90 – 0.99ExcellentNear-perfect AI decisions, optimal system recovery
0.70 – 0.89Very GoodStrong decisions, effective problem resolution
0.50 – 0.69GoodSolid performance, successful recovery
0.30 – 0.49AverageAcceptable decisions, partial success
0.10 – 0.29PoorWeak decisions, minimal improvement
0.01 – 0.09Very PoorFailed decisions, system still critical

</div>


πŸ”— Tasks in this system now :

The AI Ops Environment features ten comprehensive tasks that simulate real-world IT operations scenarios. These tasks are carefully designed to test different aspects of AI decision-making, from basic monitoring to complex optimization challenges.

The system includes two easy-level tasks focused on fundamental operations like system health monitoring and log analysis. These serve as entry points for the AI to demonstrate basic problem-solving capabilities. The majority of tasks (eight) are medium-complexity scenarios that involve sophisticated operations such as load balancing optimization, anomaly detection, resource allocation, incident response automation, and performance tuning.

<div align="center">

TaskDescription
Basic System MonitoringMonitor basic system health and status
Simple Log AnalysisAnalyze basic system logs for errors
Load Balancing OptimizationDistribute workload across servers efficiently
Anomaly Detection MonitoringIdentify unusual patterns in system behavior
Resource Allocation PlanningOptimize CPU, memory, and storage usage
Incident Response AutomationAutomatically handle system emergencies
Performance Tuning EngineOptimize system performance parameters
Cost Efficiency OptimizationReduce operational costs while maintaining performance
Intelligent Scheduling SystemOptimize task scheduling for maximum efficiency
Database Performance TuningOptimize database queries and indexing for performance

</div>


πŸ”— Output determines the system :

The system generates structured output following the OpenEnv-compatible format, representing a complete reinforcement learning episode. Each execution produces:

  • β€”[START] β†’ Initializes the task and environment
  • β€”[STEP] β†’ Represents each action taken by the agent along with reward and state progression
  • β€”[END] β†’ Indicates completion of the episode with success status and total steps
 - Output Structure
[START] task=<task_name> env=<environment> model name:......
[STEP] step=1 action=<action> reward=<0.00> done=false
[STEP] step=2 action=<action> reward=<0.00> done=false
...
[STEP] step=n action=<action> reward=<1.00> done=true

[END] success=<true|false> steps=<n>
  • β€”Characteristics
  • β€”Single episode execution per run
  • β€”Rewards normalized and formatted to two decimal places
  • β€”Sequential step-by-step action tracing
  • β€”Clear termination with success or failure
  • β€”Fully compliant with evaluation and validation requirements

πŸ”— How to Run

The AI Ops Environment runs as a web dashboard where five intelligent agents collaborate to solve IT incidents through a five-phase pipeline. Users watch in real-time as the system detects problems, makes decisions, executes solutions, and learns from each experience to improve future performance. Users interact through an intuitive web interface that displays live system metrics, allows task and event selection, and provides real-time visibility into the AI's decision-making process. The dashboard shows the progression through each phase, displays reward scores, and demonstrates how the system transforms critical states (like 95% CPU usage) into healthy ones (like 32% CPU usage) through intelligent automation.

πŸ”— Local Setup :

bash
# 1. Clone repository
git clone <your-repo-url>
cd ai-ops-environment-meta--main

# 2. Install dependencies
pip install -r requirements.txt

# 3. Start server
uvicorn app:app --host 0.0.0.0 --port 7860

# 4. Open browser
http://localhost:7860
# Required for LLM integration
export API_BASE_URL="https://your-llm-proxy.com/v1"
export API_KEY="your-api-key-here"
export MODEL_NAME="Qwen/Qwen2.5-72B-Instruct"

# Or create .env file
echo "API_BASE_URL=https://your-llm-proxy.com/v1" > .env
echo "API_KEY=your-api-key-here" >> .env
echo "MODEL_NAME=Qwen/Qwen2.5-72B-Instruct" >> .env

πŸ”— Run AI interface :

# Random mode
python inference.py

# Deterministic mode 
python inference.py load_balancing_optimization HIGH_CPU 42

# Local development (port 7860)
uvicorn app:app --host 0.0.0.0 --port 7860 --reload

# Different port if 7860 is busy
uvicorn app:app --host 0.0.0.0 --port 8080 --reload

πŸ”— Docker setup :

# Build and run
docker build -t ai-ops-env .
docker run -p 7860:7860 ai-ops-env

πŸ”— Hugging face (optional) :

# 1. Create new Space
# Go to huggingface.co β†’ Spaces β†’ Create New Space
# Choose: Docker, Python 3.9, Public

# 2. Push to HF Space
git clone https://huggingface.co/spaces/your-username/your-space-name
cd your-space-name
git remote add origin https://huggingface.co/spaces/your-username/your-space-name

# 3. Copy your files
cp -r /path/to/your/ai-ops-environment/* .

# 4. Set environment variables
# In Space Settings β†’ Variables:
# API_BASE_URL=your-llm-proxy-url
# API_KEY=your-api-key
# MODEL_NAME=Qwen/Qwen2.5-72B-Instruct

# 5. Push and deploy
git add .
git commit -m "Deploy AI Ops Environment"
git push
# Test locally before pushing
openenv validate

# Check HF Space logs for errors
# Space URL: https://your-username-your-space-name.hf.space

- Select task from dropdown
- Choose event type
- (Optional) Enter seed for reproducible results
- Click "Run System"
- Watch AI solve the problem!

πŸ”— Troubleshooting:

# Check if server is running
curl http://localhost:7860/

# Check logs for errors
# Look for "ERROR" or "CRITICAL" messages

# Test API endpoints
curl http://localhost:7860/reset
curl http://localhost:7860/run?task=load_balancing_optimization&event=HIGH_CPU

πŸ”— Agent Purpose :

<div align="center">

AgentPrimary FunctionKey ActionsSuccess Metric
Detection AgentFind system problemsanalyzesystemstate, detecthighcpuEarly issue identification
Analysis AgentUnderstand root causesevaluatescaling, classifyleak_severityAccurate problem diagnosis
Decision AgentChoose best solutionsselectoptimalstrategy, evaluatecleanupoptionsOptimal action selection
Execution AgentImplement fixesscaleresources, restartserviceSuccessful problem resolution
Recovery AgentStabilize systemstabilizesystem, monitorperformanceSystem health restoration

</div>


πŸ”— AI Intelligence capabilities :

  • β€”Autonomous Decision-Making: Dynamically selects optimal actions based on real-time system state and reward feedback
  • β€”Adaptive Learning Mechanism: Continuously improves strategies by learning from past actions and outcomes
  • β€”Context-Aware Analysis: Understands system conditions (CPU, memory, errors) to make informed decisions
  • β€”Uncertainty Handling: Operates effectively under stochastic and unpredictable system behavior
  • β€”Explainable Reasoning: Provides transparent, step-by-step insights into every decision and action taken

πŸ”— Action & Observation Space :

  • β€”The agent observes the system state through key performance metrics: CPU Usage Memory Usage Error Rate Latency These values represent the current condition of the system and guide decision-making.
  • β€”Action Space The agent can perform the following actions to manage and stabilize the system: Analyze System State Detect System Anomaly Evaluate Recovery Strategy Scale Resources Redistribute Load Stabilize System
  • β€”Interaction Mechanism At each step: The agent observes the current state Selects an action from the action space Receives a reward based on system improvement Transitions to a new state This loop continues until the system reaches a stable condition or the episode terminates.

πŸ”— Project Structure :

bash
ai-ops-rl-intelligence-envrionment /
β”œβ”€β”€ πŸ“„ app.py                  # FastAPI server & API endpoints
β”œβ”€β”€ πŸ“„ inference.py            # AI inference engine
β”œβ”€β”€ πŸ“„ openenv.yaml            # Environment configuration
β”œβ”€β”€ πŸ“„ Dockerfile              # Container setup
β”œβ”€β”€ πŸ“„ requirements.txt        # Python dependencies
β”œβ”€β”€ πŸ“„ pyproject.toml          # Project metadata
β”‚
β”œβ”€β”€ πŸ“ ai_ops_env/             # Core AI Ops environment
β”‚   β”œβ”€β”€ πŸ“„ __init__.py
β”‚   β”œβ”€β”€ πŸ“„ environment.py      # Main simulation engine
β”‚   β”œβ”€β”€ πŸ“„ grader.py           # Scoring & evaluation logic
β”‚   β”œβ”€β”€ πŸ“„ tasks.py            # Task definitions
β”‚   β”œβ”€β”€ πŸ“„ reward_learning.py  # Adaptive reward system
β”‚   └── πŸ“„ policy_learning.py  # Strategy optimization
β”‚
β”œβ”€β”€ πŸ“ static/                 # Frontend assets
β”‚   β”œβ”€β”€ πŸ“„ ui.js               # Interactive dashboard logic
β”‚   β”œβ”€β”€ πŸ“„ style.css           # Styling
β”‚   └── πŸ“„ script.js           # Additional scripts
β”‚
β”œβ”€β”€ πŸ“ templates/              # HTML templates
β”‚   └── πŸ“„ index.html          # Main UI page
β”‚
β”œβ”€β”€ πŸ“ agents/                 # AI agents
β”‚   └── πŸ“„ rules_agent.py      # Rule-based agent logic
β”‚
β”œβ”€β”€ πŸ“ .windsurf/              # IDE workflows & automation
β”‚   └── πŸ“ workflows/
β”‚       β”œβ”€β”€ πŸ“„ run-inference.md
β”‚       └── πŸ“„ tasks.md
β”‚
└── πŸ“ .git/                   # Git version control

πŸ”— Tech Stack :

ComponentTechnologyPurpose
Backend FrameworkFastAPIWeb server & API endpoints
AI IntegrationOpenAI APILLM model communication
Environment SimulationPythonCore system logic
Reinforcement LearningCustom RLLearning & adaptation
FrontendHTML/CSS/JavaScriptWeb dashboard
ContainerizationDockerDeployment & portability
Package Managementpip / requirements.txtDependency management
ConfigurationYAMLEnvironment setup
Web ServerUvicornASGI server
ValidationOpenEnvCompliance checking

πŸ”— API Endpoints used in this :

EndpointMethodPurposeExample Usage
/GETMain dashboard pagehttp://localhost:7860/
/resetPOSTReset environment statecurl -X POST http://localhost:7860/reset
/runGETExecute AI inferencehttp://localhost:7860/run?task=loadbalancingoptimization&event=HIGH_CPU&seed=42
/graderPOSTGrade AI actionscurl -X POST http://localhost:7860/grader -d '{"task_id":"1","action":"scale"}'
/stateGETGet current system statehttp://localhost:7860/state
/tasksGETList available taskshttp://localhost:7860/tasks
/rewardGETReward system statushttp://localhost:7860/reward
/baselineGETBaseline metricshttp://localhost:7860/baseline
/inference-rawGETRaw inference outputhttp://localhost:7860/inference-raw
/run: Main endpoint for AI execution with optional seed
/reset: Environment reset for fresh starts
/grader: Action scoring system
/state: Real-time system metrics
All endpoints return JSON responses with proper error handling!

πŸ”— Environment Variables use by this system :

VariableDescriptionExample Value
APIBASEURLLLM proxy endpoint URLhttps://your-llm-proxy.com/v1
API_KEYAuthentication key for LLM APIsk-your-api-key-here
MODEL_NAMELLM model identifierQwen/Qwen2.5-72B-Instruct
echo "API_BASE_URL=https://your-llm-proxy.com/v1" > .env
echo "API_KEY=sk-your-api-key-here" >> .env
echo "MODEL_NAME=Qwen/Qwen2.5-72B-Instruct" >> .env

πŸ”— Real-World Impact this environment :

This system demonstrates how reinforcement learning can transform traditional IT operations into intelligent, autonomous ecosystems capable of handling real-time challenges with minimal human intervention. By simulating realistic system failures and enabling adaptive decision-making, it showcases a practical pathway toward self-healing infrastructure and efficient incident management. The approach not only reduces response time and operational overhead but also improves system reliability and scalability in dynamic environments.

  • β€”Enables autonomous incident detection and recovery in cloud and enterprise systems
  • β€”Reduces manual intervention and operational costs through intelligent automation
  • β€”Improves system reliability by responding faster to failures and anomalies
  • β€”Supports scalable infrastructure management in high-load, distributed environments
  • β€”Provides explainable decision-making for better trust and system transparency
  • β€”Lays foundation for self-healing and resilient future infrastructure systems

πŸ”— Future Enhancements :

  • β€”Integration with real-world cloud infrastructure (AWS, Kubernetes)
  • β€”Deployment of fully autonomous self-healing systems in production
  • β€”Advanced multi-agent collaboration for complex incident handling
  • β€”Incorporation of predictive analytics for proactive failure prevention
  • β€”Support for large-scale distributed system environments
  • β€”Integration with real-time monitoring tools (Prometheus, Grafana)
  • β€”Enhanced reward modeling using advanced RL algorithms
  • β€”Continuous online learning from live system feedback
  • β€”Expansion to domain-specific environments (finance, healthcare, IoT)
  • β€”Improved explainability using advanced AI reasoning techniques
  • β€”Human-in-the-loop control for hybrid decision systems
  • β€”Optimization for edge computing and resource-constrained systems

πŸ”— Contribution :

B. SAI GANESH

AI Developer | System Builder | Innovator ---

πŸ”— References & Inspiration towards :

This project is developed following the OpenEnv framework guidelines for designing reinforcement learning environments. The implementation is inspired by standard environment design principles and extends them with adaptive decision-making, stochastic behavior, and AI-driven system recovery tailored for AI Ops scenarios.


πŸ”— Conclusion :

This project demonstrates a complete and intelligent AI Ops environment powered by reinforcement learning, where an autonomous agent can detect, analyze, and resolve system incidents through structured decision-making. By combining stochastic simulation, adaptive learning, and explainable execution, the system moves beyond static automation toward dynamic, self-improving infrastructure management. It highlights the potential of AI-driven operations to reduce manual intervention, improve system reliability, and enable scalable, self-healing systems. This work represents a strong step toward the future of autonomous, resilient, and intelligent system orchestration. As the system grows, it will incorporate deeper reasoning capabilities, adaptive learning strategies, and real-time integrations with production systemsβ€”transforming it from a simulation framework into a fully autonomous, enterprise-ready AI operations engine.