CoolFace
Apppublic

DarkyCodez/precision-ag-env

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
App README

🌾 Precision Resilience: Agricultural AI Agent

Built for the Meta x Scaler OpenEnv Hackathon

πŸ“– Overview

The 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.

Unlike 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.


🎯 The Three Tasks

The environment scales in complexity across three distinct scenarios to evaluate the agent's reasoning and sequencing capabilities:

1. The "Thirsty Crop" (Easy)

  • β€”Objective: Maintain optimal soil moisture (40%-60%) for 10 consecutive turns.
  • β€”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.

2. The "Nutrient Balance" (Medium)

  • β€”Objective: Reach a "Harvest Ready" state with optimal nitrogen levels.
  • β€”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.

3. The "Heatwave Crisis" (Hard)

  • β€”Objective: Maximize profit during a simulated drought and heatwave.
  • β€”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.

βš™οΈ Environment Mechanics

Observation Space (State)

The agent receives a JSON payload containing real-time IoT sensor readings:

  • β€”soil_moisture (float: 0.0 - 1.0)
  • β€”nitrogen_level (float: 0.0 - 1.0)
  • β€”crop_health (float: 0.0 - 1.0)
  • β€”ambient_temp (float)
  • β€”turn_count (integer)

Action Space

The agent responds with a single discrete integer representing a physical action:

  • β€”0: Do Nothing (Conserves budget, allows natural degradation)
  • β€”1: Irrigate (+0.2 Moisture, incurs water cost)
  • β€”2: Fertilize (+0.2 Nitrogen, incurs fertilizer cost)
  • β€”3: Harvest (Terminates episode, calculates final yield reward)

πŸš€ Local Setup & Deployment

This environment is fully containerized and compliant with the OpenEnv validation specifications.

1. Build the Docker Image:

bash
docker build -t ag-env .

2. Run the Environment:

bash
docker run -p 7860:7860 ag-env

3. Run the Agent (Inference):

Ensure you have set your HF_TOKEN environment variable, then run:

bash
python inference.py