trace / README.md
Ayush
Update
4156f51
|
Raw
History Blame Contribute Delete
6.07 kB
metadata
title: Trace Your Digital Footprint
emoji: πŸ•΅οΈ
colorFrom: purple
colorTo: indigo
sdk: docker
app_port: 8000
pinned: false

πŸ•΅οΈ Trace β€” "Your Digital Footprint"

Meta OpenEnv Hackathon 2026 | Team Submission

Trace is a privacy-centric, multi-agent RL environment that builds a dynamic Semantic World Model of a user's fragmented digital life β€” without centralizing data.


Themes Addressed

Theme Coverage
Theme #2 – Long-Horizon Planning & Instruction Following Primary β€” federated multi-step retrieval across years of data
Theme #1 – Multi-Agent Interactions Secondary β€” planner, retriever, verifier, memory agents
Theme #4 – Self-Improvement Tertiary β€” agents learn from past executions, refine strategies
Sub-theme: Scale AI Non-code long-horizon business/personal workflows
Sub-theme: Patronus AI Consumer workflows with schema drift (Gmail/Drive APIs change)

Architecture Overview

User Query (e.g., "Audit all receipts from 2022-2024 and flag anomalies")
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   PLANNER AGENT                          β”‚
β”‚  plan-act-verify framework | goal decomposition          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚ sub-tasks
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β–Ό              β–Ό              β–Ό
   RETRIEVER AGENT   MEMORY AGENT  VERIFIER AGENT
   (federated fetch) (episodic KV) (reward scorer)
          β”‚              β”‚              β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚ observations
                         β–Ό
              OpenEnv Environment Loop
              (reset / step / reward)
                         β”‚
                         β–Ό
              TRL + Unsloth RL Training

Quick Start

# 1. Install dependencies
pip install -r requirements.txt

# 2. Bootstrap OpenEnv environment
cd environments/trace_env
openenv init   # or run: uvicorn app:app --reload

# 3. Run training script (Google Colab friendly)
cd training
python train_grpo.py --config ../configs/grpo_config.yaml

# 4. Evaluate
python scripts/evaluate.py --env-url http://localhost:8000

Project Structure

trace/
β”œβ”€β”€ environments/
β”‚   └── trace_env/          # OpenEnv-compatible RL environment
β”‚       β”œβ”€β”€ app.py           # FastAPI server (OpenEnv interface)
β”‚       β”œβ”€β”€ core/
β”‚       β”‚   β”œβ”€β”€ env.py       # TraceEnv: reset(), step(), state()
β”‚       β”‚   β”œβ”€β”€ world_model.py  # Semantic World Model (SWM)
β”‚       β”‚   └── schemas.py   # Action / Observation dataclasses
β”‚       β”œβ”€β”€ agents/
β”‚       β”‚   β”œβ”€β”€ planner.py   # Long-horizon goal decomposer
β”‚       β”‚   β”œβ”€β”€ retriever.py # Federated data fetcher (Gmail, Drive)
β”‚       β”‚   β”œβ”€β”€ memory.py    # Episodic + semantic memory store
β”‚       β”‚   └── verifier.py  # Plan verification agent
β”‚       β”œβ”€β”€ tools/
β”‚       β”‚   β”œβ”€β”€ gmail_tool.py
β”‚       β”‚   β”œβ”€β”€ drive_tool.py
β”‚       β”‚   └── timeline_tool.py
β”‚       └── rewards/
β”‚           β”œβ”€β”€ reward_fn.py # Multi-component reward functions
β”‚           └── anti_hack.py # Anti-reward-hacking guards
β”œβ”€β”€ training/
β”‚   β”œβ”€β”€ train_grpo.py        # Main RL training script (TRL + Unsloth)
β”‚   β”œβ”€β”€ dataset.py           # Task curriculum generator
β”‚   └── callbacks.py         # Training monitors
β”œβ”€β”€ configs/
β”‚   β”œβ”€β”€ grpo_config.yaml     # GRPO hyperparameters
β”‚   └── env_config.yaml      # Environment settings
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ evaluate.py          # Reward curve evaluation
β”‚   └── sample_outputs.py    # Anti-hacking output inspector
β”œβ”€β”€ notebooks/
β”‚   └── trace_colab.ipynb    # Colab-ready training notebook
β”œβ”€β”€ docs/
β”‚   └── blog_post.md         # HuggingFace mini-blog
β”œβ”€β”€ requirements.txt
└── README.md

HuggingFace Deployment

Required Secrets

Set these in your HF Space settings β†’ Repository secrets:

Secret Name Source File Description
GCP_CREDENTIALS_B64 credentials.json Google Cloud OAuth client credentials
GMAIL_TOKEN_B64 token_gmail.pkl Gmail API OAuth token (base64-encoded pickle)
SHEETS_TOKEN_B64 token_sheets.pkl Sheets API OAuth token (base64-encoded pickle)
SHEETS_LEDGER_ID .ledger_id (Optional) Google Sheet ID for the financial ledger

Generate all base64 secrets at once:

python3 generate_secrets.py   # β†’ creates hf_secrets.txt with all values

Live Dashboard

Visit /dashboard on your deployed Space to see a live financial transaction dashboard populated from Gmail. The endpoint:

  1. Searches Gmail for financial emails (last 180 days)
  2. Parses transactions (vendor, category, amounts)
  3. Renders an interactive HTML dashboard

Results are cached for 10 minutes. Force refresh with /dashboard?refresh=true.


Judging Criteria Alignment

Criterion Implementation
Environment Innovation (40%) Federated multi-source retrieval + zero-knowledge SWM; novel schema-drift curriculum
Storytelling (30%) Privacy narrative + before/after timeline demo
Showing Reward Improvement (20%) Reward curves across 3 difficulty tiers; plan-quality scoring
Training Script Setup (10%) OpenEnv + TRL GRPO + Unsloth Colab notebook