CoolFace
Apppublic

Roshan10000/MFDE

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

๐Ÿง  MFDE: Misleading Feedback Decision Environment

![OpenEnv](https://github.com/openenv) ![License](LICENSE) ![Platform](https://huggingface.co/spaces)

MFDE is a professional-grade Email Triage Simulation designed to evaluate and train AI agents in handling high-stakes decisions under misleading feedback. Now updated to v2.0 with real Gmail integration and calibrated deterministic scoring.


๐ŸŒ Real-World Utility (30% Weighting)

In modern Security Operations (SecOps), feedback loops are often corrupted by noisy signals, look-alike domains, and biased human review. MFDE models this "Reality Gap" by forcing agents to choose between:

  1. 1.Trusting the Evidence: Analyzing the raw email content for deceptive patterns.
  2. 2.Trusting the Reward: Following potentially corrupted feedback signals that may penalize correct security escalations.

This environment is immediately valuable for the RL community to test agentic resilience and calibration in enterprise-critical workflows.


๐Ÿ‘๏ธ v2.0 Extended Features

  • โ€”Real Gmail connectivity โ€” Connect any inbox via MCP and triage live telemetry.
  • โ€”Claude-Powered Inference โ€” Multi-modal baseline agents for high-fidelity triage.
  • โ€”Calibrated Scoring โ€” Strictly deterministic rewards in the (0.02, 0.98) safe range.
  • โ€”Glassmorphic Dashboard โ€” Professional real-time analytics for human-in-the-loop monitoring.

๐Ÿ‘๏ธ Technical Specifications

Observation Space

The environment provides structured email metadata: | Field | Type | Description | |---|---|---| | email_text | string | The full raw body of the email | | sender | string | The sender address (critical for phishing detection) | | subject | string | The subject line | | step_count | int | Progress within the current task |

Action Space (JSON)

The agent must submit a precise triage decision:

json
{
  "decision": "reply | ignore | escalate",
  "priority": "low | medium | high"
}

๐ŸŽฏ Task Tiers & Difficulty

TierStepsNoise โœ…Description
EASY50%Clear signals. Noisy rewards are disabled. Tests basic triage logic.
MEDIUM730%Deceptive "CEO Fraud" emails. Reward signals can be randomly misleading.
HARD1050%Advanced phishing (Repo mimics, Metamask drains). High-variance rewards.
GMAILvaries0%Real-life telemetry fetched via MCP. AI-graded by Claude.

๐Ÿงฎ Reward & Grader Design

Calibrated Tiers

MFDE provides dense signal with strict adherence to OpenEnv range compliance:

  • โ€”Full Success (Decision & Priority correct): 0.98
  • โ€”Partial Success (Decision correct only): 0.55
  • โ€”Failure (Incorrect decision): 0.02

Medium and Hard tasks inject reward noise based on the task difficulty, simulating real-world signal corruption while staying within the (0.01, 0.99) safe interval.

Deterministic Grader

Compliance with the hackathon rubric is guaranteed via grader.py:

  • โ€”Function: grade(history) -> float [0.0 - 1.0]
  • โ€”Calculated by averaging total weighted rewards across the trajectory and clamping to 2 decimal places for precision.

๐Ÿš€ Getting Started

Prerequisites

  • โ€”Python 3.11+
  • โ€”Docker (for containerized execution)

Local Launch

bash
pip install -r requirements.txt
export ANTHROPIC_API_KEY="your-key-here"
python -m uvicorn app:app --host 0.0.0.0 --port 7860

Baseline Inference (Reproduction)

Our inference.py uses the standard OpenAI client and supports heuristic fallbacks:

bash
# Set credentials for Claude AI inference
export HF_TOKEN="your-hf-token"
export API_BASE_URL="https://router.huggingface.co/v1"
python inference.py

๐Ÿ”Œ API Endpoints

MethodPathDescription
POST/resetReset environment, pick task (easy/medium/hard)
POST/stepSubmit triage action, get reward
GET/stateCurrent episode state + history
GET/api/performanceScore, streak, rank (2-decimal precision)
POST/api/gmail/fetchFetch real Gmail emails via MCP
POST/api/gmail/triageTriage emails with Claude AI

๐Ÿ—๏ธ Spec Compliance Checklist

  • โ€”[x] Typed Models: Full Pydantic V2 implementation in models.py.
  • โ€”[x] Standard API: /reset, /step, and /state endpoints functional.
  • โ€”[x] Containerized: Dockerfile tested for HF Spaces UID 1000.
  • โ€”[x] Calibrated: Rewards strictly within (0.01, 0.99).
  • โ€”[x] Structured Logs: Baseline script outputs exact [START]/[STEP]/[END] format.
  • โ€”[x] Deterministic: All graders are 100% reproducible.

๐Ÿ“Š Baseline Scores (Reproduce with random.seed(42))

TaskStepsBaseline ScoreSuccess
Easy50.60โœ… Yes
Medium70.84โœ… Yes
Hard100.79โœ… Yes

Reproduced using deterministic heuristic fallback.


๐Ÿ—๏ธ File Structure

mfde-main/
โ”œโ”€โ”€ app.py            # FastAPI server (standard + Gmail endpoints)
โ”œโ”€โ”€ env.py            # MFDEEnv with Gmail support
โ”œโ”€โ”€ models.py         # Pydantic models (incl. Gmail models)
โ”œโ”€โ”€ tasks.py          # Simulation task definitions
โ”œโ”€โ”€ grader.py         # Grading logic (simulation + Gmail)
โ”œโ”€โ”€ inference.py      # AI inference script (simulation + Gmail)
โ”œโ”€โ”€ dashboard.html    # Professional Glassmorphic UI
โ”œโ”€โ”€ openenv.yaml      # OpenEnv spec
โ”œโ”€โ”€ Dockerfile        # HF Spaces compatible (UID 1000)
โ””โ”€โ”€ requirements.txt  # Dependencies