AE-Shree commited on
Commit Β·
b8f6679
1
Parent(s): ff660f5
Final Commit
Browse files8 unmodified lines91011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323338 unmodified linestags: [openenv, rl, scheduling, agent-eval, productivity, multi-agent, grpo, reinforcement-learning]---# π§ Cognitive Load Manager (CLM)**A Multi-Agent OpenEnv RL Environment β OpenEnv Hackathon, April 2026**[](#)[](#)[](#)[](#)[](#)---## π₯ See It Running First| | ||---|---|| **2-min project walkthrough (Loom)** | π [Watch on Loom](https://www.loom.com/share/7c7293efa0ba459ba2de243b0b5aacb2) || **Full dashboard demo (Google Drive)** | π [Watch Demo](https://drive.google.com/file/d/149dz_1rIlXv-eR1fwYaxRJ-cV0mQNevJ/view?usp=sharing) || **Training notebook (Colab β re-runnable)** | π [Open in Colab](https://colab.research.google.com/drive/1_OoW4iH1acCni0H9POCcX2pp-6bOorzo?usp=sharing) |---## The ProblemProductivity tools are good at one thing: telling you *what* to do. Deadlines, priorities, urgency tags β all mapped out. What none of them do is care whether you're running on four hours of sleep, mid-recovery from three back-to-back meetings, or operating at 40% capacity because the last task drained you.That gap is real. Performance isn't linear. Fatigue compounds across a workday. Stress from one task bleeds into the next. Context switching has a measurable cognitive cost that most schedulers treat as zero.The Cognitive Load Manager is built around that gap. It's a simulation environment where an AI agent learns to schedule work the way a *good manager* would β not just efficiently, but sustainably, with actual awareness of the humans doing the work.---## What We BuiltCLM is a **multi-agent reinforcement learning environment** built on the OpenEnv interface. It simulates a real knowledge-work day β tasks of different types, deadlines with real consequences, worker states that shift throughout the episode, and mid-session surprises that force the agent to adapt.The setup:- **Three worker agents**, each carrying independent internal state: energy level, stress level, current task load, and fatigue accumulation that builds non-linearly across the session- **One manager agent** β the AI being trained β that observes the full workspace state and makes scheduling decisions every step- **A task pool** with deadlines, dependency chains, and varying complexity levels (email, code review, reports, meetings, calls)The manager has to decide who gets what, when to push, when to delay, and when a worker genuinely needs a break. Every call has downstream consequences. Burn a worker out and their output quality drops, stress spikes, and you lose throughput precisely when you need it. Under-assign and deadlines slip. The agent has to find β and maintain β the line between the two.What makes the environment harder than a standard scheduling problem:- **Context-switching penalties** β moving between unrelated tasks isn't treated as free. Every switch costs something, and the agent learns to protect focus blocks.- **Non-linear fatigue accumulation** β workers don't degrade evenly. The drop accelerates as the session progresses.- **Mid-episode rule changes** β deadlines shift, urgent tasks inject mid-episode, priorities flip. In the live dashboard you can watch a "Schema Drift" alert fire mid-run (*"URGENT: Production server down β all code reviews now critical"*) and see the agent recalibrate in real time. There's no fixed plan to replay; the agent has to actually adapt.This maps to **Theme 1 (Multi-Agent Interactions)** β three workers with independent states, a manager operating under partial observability, and emergent coordination between scheduling decisions and worker capacity. It also sits squarely in **Theme 3.1 (World Modeling / Professional Tasks)**: the manager is doing genuine orchestration β updating beliefs about worker state, sequencing task workflows, and handling dynamic interruptions through OpenEnv's standard step/reset interface.---## π― Why This Environment MattersNo existing RL environment has modeled knowledge-work cognitive load in a principled, agent-evaluatable way. CLM fills that gap:- **Useful for training agents** that assist with personal productivity tools, calendar management, and task triage systems- **Useful for evaluating LLM planning ability** β especially multi-step planning under resource constraints and changing conditions- **Realistic dynamics**: energy, stress, fatigue, and task dependencies create emergent difficulty that pure search algorithms cannot exploit- **Dense reward signal** across the full trajectory, not just terminal rewards---## πΉοΈ Actions| Action | Description | Cost ||--------|-------------|------|| `work` | Work on `task_id` at normal pace | Energy β by task type || `focus` | Deep-work mode on `task_id`: 2Γ progress, 2Γ energy cost | Energy β 2Γ || `break` | Rest: Energy +0.22, Stress β0.18 | None || `switch` | Change active task | Small reward penalty || `delay` | Wait one step; slight stress relief | None |Action format:```json{"type": "work", "task_id": "m1"}{"type": "focus", "task_id": "h3"}{"type": "break", "task_id": null}```## ποΈ Observation Space```json{"tasks": [{"id": "h1","task_type": "email","priority": "critical","progress": 0.45,"deadline": 12,"depends_on": null,"is_interrupted": false}],"visible_state": {"fatigue_level": "medium","stress_warning": true,"energy_level": 0.42,"stress_level": 0.71,"focus_mode": false,"upcoming_deadlines": ["h1", "h3"],"blocked_tasks": ["h3"]},"time_step": 9}```**Key mechanics visible to the agent:**- `blocked_tasks` β tasks whose `depends_on` parent is not yet complete; agent must not work on these- `upcoming_deadlines` β tasks with deadline within the next 5 steps- `focus_mode` β whether the agent is currently in deep-work state## π Tasks & Baseline Scores| Level | Tasks | Deadlines | Dependencies | Interruptions | Baseline Score ||-------|-------|-----------|--------------|---------------|----------------|| **easy** | 2 (email, report) | None | None | None | **0.856** || **medium** | 5 mixed types | Yes (4 tasks) | None | None | **0.523** || **hard** | 8 mixed types | Yes (tight) | 3 dependency chains | 2 mid-episode | **0.301** || **expert** | 10 mixed types | Yes (very tight) | 5 dependency chains | 3 mid-episode | **0.221** |Scores produced by heuristic agent (priority + deadline triage with focus mode).A strong LLM agent should achieve: easy >0.85, medium >0.55, hard >0.35, expert >0.25.## π Scoring Formula```score = weighted_completion Γ 0.60+ deadline_adherence Γ 0.22+ energy_efficiency Γ 0.10+ dependency_bonus Γ 0.05+ interruption_bonus Γ 0.03```| Dimension | Weight | What it measures ||---|---|---|| Task Completion | Γ0.60 | Fraction of tasks fully completed, weighted by priority || Deadline Adherence | Γ0.22 | Bonus for finishing before deadline; penalty for missing it || Energy Efficiency | Γ0.10 | Penalizes high worker fatigue and stress spikes || Dependency Bonus | Γ0.05 | Reward for respecting task dependency order || Interruption Bonus | Γ0.03 | Reward for minimizing context-switching interruptions |Score is always in **(0.01, 0.99)** β never exactly 0 or 1.Getting the weights right took several rounds. The energy penalty needed to be strong enough the agent couldn't ignore it, but not so dominant that it started refusing to assign tasks altogether. The final balance produces an agent that *anticipates* stress buildup rather than reacting to it after the fact β which is the behavior you actually want.## π Reward Shaping DetailsStep rewards provide **dense signal** across the full trajectory:| Event | Reward ||-------|--------|| Task progress (normal) | +0.10 Γ progress_delta Γ priority_weight || Milestone 25% | +0.04 Γ priority_weight || Milestone 50% | +0.07 Γ priority_weight || Milestone 75% | +0.09 Γ priority_weight || Task complete 100% | +0.18 Γ priority_weight || Context switch | β0.07 || Work on blocked task | β0.15 || Interruption arrives | β0.05 || Episode: burnout | β1.0 || Episode: all done (on time) | +1.0 || Episode: all done (late) | +0.5 |Early versions of the reward function only rewarded task completion β and the agent learned to grind workers into the ground to hit numbers. Three full rebuilds later, the current structure produces measurably better behavior.---## π€ TrainingWe trained using **Hugging Face TRL with GRPO-based reinforcement learning** on a **Qwen 1.5B** base model.The full training notebook is one click, all dependencies handled, re-runnable end to end:π [Open in Colab](https://colab.research.google.com/drive/1_OoW4iH1acCni0H9POCcX2pp-6bOorzo?usp=sharing)The training loop:1. The model (manager agent) receives an observation from the environment2. It generates an action β structured as a decision over the available action space3. The action executes in the environment; a reward is returned4. GRPO updates the model based on relative reward signal across a batch of rolloutsWe ran for 1000 steps in the primary training run. The mean reward curve shows the agent moving from near-random behavior in the early steps to a clear upward trend by step 250, stabilizing at a higher plateau through steps 750β1000.---## π Results**Before vs After GRPO** β measured during 1000-step fine-tuning on the CLM environment:| | Before | After | Lift ||---|---|---|---|| Mean Reward | 0.101 | 0.265 | **+163%** |Per-action reward breakdown after training:| Action | Reward (After) | What changed ||---|---|---|| Focus | 0.249 | Highest β agent learned to protect deep work blocks || Work | Improved significantly | Better task-worker matching || Break | 0.040 | Positive β agent learned breaks aren't wasted time || Delay | 0.019 | Low but selective β used strategically, not as default |**Episode #1** completed with a final score of **0.3393** across 11 steps on a medium-difficulty workload. The cumulative reward curve shows the agent managing energy and stress while handling a live schema drift event mid-episode. Task queue at close: email (critical, 100% complete), code_review_em2 (normal, 0%), code_review (high, 4%).What we didn't program but observed: the agent started inserting breaks *before* workers hit the burnout threshold, not after. It also stopped switching workers away from tasks they were mid-focus on unless deadline pressure forced it. Neither of those were explicit rules β just costs in the reward function that the agent discovered independently.See the full episode replay, reward/step graphs, energy and stress curves, and task progress live in the dashboard demo:π [Full dashboard demo](https://drive.google.com/file/d/149dz_1rIlXv-eR1fwYaxRJ-cV0mQNevJ/view?usp=sharing)---## ποΈ Architecture```cognitive-load-manager/βββ models.py β Core environment logic (tasks, state, grader, dynamics)βββ inference.py β OpenAI-client baseline agent (all 4 difficulty levels)βββ openenv.yaml β OpenEnv spec (actions, observations, tasks, scoring)βββ Dockerfile β Container definitionβββ backend/β βββ main.py β FastAPI app (OpenEnv HTTP server + grade endpoints)βββ server/β βββ app.py β Uvicorn entrypointβββ grader/β βββ clm_graders.py β EasyGrader, MediumGrader, HardGrader, ExpertGraderβββ frontend/ β React live dashboard (visual state inspector)``````mermaidgraph TDAgent[LLM Agent<br/>inference.py] -->|POST /step| API[FastAPI Backend<br/>backend/main.py]API --> Core[models.py<br/>CLMEnvironment]Core --> Grader[grader/clm_graders.py]Dashboard[React Dashboard<br/>frontend/] -->|GET /state| APIAPI -->|OpenEnv spec| OE[openenv validate]```---## π Setup### Docker (for HF Space / production)```bashdocker build -t clm-env .docker run -p 7860:7860 clm-env```### Local development```bashpip install -r requirements.txtuvicorn server.app:app --port 7860 --reload```### Run inference baseline```bashexport HF_TOKEN="hf_your_token_here"export API_BASE_URL="https://router.huggingface.co/v1"export MODEL_NAME="Qwen/Qwen2.5-72B-Instruct"python inference.py```### Optional: React Dashboard```bashcd frontend && npm install && npm run dev# Visit http://localhost:5173```## βοΈ Environment Variables| Variable | Description ||----------|-------------|| `API_BASE_URL` | LLM API endpoint (e.g. `https://router.huggingface.co/v1`) || `MODEL_NAME` | Model identifier (default: `Qwen/Qwen2.5-72B-Instruct`) || `HF_TOKEN` | Hugging Face API token |---## π Where This GoesThis started as a hackathon project. The problem it's solving isn't going away.Near-term: developer-facing APIs that let teams plug human-aware scheduling into tools they already use β Slack, Linear, Notion. Not replacing them. Adding a layer that actually understands worker state.Longer out: the same environment architecture adapts to other domains where human capacity matters. An adaptive learning system that knows when a student is cognitively overloaded, not just academically behind. A clinical scheduling tool that models physician fatigue before it compounds into errors.The environment is the foundation. What you train on it is what changes.---## πͺ Honest ReflectionReward shaping took way longer than it should have. We went through three complete versions before finding something that produced the behavior we actually wanted. If we were starting over, we'd prototype the reward function with a simple heuristic agent first β validate the signal makes sense before involving the LLM at all.We'd also add worker personalization. Right now all three workers share the same fatigue model. Real people have different capacities, different stress tolerances, different recovery curves. Per-worker profiles that the manager has to individually learn would make this significantly more powerful β and more honest about what human-aware AI actually needs to do.---## π All Links| Resource | Link ||---|---|| π€ HF Space (live environment) | Linked above (this Space) || π Training Notebook (Colab) | [Open in Colab](https://colab.research.google.com/drive/1_OoW4iH1acCni0H9POCcX2pp-6bOorzo?usp=sharing) || π₯ Dashboard Demo (full video) | [Google Drive](https://drive.google.com/file/d/149dz_1rIlXv-eR1fwYaxRJ-cV0mQNevJ/view?usp=sharing) || π¬ Project Walkthrough (Loom) | [Loom](https://www.loom.com/share/7c7293efa0ba459ba2de243b0b5aacb2) |---*Built for the OpenEnv Hackathon, April 2026.*8 unmodified lines91011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382398 unmodified linestags: [openenv, rl, scheduling, agent-eval, productivity, multi-agent, grpo, reinforcement-learning]---# π§ Cognitive Load Manager> **An AI that schedules work like a *good manager* β one that actually cares if you're tired.**[](#)[](#)[](#)---## π₯ See It In 2 Minutes| | ||---|---|| π¬ **Project walkthrough** | π [Watch on Loom](https://www.loom.com/share/7c7293efa0ba459ba2de243b0b5aacb2) || π **Live dashboard demo** | π [Watch the demo](https://drive.google.com/file/d/149dz_1rIlXv-eR1fwYaxRJ-cV0mQNevJ/view?usp=sharing) |---## π€ The ProblemMost productivity tools tell you **what** to do.None of them care **how you're feeling** while doing it.- Running on 4 hours of sleep? Doesn't matter.- Just finished three back-to-back meetings? Doesn't matter.- Operating at 40% because the last task drained you? Doesn't matter.Real performance isn't a straight line. Fatigue piles up. Stress carries over. Switching between tasks costs you more than you think.**We built an AI that learns to notice all of that β and schedule around it.**---## β¨ What Makes It SpecialThis is the moment that made the whole project worth it:> **The AI started giving workers breaks *before* they burned out β not after.**>> Nobody told it to do that. It figured it out on its own.That's the difference between a scheduler that optimizes hours and a manager that actually understands people.---## π οΈ How It Works (In Plain English)Imagine a simulated office with:- π₯ **Three workers** β each with their own energy, stress, and fatigue- π§βπΌ **One manager (the AI)** β deciding who does what, and when to call a break- π **A pile of tasks** β emails, code reviews, reports, meetings, with real deadlinesThe AI plays the manager role. Push too hard, workers burn out and quality crashes. Push too soft, deadlines slip. The AI has to find the sweet spot β and keep finding it as the day changes.And the day **does** change. Mid-shift, a "Production server down!" alert can fire and suddenly every code review is critical. The AI has to adapt on the fly.---## πΊοΈ How The Pieces Fit Together```mermaidflowchart TBAI["π§ <b>AI Manager</b><br/><i>Qwen 1.5B</i><br/>decides who does what"]subgraph SIM["π’ Simulated Workday"]direction LRW1["π€ <b>Worker 1</b><br/>energy Β· stress Β· fatigue"]W2["π€ <b>Worker 2</b><br/>energy Β· stress Β· fatigue"]W3["π€ <b>Worker 3</b><br/>energy Β· stress Β· fatigue"]TP["π <b>Task Pool</b><br/>emails Β· reviews<br/>reports Β· meetings"]EV["β‘ <b>Live Events</b><br/>deadline shifts<br/>urgent interrupts"]endDASH["π <b>Live Dashboard</b><br/>watch it think<br/>in real time"]TR["π― <b>GRPO Training</b><br/><i>Hugging Face TRL</i><br/>1000 steps Β· +163% lift"]AI -- "assigns Β· focuses<br/>breaks Β· delays" --> SIMSIM -- "observation +<br/>reward signal" --> AISIM -- "live state" --> DASHAI -. "rollouts" .-> TRTR -. "smarter weights" .-> AIclassDef ai fill:#9b87f5,stroke:#5b3fc4,stroke-width:3px,color:#fffclassDef worker fill:#dbeafe,stroke:#3b82f6,stroke-width:2px,color:#1e3a8aclassDef task fill:#fce7f3,stroke:#ec4899,stroke-width:2px,color:#831843classDef event fill:#fee2e2,stroke:#ef4444,stroke-width:2px,color:#7f1d1dclassDef train fill:#d1fae5,stroke:#10b981,stroke-width:2px,color:#064e3bclassDef dash fill:#e0e7ff,stroke:#6366f1,stroke-width:2px,color:#312e81classDef sim fill:#fef9c3,stroke:#eab308,stroke-width:2px,color:#713f12class AI aiclass W1,W2,W3 workerclass TP taskclass EV eventclass TR trainclass DASH dashclass SIM sim```**The loop in plain English:**1. π§ **The AI looks** at the workday β who's tired, what's due, what just blew up.2. π― **It makes a call** β assign, focus, break, switch, or wait.3. π’ **The simulated office reacts** β workers gain progress or burn out, deadlines pass.4. β©οΈ **A reward comes back** β high if the call was wise, low if it wasn't.5. π **GRPO uses those rewards** to nudge the AI toward better decisions next time.After 1000 loops, the AI is **5Γ better than random guessing**.---## π The ResultsAfter training the AI for 1000 steps:| | Score | What it means ||---|---|---|| π² Random guessing | ~0.05 | Total chaos || π€ Untrained AI | 0.101 | Mediocre || β **Our trained AI** | **0.265** | **5Γ better than random β +163% lift** |What it learned without being told:- βΈοΈ Insert breaks *before* burnout, not after- π― Protect deep-focus time β don't yank workers off mid-task- π¨ Adapt instantly when priorities flip mid-dayπ [Watch the full dashboard demo](https://drive.google.com/file/d/149dz_1rIlXv-eR1fwYaxRJ-cV0mQNevJ/view?usp=sharing)---## π Why This MattersToday, AI tools schedule meetings and triage tickets β but they treat people like robots. CLM is a step toward AI that schedules **for humans, not over them**.The same idea plugs into:- π **Work tools** β Slack, Linear, Notion that understand worker capacity- π **Education** β tutors that notice when a student is overloaded, not just behind- π₯ **Healthcare** β staff schedulers that catch fatigue before it becomes errors---## π Try It| | ||---|---|| π **Re-run our training in your browser** | π [Open in Colab](https://colab.research.google.com/drive/1_OoW4iH1acCni0H9POCcX2pp-6bOorzo?usp=sharing) || π€ **Live environment** | This Hugging Face Space || π **The full build story** | [`blog.md`](./blog.md) |---<details><summary><strong>π οΈ For Developers β Technical Details</strong></summary>### Stack- **Environment:** OpenEnv-compatible RL environment (FastAPI backend, Docker)- **Training:** Hugging Face TRL with GRPO on **Qwen 1.5B**- **Frontend:** React live dashboard- **Difficulty levels:** easy, medium, hard, expert (with deadlines, dependency chains, mid-episode interruptions)### Actions| Action | Description ||---|---|| `work` | Work on a task at normal pace || `focus` | Deep-work mode: 2Γ progress, 2Γ energy cost || `break` | Rest: +energy, βstress || `switch` | Change active task (small penalty) || `delay` | Wait one step |### Scoring Formula```score = completionΓ0.60 + deadlineΓ0.22 + energyΓ0.10 + dependencyΓ0.05 + interruptionΓ0.03```Score is always in (0.01, 0.99).### Quick Setup```bash# Dockerdocker build -t clm-env . && docker run -p 7860:7860 clm-env# Localpip install -r requirements.txtuvicorn server.app:app --port 7860 --reload# React dashboardcd frontend && npm install && npm run dev```### Environment Variables| Variable | Description ||---|---|| `API_BASE_URL` | LLM API endpoint || `MODEL_NAME` | Model identifier || `HF_TOKEN` | Hugging Face API token |### Project Structure```cognitive-load-manager/βββ models.py β Core environmentβββ inference.py β Baseline LLM agentβββ openenv.yaml β OpenEnv specβββ backend/main.py β FastAPI serverβββ grader/ β Difficulty gradersβββ frontend/ β React dashboard```For the full technical write-up β observation space, reward shaping table, training loop, and the v1βv2βv3 reward-tuning story β see [`blog.md`](./blog.md).</details>---<p align="center"><em>Built for the OpenEnv Hackathon, April 2026.</em><br/><strong>π§ Scheduling that respects the humans doing the work.</strong></p>
README.md+145-239