Skip to content

About

Enterprise RL Environment with Schema Drift Resilience · Python, GRPO, Llama-3.2-3B · Built a custom Gym-compatible RL environment on Meta's OpenEnv framework. Trained Llama-3.2-3B with GRPO, achieving a +0.88 reward lift across 500 episodes and 55% SLA compliance — up from 10% baseline

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

title OpenEnv Enterprise — Schema Drift Resilience
emoji 🚀
colorFrom blue
colorTo indigo
sdk docker
app_port 7860
pinned false
license mit

🏢 OpenEnv Enterprise: The Resilience Engine

Training LLM agents to survive schema drift, chaos, and long-horizon enterprise workflows

Python OpenEnv Llama GRPO License

Hackathon: Meta OpenEnv India 2026 · Theme: Reliability & Agentic Workflows
Team: Mohammad Rehan & Shifana Khanum · Presidency University Bangalore

🔴 Live Demo  ·  📓 Colab Notebook  ·  📝 Technical Blog  ·  📊 Training Data


🌪️ The Problem: Why Enterprise AI Fails

Most LLM agents are tested in clean, deterministic environments. The real world is nothing like that.

In a live enterprise, schema drift happens constantly — an API field gets renamed mid-deal, a team member goes out-of-office, an SLA deadline shifts overnight. Agents trained on fixed schemas hallucinate, loop, or crash the moment they encounter these changes.

The gap: No published RL benchmark trains agents specifically for mid-episode schema drift — until now.


🧠 Our Solution: GRPO + Patronus Oversight

We built a complete Self-Healing Agentic Workflow from scratch:

Component What It Does
EnterpriseWorkflowEnv Custom Gym-style env inheriting from openenv.env.env.Env. Full reset / step / render compliance.
GRPO Training Group Relative Policy Optimization (the algorithm behind DeepSeek-R1) applied to Llama-3.2-3B on 500 training episodes.
Patronus Oversight Real-time security referee monitoring every action. Enforces strict RBAC (L1 vs L2) and applies penalties for schema violations.
Process Reward Model The reward function scores reasoning quality, not just actions — agent gets rewarded for mentioning "block", "schema", or "SLA" in the right contexts.
Composable Rubric Full openenv.yaml manifest with 5-dimensional rubric scoring per the OpenEnv spec.

📊 Results: From Brittle to Resilient

Training over 500 episodes with progressive difficulty (easy → medium → hard):

Metric Untrained Baseline GRPO Trained Improvement
Mean Episode Reward (first 100 eps) −0.29 — —
Mean Episode Reward (last 100 eps) — +0.59 ▲ +0.88
Rolling Avg (30-ep window) at end −0.46 +0.69 ▲ +1.15
SLA Compliance ~10% ~55% +45pp
Schema Drift Recovery Never adapts Consistent ✅ Achieved
Failure Modes All 5 present Eliminated ✅ Zero

The agent starts with a −0.29 rolling average in easy episodes and finishes the hard curriculum at +0.69 — a +0.88 total reward lift from first to last 100 episodes.

Training Results Graph

Real ε-greedy exploration → exploitation transition across 500 episodes. Progressive difficulty: easy (0–149) → medium (150–299) → hard (300–499). Raw data in results/reward_curve.csv.


🏗️ Architecture

OpenEnv Enterprise
├── env/
│   ├── enterprise_env.py     # Core env — inherits openenv.env.env.Env
│   ├── reward.py             # Dense + sparse reward with PRM
│   ├── actions.py            # 8 discrete enterprise actions
│   ├── state.py              # Partial-observability state (hidden fields never exposed)
│   ├── stochasticity.py      # 3 independent chaos events per step
│   └── oversight_referee.py  # Patronus AI RBAC enforcement + defer-spiral detection
│
├── scenarios/                # 5 complete enterprise scenarios
│   ├── sales_pipeline.py     # Mid-episode schema drift (deal_value → contract_amount)
│   ├── hr_escalation.py
│   ├── it_incident.py
│   ├── customer_refund.py
│   └── supply_chain.py
│
├── training/
│   ├── train.py              # Full GRPO training script
│   └── eval.py               # 5-scenario evaluation (50 episodes)
│
├── app.py                    # FastAPI demo server (reset / step / simulate endpoints)
├── openenv.yaml              # OpenEnv manifest with 5-dim composable rubric
└── OpenEnv_Colab_Master.ipynb  # Complete 11-step Colab pipeline (free T4 GPU)

🎯 Novel Technical Contributions

1. Mid-Episode Schema Drift

At step 3 of every sales episode, the field deal_value is silently renamed to contract_amount. The agent is never told. If it continues using the old field name, it receives a −0.1 penalty every step until it detects and adapts. This directly simulates real-world API versioning failures.

2. Three Independent Chaos Events (Stochasticity Layer)

Event Probability Effect
Actor Dropout 12%/step Team member goes OOO; in-progress task reverts to pending
Priority Spike 8%/step SLA cut by 2 steps; executive message injected
Inbox Noise 10%/step Low-signal IT/HR email floods the queue

3. Multi-Agent RBAC (L1 / L2 Authority Scopes)

L1 Agent: assign_task, reply_message, defer, lookup_policy, request_approval, re_route
L2 Agent: escalate, close_task  ← EXCLUSIVE to L2

Unauthorized actions trigger an immediate −0.5 penalty from the Patronus Oversight Referee.

4. Process Reward Model (PRM)

The reward function doesn't just score outcomes — it rewards correct reasoning:

  • Mentioning block when observing a blocked task: +0.05
  • Mentioning schema when drift has fired: +0.05
  • Mentioning SLA under time pressure: +0.03

5. Progressive Difficulty Curriculum

Training moves through three difficulty tiers, creating a natural curriculum that prevents reward hacking on easy configurations before stress-testing hard scenarios.


🎮 The 8-Action Space

# Action Effect
0 assign_task Start working on a pending task
1 escalate Push to senior agent — L2 only
2 defer Delay — dangerous when SLA is close
3 close_task Mark complete — L2 only
4 reply_message Respond to inbox
5 re_route Find alternate path around a blocker
6 lookup_policy Check company policy (costs −0.02)
7 request_approval Request sign-off

🚀 Quick Start

Interactive Demo (No Setup)

Open in HF Spaces

Run on Google Colab (Free T4 GPU)

Open in Colab

Local Installation

git clone https://github.com/MrEGAMERZ/OpenEnv.git
cd OpenEnv
pip install -r requirements.txt

# Run the environment locally
python app.py
# → Visit http://localhost:7860

Run the Environment Directly

from env.enterprise_env import EnterpriseWorkflowEnv

env = EnterpriseWorkflowEnv(scenario_name="sales_pipeline", difficulty="hard")
obs = env.reset()
print(obs)

# Step with L2 agent to close a task
obs, reward, done, info = env.step(action=3, agent_id="L2")
print(f"Reward: {reward:.3f} | Done: {done}")

📋 OpenEnv Compliance Checklist

Requirement Status
Inherits openenv.env.env.Env ✅
openenv.yaml manifest with composable rubric ✅
Gym-style reset(), step(), render() API ✅
GRPO training pipeline (Colab-runnable) ✅
Real training evidence (500-episode CSV) ✅
Dense, composable reward with PRM ✅
Multi-scenario evaluation (5 scenarios × 50 eps) ✅
Live HF Space demo ✅

📦 Repository Structure (For Evaluators)

Environment Code

File Purpose
env/enterprise_env.py Core env — ReadOnlyStateView, RBAC enforcement, 2s step timeout
env/reward.py Dense + sparse reward with schema drift penalty and PRM bonuses
env/actions.py 8 discrete enterprise actions with integer mapping
env/state.py EnterpriseState dataclass with hidden fields never exposed to agent
env/stochasticity.py 3 independent chaos events — actor dropout, priority spike, inbox noise
env/oversight_referee.py Patronus AI referee — defer-spiral detection + RBAC enforcement
scenarios/sales_pipeline.py Primary scenario with schema drift FSM
openenv.yaml OpenEnv manifest (5-dim rubric, action space, observation type)

Training & Evaluation

File Purpose
training/train.py Full GRPO training script with progressive curriculum
training/eval.py 5-scenario evaluation audit (50 episodes each)
OpenEnv_Colab_Master.ipynb Complete 11-step Colab pipeline — re-runnable on free T4 GPU

Evidence & Logs

File Purpose
results/reward_curve.csv Raw reward data — 500 episodes, 9 tracked metrics per episode
results/reward_curve.png Dual-panel reward + SLA curve visualization
results/eval_debug.txt Full evaluation transcript across all 5 scenarios
traces/trace_trained.txt Before/after behavioral traces (untrained vs trained agent)

🛠️ Tech Stack

Layer Technology
Foundation Model Llama-3.2-3B-Instruct
RL Algorithm GRPO (Group Relative Policy Optimization)
Training Stack Unsloth + Hugging Face TRL
Environment Base OpenEnv (openenv.env.env.Env) + Gymnasium-compatible API
Deployment FastAPI + Docker on Hugging Face Spaces
Oversight Patronus AI (RBAC + schema drift monitoring)

🔗 Links

Resource URL
Live Demo openenv-enterprise-workflow on HF Spaces
Colab Notebook OpenEnv_Colab_Master.ipynb
Technical Blog BLOG.md — Teaching an LLM to Manage a Chaotic Office
GitHub MrEGAMERZ/OpenEnv
Training Data results/reward_curve.csv
Evaluation Logs results/eval_debug.txt
Behavioral Traces traces/trace_trained.txt

Built for the OpenEnv Hackathon India 2026
Mohammad Rehan & Shifana Khanum — Presidency University Bangalore

Open source. Runs on Colab free tier. MIT Licensed.

About

Enterprise RL Environment with Schema Drift Resilience · Python, GRPO, Llama-3.2-3B · Built a custom Gym-compatible RL environment on Meta's OpenEnv framework. Trained Llama-3.2-3B with GRPO, achieving a +0.88 reward lift across 500 episodes and 55% SLA compliance — up from 10% baseline

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages