sourcandy43/osworld1
OsWorld Data Cleaning Environment
A benchmark environment for training and evaluating LLM agents on multi-step data engineering and cleaning tasks.
๐ง Architecture Overview
The OsWorld Data Cleaning Environment models data cleaning as a Markov Decision Process (MDP).
- State Representation: Workspace files (CSV, JSON, SQL, HTML, logs) and task description
- Action Space: Structured actions (inspection, Python execution, utilities)
- Semantic Grading: Multi-component ฮฆ (Phi) scoring system
- Reward System: Delta-based shaping with penalties and efficiency-scaled terminal rewards
๐ Quick Start
1. Prerequisites
pip install uv2. Installation
uv sync3. Environment Configuration
Create a .env file:
HF_TOKEN=your_huggingface_token
MODEL_NAME=Qwen/Qwen2.5-72B-Instruct
API_BASE_URL=https://router.huggingface.co/v1
# Optional fallback
OPENROUTER_API_KEY=your_key๐ Task Scenarios
The environment contains 15 task variants across 3 difficulty tiers.
Each reset() returns a deterministic task instance, cycling through predefined variants.
During benchmarking (inference.py), only a single episode is executed per run to ensure strict evaluation consistency.๐ Easy Tier (4 Variants)
- Duplicate Removal Standardize columns (
id,name) and remove duplicates
- Format Normalization Strip whitespace and normalize strings to lowercase
- Type Coercion Convert semantic strings into correct types
- Column Rename Pure schema alignment
โก Medium Tier (7 Variants)
- Missing value imputation
- Schema repair
- Constraint enforcement
- Multi-file joins
- JSON normalization
- SQL extraction
- HTML scraping
๐ฅ Hard Tier (4 Variants)
- Corrupted pipeline recovery
- Adversarial data fixing
- Cascading multi-file transformations
- Log parsing
๐ Interaction Loop
Each episode follows:
- Agent receives observation (files + task)
- Agent emits an action
- Environment executes action in sandbox
- Returns updated state, reward, and score
Loop continues until termination or max steps.
๐ Evaluation System
ฮฆ Score (Semantic Grading)
$$ \Phi = 0.4 \cdot content + 0.2 \cdot schema + 0.2 \cdot validity + 0.2 \cdot constraints - penalty $$
- All components normalized to [0, 1]
- Final ฮฆ is clamped to [0, 1]
- Task is solved when ฮฆ = 1.0
Component Breakdown
Content (40%) F1-based row matching (precision + recall)
Schema (20%) Column overlap + ordering consistency (capped โค 1.0)
Validity (20%)
- Null handling
- Type correctness
- Format consistency
Constraints (20%)
- Uniqueness
- Value ranges
- Task-specific rules
Anti-Cheat Penalty
$$ penalty = \min\left(0.3,\; 0.1 \cdot \frac{\max(0, n{agent} - n{expected})}{n_{expected}}\right) $$
Prevents:
- Row inflation
- Duplicate exploitation
- Partial-output hacks
๐ฏ Reward Function
The reward at each step is:
R = step_penalty
+ (new_score - old_score)
+ regression_penalty (if score drops)
+ error_penalty
+ destructive_penalty
+ terminal_bonus (if done)๐ฅ Terminal Reward Scaling
When the episode ends, a terminal bonus is applied:
terminal_bonus = ฮฑ * final_score * efficiency_factorWhere:
- final_score = ฮฆ (final semantic score)
- ฮฑ = terminal scaling constant (e.g., 5.0)
โก Efficiency Factor
Encourages fewer steps:
efficiency_factor = max(0.3, 1 - steps_used / max_steps)Properties:
- Faster solutions โ higher reward
- Slow agents are penalized but not zeroed
- Minimum floor prevents reward collapse
๐ง Reward Properties
- Dense feedback โ incremental progress rewarded
- Regression penalty โ discourages breaking correct states
- Execution penalties โ punishes unsafe/destructive actions
- Efficiency scaling โ promotes optimal planning
๐ค Agent Constraints
- Agent only sees provided files
- Tasks are defined in
current_task - Execution occurs in sandboxed Python
- Available libraries:
pandas,io, etc. - Agent primarily uses
execute_python, with optional inspection steps
๐ Usage
Benchmark Mode
uv run inference.pyOutputs strict logs:
[START]
[STEP]
[END]Evaluation
uv run python eval.pyRun Server
uv run uvicorn server.app:app --host 0.0.0.0 --port 8000๐ Project Structure
OsWorld/
โโโ server/
โ โโโ tasks.py
โ โโโ graders.py
โ โโโ OsWorld_environment.py
โโโ models.py
โโโ client.py
โโโ inference.py
โโโ openenv.yaml๐ง Design Philosophy
- Semantic correctness over exact matching
- Robustness against reward hacking
- Real-world data complexity
- Multi-step reasoning evaluation
- Efficiency-aware agent behavior
Built for OpenEnv Hackathon | Designed for serious agent evaluation
