Spaces:
Paused
Paused
Aryan commited on
Commit ·
b34d858
1
Parent(s): deb602f
restructured inference.py and updated readme
Browse files
scheduling_assistant/Dockerfile → Dockerfile
RENAMED
|
File without changes
|
README.md
CHANGED
|
@@ -1,41 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# Scheduling Assistant - OpenEnv
|
| 2 |
|
| 3 |
-
|
|
|
|
| 4 |
|
| 5 |
-
##
|
| 6 |
-
|
| 7 |
-
1. Lookup employee information (names, timezones)
|
| 8 |
-
2. View cross-timezone calendars and manage overlap.
|
| 9 |
-
3. Successfully book and prioritize syncs across different levels of complexity.
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
##
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
## Action Space
|
| 20 |
-
`
|
| 21 |
-
- `action_type`: One of `['lookup_employee', 'view_calendar', 'book_meeting', 'cancel_meeting', 'submit_task']`
|
| 22 |
-
- `employee_ids`: Array of strings
|
| 23 |
-
- `start_time`: ISO 8601 string
|
| 24 |
-
- `end_time`: ISO 8601 string
|
| 25 |
-
- `meeting_id`: String (
|
| 26 |
|
| 27 |
## Observation Space
|
| 28 |
-
|
| 29 |
-
- `current_simulated_time`: ISO 8601
|
| 30 |
-
- `task_description`:
|
| 31 |
-
- `last_action_result`: Outcome of the
|
| 32 |
-
- `error_message`:
|
| 33 |
|
| 34 |
-
##
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Scheduling Assistant OpenEnv
|
| 3 |
+
emoji: 🗓️
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- openenv
|
| 10 |
+
- benchmark
|
| 11 |
+
- agents
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
# Scheduling Assistant - OpenEnv
|
| 15 |
|
| 16 |
+
## Motivation & Description
|
| 17 |
+
Corporate scheduling is notoriously difficult for LLM agents. While static QA benchmarks test reasoning in a vacuum, calendar management evaluates an agent's ability to act on temporal data, perform cross-timezone arithmetic, and navigate multi-step constraint satisfaction. This OpenEnv benchmark simulates a backend scheduling system to rigidly test these capabilities in a programmatic, autonomous evaluation loop.
|
| 18 |
|
| 19 |
+
## Setup & Running
|
| 20 |
+
The environment is containerized. It should run seamlessly via Docker or bare metal Python.
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
### Via Bare Metal:
|
| 23 |
+
```bash
|
| 24 |
+
cd scheduling_assistant
|
| 25 |
+
pip install -r requirements.txt
|
| 26 |
+
export OPENAI_API_KEY="sk-..." # Or any valid proxy like Groq
|
| 27 |
+
export TASK_LEVEL="medium" # "easy" | "medium" | "hard"
|
| 28 |
+
python inference.py
|
| 29 |
+
```
|
| 30 |
|
| 31 |
+
### Via Docker:
|
| 32 |
+
```bash
|
| 33 |
+
docker build -t openenv-scheduler .
|
| 34 |
+
docker run -e OPENAI_API_KEY="sk-..." -e TASK_LEVEL="easy" openenv-scheduler
|
| 35 |
+
```
|
| 36 |
|
| 37 |
## Action Space
|
| 38 |
+
The agent navigates the environment using the `step_environment` tool. The action schema expects a JSON object containing:
|
| 39 |
+
- `action_type`: Evaluated string routing. One of `['lookup_employee', 'view_calendar', 'book_meeting', 'cancel_meeting', 'submit_task']`
|
| 40 |
+
- `employee_ids`: Array of strings (e.g. `["charlie", "alice"]`)
|
| 41 |
+
- `start_time`: ISO 8601 string containing timezone information
|
| 42 |
+
- `end_time`: ISO 8601 string containing timezone information
|
| 43 |
+
- `meeting_id`: String (UUID) targeted for cancellation
|
| 44 |
|
| 45 |
## Observation Space
|
| 46 |
+
The environment emits a strict observation dictionary after every action:
|
| 47 |
+
- `current_simulated_time`: Static simulated execution time in ISO 8601.
|
| 48 |
+
- `task_description`: The specific instructions and targets for the chosen episode difficulty.
|
| 49 |
+
- `last_action_result`: Outcome array/string of the previously called functionality (e.g. returned calendars).
|
| 50 |
+
- `error_message`: Missing variables, formatting limitations, or failed logical constraint messages (e.g. "Outside working hours for {employee}").
|
| 51 |
|
| 52 |
+
## Task Descriptions & Difficulty
|
| 53 |
|
| 54 |
+
- **Easy**: Book a 30-minute sync between two people in the identical timezone (UTC) tomorrow.
|
| 55 |
+
- *Evaluation*: Tests basic JSON array filtering and time addition within standard constraints.
|
| 56 |
+
- **Medium**: Schedule a 1-hour global all-hands matching the active 9-to-5 working hours of 4 specific employees across distinct timezones (PST, EST, UTC, and CST).
|
| 57 |
+
- *Evaluation*: Tests rigorous temporal overlap arithmetic. There is exactly one valid 1-hour global window where all 4 conditions are met.
|
| 58 |
+
- **Hard**: The CEO needs an urgent sync that overlaps a booked slot. The agent must override a "low priority" internal meeting to book the VIP event, and reschedule the bumped meeting, all without cancelling "high priority" syncs.
|
| 59 |
+
- *Evaluation*: Tests multi-hop logic, priority understanding, and state backtracking over multiple continuous actions.
|
| 60 |
+
|
| 61 |
+
## Baseline Scores
|
| 62 |
+
Testing was conducted locally with **`llama-3.3-70b-versatile`** (Groq) heavily capped by `MAX_STEPS = 15`.
|
| 63 |
+
|
| 64 |
+
| Difficulty | Baseline Score (Total Reward) | Observations |
|
| 65 |
+
| :--- | :--- | :--- |
|
| 66 |
+
| **Easy** | `1.0` | Successfully deduced calendar holes, passed the constraint checker, and successfully booked. |
|
| 67 |
+
| **Medium** | `0.2` | Successfully filtered out the employee IDs and scanned calendars, but critically failed to blindly deduce the precise global hour overlap. Trapped in an iterative trial-and-error cycle until max steps were reached. |
|
| 68 |
+
| **Hard** | `0.1 - 0.2` | Agent correctly maps the target IDs but is mathematically bottlenecked similar to the Medium benchmark. Exhausts tools prior to completion. |
|
scheduling_assistant/env.py → env.py
RENAMED
|
@@ -23,7 +23,7 @@ EMPLOYEES = {
|
|
| 23 |
"bob": {"id": "bob", "name": "Bob", "timezone": "UTC"},
|
| 24 |
"charlie": {"id": "charlie", "name": "Charlie", "timezone": "US/Pacific"},
|
| 25 |
"dave": {"id": "dave", "name": "Dave", "timezone": "US/Eastern"},
|
| 26 |
-
"eve": {"id": "eve", "name": "Eve", "timezone": "
|
| 27 |
"ceo": {"id": "ceo", "name": "CEO", "timezone": "US/Eastern"},
|
| 28 |
"vp_sales": {"id": "vp_sales", "name": "VP of Sales", "timezone": "US/Pacific"}
|
| 29 |
}
|
|
@@ -73,7 +73,7 @@ class SchedulingEnv:
|
|
| 73 |
|
| 74 |
elif self.task_level == "medium":
|
| 75 |
self.task_description = (
|
| 76 |
-
"Schedule a 1-hour meeting for 4 people: Charlie (PST), Dave (EST), Alice (UTC), and Eve (
|
| 77 |
"The meeting must fall specifically within the 9-to-5 local working hours of ALL 4 participants tomorrow (Oct 11). "
|
| 78 |
"When finished, run submit_task."
|
| 79 |
)
|
|
@@ -161,6 +161,8 @@ class SchedulingEnv:
|
|
| 161 |
return False
|
| 162 |
|
| 163 |
def step(self, action: Action) -> tuple[Dict, float, bool]:
|
|
|
|
|
|
|
| 164 |
self.current_step += 1
|
| 165 |
reward = 0.0
|
| 166 |
done = False
|
|
|
|
| 23 |
"bob": {"id": "bob", "name": "Bob", "timezone": "UTC"},
|
| 24 |
"charlie": {"id": "charlie", "name": "Charlie", "timezone": "US/Pacific"},
|
| 25 |
"dave": {"id": "dave", "name": "Dave", "timezone": "US/Eastern"},
|
| 26 |
+
"eve": {"id": "eve", "name": "Eve", "timezone": "US/Central"},
|
| 27 |
"ceo": {"id": "ceo", "name": "CEO", "timezone": "US/Eastern"},
|
| 28 |
"vp_sales": {"id": "vp_sales", "name": "VP of Sales", "timezone": "US/Pacific"}
|
| 29 |
}
|
|
|
|
| 73 |
|
| 74 |
elif self.task_level == "medium":
|
| 75 |
self.task_description = (
|
| 76 |
+
"Schedule a 1-hour meeting for 4 people: Charlie (PST), Dave (EST), Alice (UTC), and Eve (CST). "
|
| 77 |
"The meeting must fall specifically within the 9-to-5 local working hours of ALL 4 participants tomorrow (Oct 11). "
|
| 78 |
"When finished, run submit_task."
|
| 79 |
)
|
|
|
|
| 161 |
return False
|
| 162 |
|
| 163 |
def step(self, action: Action) -> tuple[Dict, float, bool]:
|
| 164 |
+
if action.employee_ids:
|
| 165 |
+
action.employee_ids = [e.lower() for e in action.employee_ids]
|
| 166 |
self.current_step += 1
|
| 167 |
reward = 0.0
|
| 168 |
done = False
|
scheduling_assistant/inference.py → inference.py
RENAMED
|
@@ -1,7 +1,28 @@
|
|
| 1 |
import os
|
| 2 |
import json
|
|
|
|
| 3 |
from openai import OpenAI
|
| 4 |
from env import SchedulingEnv, Action
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
def main():
|
| 7 |
hf_token = os.getenv("HF_TOKEN")
|
|
@@ -29,7 +50,7 @@ def main():
|
|
| 29 |
|
| 30 |
obs = env.reset()
|
| 31 |
|
| 32 |
-
|
| 33 |
|
| 34 |
messages = [
|
| 35 |
{
|
|
@@ -61,18 +82,26 @@ def main():
|
|
| 61 |
}
|
| 62 |
]
|
| 63 |
|
|
|
|
| 64 |
total_reward = 0.0
|
|
|
|
|
|
|
| 65 |
|
| 66 |
for step_num in range(1, env.max_steps + 1):
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
response = client.chat.completions.create(
|
| 70 |
-
model=model_name,
|
| 71 |
-
messages=messages,
|
| 72 |
-
tools=tools,
|
| 73 |
-
tool_choice={"type": "function", "function": {"name": "step_environment"}}
|
| 74 |
-
)
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
response_message = response.choices[0].message
|
| 77 |
messages.append(response_message)
|
| 78 |
|
|
@@ -80,17 +109,22 @@ def main():
|
|
| 80 |
if not tool_calls:
|
| 81 |
# Model failed to call a tool, force a submit task
|
| 82 |
action = Action(action_type="submit_task")
|
|
|
|
| 83 |
obs, reward, done = env.step(action)
|
| 84 |
total_reward = reward
|
|
|
|
|
|
|
| 85 |
break
|
| 86 |
|
| 87 |
tool_call = tool_calls[0]
|
|
|
|
| 88 |
try:
|
| 89 |
-
action_args = json.loads(
|
| 90 |
action = Action(**action_args)
|
| 91 |
except Exception as e:
|
| 92 |
# Fallback if invalid action
|
| 93 |
action = Action(action_type="submit_task")
|
|
|
|
| 94 |
|
| 95 |
messages.append({
|
| 96 |
"role": "tool",
|
|
@@ -101,16 +135,21 @@ def main():
|
|
| 101 |
|
| 102 |
obs, reward, done = env.step(action)
|
| 103 |
total_reward = reward
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
|
|
|
|
|
|
|
|
|
| 105 |
messages.append({
|
| 106 |
"role": "user",
|
| 107 |
"content": f"Observation:\n{json.dumps(obs)}\nReward so far: {reward}"
|
| 108 |
})
|
| 109 |
-
|
| 110 |
-
if done:
|
| 111 |
-
break
|
| 112 |
|
| 113 |
-
|
|
|
|
| 114 |
|
| 115 |
if __name__ == "__main__":
|
| 116 |
main()
|
|
|
|
| 1 |
import os
|
| 2 |
import json
|
| 3 |
+
from typing import List, Optional
|
| 4 |
from openai import OpenAI
|
| 5 |
from env import SchedulingEnv, Action
|
| 6 |
+
from dotenv import load_dotenv
|
| 7 |
+
|
| 8 |
+
load_dotenv()
|
| 9 |
+
|
| 10 |
+
def log_start(task: str, env: str, model: str) -> None:
|
| 11 |
+
print(f"[START] task={task} env={env} model={model}", flush=True)
|
| 12 |
+
|
| 13 |
+
def log_step(step: int, action: str, reward: float, done: bool, error: Optional[str]) -> None:
|
| 14 |
+
error_val = str(error).replace('\n', ' ') if error else "null"
|
| 15 |
+
done_val = str(done).lower()
|
| 16 |
+
# clean newlines from action
|
| 17 |
+
action = action.replace('\n', ' ')
|
| 18 |
+
print(
|
| 19 |
+
f"[STEP] step={step} action={action} reward={reward:.2f} done={done_val} error={error_val}",
|
| 20 |
+
flush=True,
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
def log_end(success: bool, steps: int, score: float, rewards: List[float]) -> None:
|
| 24 |
+
rewards_str = ",".join(f"{r:.2f}" for r in rewards)
|
| 25 |
+
print(f"[END] success={str(success).lower()} steps={steps} score={score:.3f} rewards={rewards_str}", flush=True)
|
| 26 |
|
| 27 |
def main():
|
| 28 |
hf_token = os.getenv("HF_TOKEN")
|
|
|
|
| 50 |
|
| 51 |
obs = env.reset()
|
| 52 |
|
| 53 |
+
log_start(task=task_level, env="scheduling_benchmark", model=model_name)
|
| 54 |
|
| 55 |
messages = [
|
| 56 |
{
|
|
|
|
| 82 |
}
|
| 83 |
]
|
| 84 |
|
| 85 |
+
rewards_list = []
|
| 86 |
total_reward = 0.0
|
| 87 |
+
steps_taken = 0
|
| 88 |
+
done = False
|
| 89 |
|
| 90 |
for step_num in range(1, env.max_steps + 1):
|
| 91 |
+
steps_taken = step_num
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
+
try:
|
| 94 |
+
response = client.chat.completions.create(
|
| 95 |
+
model=model_name,
|
| 96 |
+
messages=messages,
|
| 97 |
+
tools=tools,
|
| 98 |
+
tool_choice={"type": "function", "function": {"name": "step_environment"}}
|
| 99 |
+
)
|
| 100 |
+
except Exception as e:
|
| 101 |
+
error_msg = f"Model API Error: {str(e)}"
|
| 102 |
+
log_step(step=step_num, action="api_call_failed", reward=total_reward, done=True, error=error_msg)
|
| 103 |
+
break
|
| 104 |
+
|
| 105 |
response_message = response.choices[0].message
|
| 106 |
messages.append(response_message)
|
| 107 |
|
|
|
|
| 109 |
if not tool_calls:
|
| 110 |
# Model failed to call a tool, force a submit task
|
| 111 |
action = Action(action_type="submit_task")
|
| 112 |
+
action_str = "submit_task (force_fallback)"
|
| 113 |
obs, reward, done = env.step(action)
|
| 114 |
total_reward = reward
|
| 115 |
+
rewards_list.append(reward)
|
| 116 |
+
log_step(step=step_num, action=action_str, reward=reward, done=done, error=obs['error_message'])
|
| 117 |
break
|
| 118 |
|
| 119 |
tool_call = tool_calls[0]
|
| 120 |
+
action_args_str = tool_call.function.arguments
|
| 121 |
try:
|
| 122 |
+
action_args = json.loads(action_args_str)
|
| 123 |
action = Action(**action_args)
|
| 124 |
except Exception as e:
|
| 125 |
# Fallback if invalid action
|
| 126 |
action = Action(action_type="submit_task")
|
| 127 |
+
action_args_str = f"INVALID_JSON: {action_args_str}"
|
| 128 |
|
| 129 |
messages.append({
|
| 130 |
"role": "tool",
|
|
|
|
| 135 |
|
| 136 |
obs, reward, done = env.step(action)
|
| 137 |
total_reward = reward
|
| 138 |
+
rewards_list.append(reward)
|
| 139 |
+
|
| 140 |
+
# log step as per stdout rules
|
| 141 |
+
log_step(step=step_num, action=action_args_str, reward=reward, done=done, error=obs.get('error_message'))
|
| 142 |
|
| 143 |
+
if done:
|
| 144 |
+
break
|
| 145 |
+
|
| 146 |
messages.append({
|
| 147 |
"role": "user",
|
| 148 |
"content": f"Observation:\n{json.dumps(obs)}\nReward so far: {reward}"
|
| 149 |
})
|
|
|
|
|
|
|
|
|
|
| 150 |
|
| 151 |
+
success = total_reward >= 1.0
|
| 152 |
+
log_end(success=success, steps=steps_taken, score=total_reward, rewards=rewards_list)
|
| 153 |
|
| 154 |
if __name__ == "__main__":
|
| 155 |
main()
|
scheduling_assistant/openenv.yaml → openenv.yaml
RENAMED
|
File without changes
|
scheduling_assistant/requirements.txt → requirements.txt
RENAMED
|
@@ -2,3 +2,4 @@ pydantic
|
|
| 2 |
openai
|
| 3 |
python-dateutil
|
| 4 |
pytz
|
|
|
|
|
|
| 2 |
openai
|
| 3 |
python-dateutil
|
| 4 |
pytz
|
| 5 |
+
dotenv
|