| title | Openenv Space |
|---|---|
| emoji | 🏆 |
| colorFrom | purple |
| colorTo | pink |
| sdk | docker |
| pinned | false |
Replace the CI badge with your repository-specific workflow badge after pushing:
https://huggingface.co/spaces/SurajSeth/openenv-space/
This repository implements a reinforcement learning environment aligned with an OpenEnv-style interface. It simulates realistic operational tasks and includes programmatic graders with continuous scores from 0.0 to 1.0.
The environment focuses on practical decision-making workflows:
- Easy: expense triage under budget and risk constraints.
- Medium: cross-team meeting scheduling with availability and process constraints.
- Hard: production incident response with mitigation, communication, and closure requirements.
The implementation provides:
- A complete environment interface (
metadata,tasks,reset,step,grade,render,close). - Pydantic models for actions, observations, steps, reset responses, and grading outputs.
- Reward shaping that promotes incremental progress and penalizes low-quality behavior.
- A baseline inference script using the OpenAI Python client with credentials read from
HF_TOKEN.
Actions are JSON objects with this schema:
{
"command": "string",
"args": {}
}Command set varies by task and is surfaced in each observation as allowed_commands.
Each step returns a typed observation with:
task_id,step_index,max_stepsscoreandprogressin [0.0, 1.0]summaryof current statestate_viewwith task-specific structured stateallowed_commandsdone
At each step, reward is computed as:
reward = 1.8 * (new_score - previous_score) + invalid_penalty + harmful_penalty - 0.01
Key shaping behavior:
- Positive reward for score improvements.
- Slight per-step cost to encourage shorter successful trajectories.
- Penalty for invalid actions.
- Stronger penalty for explicitly undesirable behavior (for example
approve_all,ignore_incident,delete_data). - Small completion bonus on successful termination.
- Extra dense shaping on the hard task to reward intermediate incident-response milestones (acknowledgements, mitigations, impact reduction, communication) and penalize stalling with
noopduring active impact.
- Goal: classify transactions and maintain budget health.
- Grader combines:
- Completion ratio of reviewed transactions.
- Budget compliance score.
- Proper handling of risky entertainment expense.
- Goal: choose a feasible meeting time, create an agenda, send invites.
- Grader combines:
- Time feasibility for required participants.
- Invite completion.
- Agenda completeness.
- Goal: acknowledge alerts, apply mitigations, reduce customer impact, communicate, and publish postmortem.
- Grader combines:
- Alert acknowledgment ratio.
- Mitigation completion ratio.
- Customer impact reduction.
- Status page communication.
- Postmortem publication.
All graders return values in [0.0, 1.0].
openenv_env/spec.py: OpenEnv interface and Pydantic models.openenv_env/tasks.py: task definitions and programmatic graders.openenv_env/environment.py: environment dynamics, transitions, and reward shaping.app.py: FastAPI server entrypoint for deployment.baseline_inference.py: reproducible baseline evaluator.Dockerfile: container definition for Hugging Face Space (docker SDK).
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS/Linux
source .venv/bin/activate
pip install -r requirements.txtQuick local check:
python -m unittest discover -s tests -v
python baseline_inference.py --seed 1337Run local API server:
uvicorn app:app --host 0.0.0.0 --port 7860Docker run:
docker build -t openenv-realworld .
docker run --rm -p 7860:7860 openenv-realworldHeuristic baseline (deterministic):
python baseline_inference.py --seed 1337Model-driven baseline (OpenAI client):
set HF_TOKEN=<your_api_key> # Windows PowerShell: $env:HF_TOKEN="..."
python baseline_inference.py --use-model --model gpt-4.1-mini --seed 1337If you omit --model, the script chooses a provider-appropriate default automatically:
HF_TOKEN->meta-llama/Meta-Llama-3.1-8B-InstructOPENAI_API_KEY->gpt-4.1-mini
By default, the script uses:
- OpenAI Python client with chat-completions.
- API key from
HF_TOKENorOPENAI_API_KEY. - Automatic provider detection from token prefix.
- No base URL required in the common case.
- Hugging Face tokens default to
https://router.huggingface.co/v1. - OpenAI keys default to
https://api.openai.com/v1. - Deterministic decoding (
temperature=0) and fixed seeds.
If you want to override the endpoint explicitly, set HF_OPENAI_BASE_URL or OPENAI_BASE_URL.
The script now validates these combinations up front:
HF_TOKENstarting withhf_routes to Hugging Face automaticallyOPENAI_API_KEYstarting withsk-routes to OpenAI automatically- You can still override either endpoint with
HF_OPENAI_BASE_URLorOPENAI_BASE_URL
Output format:
{
"model": "...",
"seed": 1337,
"task_scores": {
"easy_expense_triage": 1.0,
"medium_meeting_scheduler": 1.0,
"hard_incident_response": 1.0
},
"aggregate_score": 1.0
}This repo is configured for containerized Spaces via README front matter (sdk: docker) and a working Dockerfile.
On Hugging Face:
- Create a new Space.
- Choose Docker SDK.
- Push this repository.
- Ensure Space secret
HF_TOKENis set if running model-based baseline inside the Space.
The container serves on port 7860 and exposes environment endpoints:
GET /POST /reset/{task_id}POST /stepGET /grade
Unit tests are in tests/test_environment.py and cover:
- interface/task availability,
- seed reproducibility,
- invalid/undesirable action penalties,
- baseline policy completion across all tasks.
GitHub Actions workflow in .github/workflows/ci.yml runs:
ruff check .python -m unittest discover -s tests -vpython baseline_inference.py --seed 1337