DarkyCodez/precision-ag-env
0
1---2title: Precision Ag Env3emoji: 🌾4colorFrom: green5colorTo: blue6sdk: docker7pinned: false8---9# 🌾 Precision Resilience: Agricultural AI Agent10 11**Built for the Meta x Scaler OpenEnv Hackathon**12 13## 📖 Overview14The **Precision Resilience Agent** is a closed-loop Reinforcement Learning (RL) environment built on the OpenEnv framework. It simulates a high-value IoT greenhouse where an AI agent must autonomously manage resources to maximize crop yield while navigating volatile weather conditions and resource costs.15 16Unlike traditional text-based agents, this environment requires the LLM to act as an industrial controller—reading sensor telemetry, managing state transitions (soil moisture, nitrogen degradation), and executing precise physical actions without human intervention.17 18---19 20## 🎯 The Three Tasks21 22The environment scales in complexity across three distinct scenarios to evaluate the agent's reasoning and sequencing capabilities:23 24### 1. The "Thirsty Crop" (Easy)25* **Objective:** Maintain optimal soil moisture (40%-60%) for 10 consecutive turns.26* **Challenge:** The agent must learn the baseline degradation rate of the soil and timing of the `Irrigate` action without over-watering and drowning the crop.27 28### 2. The "Nutrient Balance" (Medium)29* **Objective:** Reach a "Harvest Ready" state with optimal nitrogen levels.30* **Challenge:** Introduces sequence-dependency. If the agent applies fertilizer and immediately over-irrigates, the nutrients wash away. The agent must learn to sequence `Fertilize` and `Irrigate` correctly before triggering `Harvest`.31 32### 3. The "Heatwave Crisis" (Hard)33* **Objective:** Maximize profit during a simulated drought and heatwave.34* **Challenge:** Introduces severe resource constraints and environmental volatility. Ambient temperatures cause "Crop Stress," and the cost of water doubles. The agent must calculate whether it is mathematically optimal to harvest early for a smaller, guaranteed profit, or risk the heatwave for a maximum payout.35 36---37 38## ⚙️ Environment Mechanics39 40### Observation Space (State)41The agent receives a JSON payload containing real-time IoT sensor readings:42* `soil_moisture` (float: 0.0 - 1.0)43* `nitrogen_level` (float: 0.0 - 1.0)44* `crop_health` (float: 0.0 - 1.0)45* `ambient_temp` (float)46* `turn_count` (integer)47 48### Action Space49The agent responds with a single discrete integer representing a physical action:50* `0`: **Do Nothing** (Conserves budget, allows natural degradation)51* `1`: **Irrigate** (+0.2 Moisture, incurs water cost)52* `2`: **Fertilize** (+0.2 Nitrogen, incurs fertilizer cost)53* `3`: **Harvest** (Terminates episode, calculates final yield reward)54 55---56 57## 🚀 Local Setup & Deployment58 59This environment is fully containerized and compliant with the OpenEnv validation specifications.60 61**1. Build the Docker Image:**62```bash63docker build -t ag-env .64```65 66**2. Run the Environment:**67```bash68docker run -p 7860:7860 ag-env69```70 71**3. Run the Agent (Inference):**72 73Ensure you have set your `HF_TOKEN` environment variable, then run:74 75```bash76python inference.py77```78 79 