RohanExploit/Meta-hackathon
πͺ Multi-Channel Retail Environment with Disruption Recovery
OpenEnv Scaler Hackathon Submission β A production-grade, OpenEnv-compliant environment that challenges AI agents to manage a realistic multi-channel retail operation under supply chain disruptions, demand shocks, and stochastic supplier behavior.
  ![OpenEnv Compliant]() ![Tests]()
π― What Problem Does This Solve?
Retail operations managers face a daily challenge that no toy environment captures: simultaneously optimizing pricing, inventory, and promotions across multiple customer segments while dealing with unpredictable supply chain disruptions.
This environment faithfully simulates the real-world tradeoffs:
- A demand collapse hits your bestseller β do you slash prices or run a promotion?
- Your supplier delivers only 80% of orders β how much buffer stock do you carry?
- Luxury customers will pay 2Γ but buy less β how do you allocate limited inventory between segments?
- Holding costs eat into margins β when exactly should you reorder?
These are genuine decisions that cost retailers billions annually. This is not a game.
ποΈ Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FastAPI Server (server/app.py) β
β POST /reset Β· POST /step Β· GET /state Β· POST /evaluate β
β GET /tasks Β· GET /health Β· POST /live/start Β· /stop Β· ... β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Core Environment β
β environment/retail_env.py β MultiChannelRetailEnv β
β environment/models.py β Pydantic: Action, Obs, State β
β environment/grader.py β Deterministic scoring [0,1] β
β environment/tasks.py β 5 difficulty tiers β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Baseline Agent (inference.py) β
β OpenAI-compatible client β observe β reason β act loop β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββπΉοΈ Action Space
The agent selects one action per step from five typed Pydantic models:
ποΈ Observation Space
The agent receives a partial observation (true demand patterns are hidden):
RetailObservation(
day: int, # Current day [0, horizon)
cash: float, # Available funds
inventory: Dict[str, int], # Current stock by product
recent_demand_luxury: Dict, # Rolling 3-day average of realized luxury demand
recent_demand_budget: Dict, # Rolling 3-day average of realized budget demand
recent_stockouts: Dict, # Per-product stockout count (steps with unmet demand)
prices_luxury: Dict, # Current luxury prices
prices_budget: Dict, # Current budget prices
disruption_active: bool, # Is a disruption currently happening?
disruption_severity: float, # Severity [0.0β1.0]
market_confidence: float, # Decaying confidence indicator [0.0β1.0]
)The agent must infer hidden demand patterns from noisy signals β this is a partially observable environment by design.
π Tasks (5 Difficulty Tiers)
Each task has a fixed seed for reproducible evaluation.
π Grading System
The grader (environment/grader.py) is deterministic, transparent, and stateless. It computes a composite score in [0.0, 1.0]:
score = 0.5 Γ profit_score + 0.3 Γ fill_rate_score + 0.2 Γ efficiency_scoreAnti-Gaming Guardrail
If fill_rate < 0.6, the final score is halved. This prevents agents from exploiting high-margin strategies that ignore customer demand.
Multi-Seed Aggregation
The /evaluate endpoint supports multi-seed evaluation with optional variance penalty:
adjusted_score = mean_score - variance_penalty Γ variance(seed_scores)π Installation & Quick Start
Prerequisites
- Python 3.10+ (if running locally)
- Docker (optional, if running via containerized setup)
- Hugging Face Token / API Key (to run the baseline inference agent)
Local Installation & Development
# Clone the repository
git clone https://github.com/RohanExploit/Meta-hackathon.git
cd Meta-hackathon
# Setup
python -m venv .venv
source .venv/bin/activate # Linux/Mac
# .venv\Scripts\activate # Windows
pip install --upgrade pip
pip install -e .
# Start the environment server
uvicorn server.app:app --host 0.0.0.0 --port 8000Run Baseline Inference
In a second terminal:
export API_BASE_URL=https://router.huggingface.co/v1
export MODEL_NAME=NousResearch/Nous-Hermes-2-Mistral-7B-DPO
export OPENAI_API_KEY=<your-hf-token>
python inference.pyDocker
docker build -t retail-env .
docker run -p 8000:8000 \
-e API_BASE_URL="https://router.huggingface.co/v1" \
-e MODEL_NAME="NousResearch/Nous-Hermes-2-Mistral-7B-DPO" \
-e OPENAI_API_KEY="<token>" \
retail-envHugging Face Spaces
This repository is deployed live at [huggingface.co/spaces/RohanExploit/Meta-hackathon](https://huggingface.co/spaces/RohanExploit/Meta-hackathon). The Space auto-builds from the root Dockerfile and starts serving the API immediately.
π‘ API Reference
All endpoints are served by FastAPI with automatic OpenAPI docs at /docs.
Example: Full Episode
# 1. Reset to easy task
curl -s -X POST http://localhost:8000/reset \
-H "Content-Type: application/json" \
-d '{"task_name": "easy", "seed": 42}'
# 2. Take an action
curl -s -X POST http://localhost:8000/step \
-H "Content-Type: application/json" \
-d '{"action": {"action": "order", "product": "Product_A", "quantity": 3}}'
# 3. Evaluate
curl -s -X POST http://localhost:8000/evaluate \
-H "Content-Type: application/json" \
-d '{"summary": {"profit": 80, "baseline_profit": 100, "total_demand": 100, "total_sales": 75}}'π§ͺ Testing & Validation
Compliance Tests (6 tests)
python -m pytest tests/test_compliance.py -vValidates: OpenEnv YAML contract, HF Spaces config, task count, API endpoints, grader bounds, anti-gaming behavior.
Smoke Tests
python test_env.py # Environment lifecycle
python test_api.py # API simulationHealth Check (all-in-one)
python scripts/health_check.pyRuns compile checks β test suite β smoke scripts β pre-submission checks.
Pre-Submission Check
python scripts/pre_submission_check.pyValidates: task count β₯ 3, inference env vars, Docker availability, OpenEnv CLI.
Reproducibility Benchmark
# Requires running server + API credentials
python scripts/benchmark_inference.pyRuns inference twice, compares scores for determinism.
Verified Baseline Scores
Tested with llama-3.1-8b-instant via Groq (seed=42):
The agent achieves 100% fill rate on easy/medium tasks. Harder tasks have lower fill rates due to multi-product inventory splitting across 3-4 products with a single action per step.
π Repository Structure
Meta-hackathon/
βββ Dockerfile # Root-level Docker config (HF Spaces uses this)
βββ README.md # This file
βββ app.spaces.yaml # HF Spaces auto-config (sdk: docker, tag: openenv)
βββ openenv.yaml # OpenEnv environment metadata
βββ pyproject.toml # Dependencies + entry points
βββ uv.lock # Locked dependency versions
βββ inference.py # Baseline LLM agent (OpenAI-compatible)
β
βββ environment/ # Core environment package
β βββ __init__.py
β βββ models.py # Pydantic: RetailAction, RetailObservation, RetailState
β βββ retail_env.py # MultiChannelRetailEnv (reset, step, state)
β βββ grader.py # Deterministic scoring [0, 1]
β βββ tasks.py # 5 task definitions (easy β expert)
β
βββ pipeline/ # NVIDIA-inspired RAG pipeline (optional layer)
β βββ config.py # Centralized model registry + tuning knobs
β βββ safety.py # Llama Guard 3 input/output guardrails
β βββ router.py # NIM-style Router Agent (query classification)
β βββ retriever.py # Two-stage: FAISS dense retrieval + LLM reranking
β βββ chain.py # LCEL orchestrator (safetyβrouterβretrievalβgen)
β βββ ingest.py # SemanticChunker document ingestion
β
βββ server/ # FastAPI server package
β βββ __init__.py
β βββ app.py # 12 API endpoints + LiveRunner + SSE stream
β βββ ui/
β βββ index.html # Terminal-style web UI (/)
β βββ dashboard.html # Modern visual dashboard (/dashboard) β Chart.js charts, live runner
β βββ chart.umd.min.js # Bundled Chart.js (served at /static/chart.js)
β
βββ tests/
β βββ test_compliance.py # 6 compliance tests
β
βββ scripts/
β βββ health_check.py # All-in-one validation
β βββ pre_submission_check.py # Rubric-mapped checks
β βββ benchmark_inference.py # Reproducibility benchmark
β βββ run_tests.py # Isolated test runner
β
βββ test_env.py # Environment smoke test
βββ test_api.py # API smoke test
βββ .github/workflows/ci.yml # GitHub Actions CIπ Key Design Decisions
Why Multi-Segment Pricing?
Real retailers optimize per customer tier. Luxury customers accept premium prices with lower volume; budget customers demand high volume at thin margins. This creates a genuine tradeoff that doesn't exist in single-price environments.
Why Disruptions?
Supply chain disruptions (demand collapses, supply delays, demand spikes) occur with ~15% probability per step. They test whether agents can adapt and recover β a capability critical in real-world retail operations.
Why Transparent Grading?
The grader formula is fully documented and deterministic. Agents can learn that profit matters most (50% weight), customer satisfaction is essential (30%), and capital efficiency rounds out performance (20%). No hidden weights.
Why Partial Observability?
Agents see demand signals, not true demand distributions. This mirrors reality: retailers observe sales data and stockout counts, not the underlying customer arrival process.
π Expected Baseline Scores
π Reproducibility
- All randomness is seeded (
np.random.seed,random.seed) via task config - Inference uses
temperature=0for deterministic LLM output - Each task has a fixed grading seed for reproducible evaluation
- Episode metrics are fully logged in the terminal step info
- Docker build is deterministic with pinned dependencies (
uv.lock)
βοΈ Environment Variables
π Hackathon Checklist
π License
MIT
Built for the Meta OpenEnv Scaler Hackathon 2026.
