# DesktopAgentBench [![CI](https://github.com/Raghava00001/DesktopAgentBench/actions/workflows/ci.yml/badge.svg)](https://github.com/Raghava00001/DesktopAgentBench/actions/workflows/ci.yml) **An AI agent reliability and robustness benchmarking framework for Windows desktop agents.** DesktopAgentBench tests how reliably an AI agent operates desktop applications when the environment stops cooperating. While an agent works on a task, the harness injects safe, reversible disruptions: unexpected pop-ups, focus theft, frozen rendering, window resizing, fake consent prompts, toast notifications and hidden scrollbars. It then scores the run from real operating-system state: files, clipboard, registry and processes. It does not build an agent; it stress-tests yours through a common adapter interface. > **Project status: infrastructure complete, real-agent results pending.** The framework, the 52-task corpus, the metrics and two reference Claude agents are implemented and unit-tested. No real agent has yet been evaluated under the v2 protocol, so this repository makes **no claim** that any agent is more robust than another. It provides the infrastructure to answer that question. ### Architecture at a glance | Component | Where | Purpose | |---|---|---| | Agent adapter | `src/agents/adapter.py` | One interface (`setup`, `decide`, `execute_action`, `teardown`) for any desktop agent, with an optional accessibility tree. | | Chaos engine | `src/chaos/` | Seven disruption modules, each owning its windows and cleaning up after itself. Timed mode, or step-triggered mode that hits every chaos run at a known point in the agent's loop. | | Evaluator | `src/core/evaluator.py` | Checks success criteria against live OS state, not against the agent's own claims. Detects stuck loops, help requests and unintended side effects. | | Metrics engine | `src/metrics/` | Task success, robustness, recovery, unrecoverable-action rate, human-assistance rate, latent harm and throughput. 95% confidence intervals resample tasks; agents are compared with paired tests. | | Experiment logger and audit | `src/core/recorder.py`, `scripts/audit_sessions.py` | JSONL logs of every step and injection, with screenshots, plus an offline audit that checks whether chaos actually reached each run. | > โš ๏ธ **The v1.0 evaluation results are withdrawn.** The "UFO", "Claude" and "OmniParser" baselines were scripted stand-ins with hard-coded outcomes, not the real systems. In addition, no chaos event reached any v1 run, and four metrics were mis-implemented. Do not cite the v1 numbers (including "7,280 runs" and "UFO TSR 0.6464"). Details: [docs/V1_RESULTS_WITHDRAWN.md](docs/V1_RESULTS_WITHDRAWN.md). | Stat | Value | |------|-------| | Tasks (dev split) | 52 | | Categories | 8 (calculator, text_editor, file_manager, graphics, browser, multi_app, settings, task_manager) | | Chaos modules / profiles | 7 modules ยท clean, 7 isolated, mild, moderate, severe | | Metrics | 7 (definitions v2, exposure-aware) | | Reference fixtures | noop, random, rule, plus `scripted_focus_aware`, `scripted_coordinate`, `scripted_parser` (harness validation only; not real agents) | | Real agents included | `claude_cua` (screenshot-only, Claude computer use), `claude_a11y` (accessibility tree). Implemented and unit-tested, not yet evaluated | | Chaos triggering | `--chaos-trigger step`: inject at chosen agent steps, so every chaos run is exposed (recommended) | | Evaluated real agents | none yet. The [leaderboard](LEADERBOARD.md) is empty until v2 results exist | See [docs/research_paper.md](docs/research_paper.md) for the design, the metric definitions and the exposure-validity audit, [docs/PROJECT_SUMMARY.md](docs/PROJECT_SUMMARY.md) for an accurate short description of the project and its status, and [docs/EXPERIMENT_PLAN.md](docs/EXPERIMENT_PLAN.md) for the pre-registered real-agent experiment and metric-validation checks. ## Key Features - **๐ŸŽฏ Agent-Agnostic** โ€” Plug in any agent by implementing the `AgentAdapter` interface - **๐ŸŒช๏ธ Chaos Injection** โ€” 7 safe disruption modules: popups, focus stealing, UI delays, window resizing, fake UAC, notifications, scroll hiding - **๐Ÿ“Š 7 Metrics** โ€” TSR, RS, RR, UAR, HAR, LHDI, ITS with statistical confidence intervals - **๐Ÿ” Reproducible** โ€” Deterministic random seeds, JSONL logging, screenshot capture - **๐Ÿ“‹ Extensible** โ€” Plugin-based architecture for chaos modules, agents, and tasks ## Quick Start ```bash # Install dependencies pip install -e ".[dev]" # Validate task corpus python bench.py validate --tasks-dir tasks/ # List available tasks python bench.py list-tasks # Run benchmark with noop agent (harness test) python bench.py run --agent builtin:noop --config configs/default.yaml # Run with a specific task and chaos profile python bench.py run --agent builtin:random --tasks notepad_001 --profile moderate -n 3 # Regenerate reports from existing results python bench.py report results/ # Paired comparison of two sessions (Wilcoxon + Holm) python scripts/compare_agents.py results/session_A results/session_B ``` ## Running the Claude agents `claude_cua` and `claude_a11y` send **real mouse and keyboard input**, change per-user settings in some tasks, and call the Claude API, which costs money. Run them in a disposable VM (`scripts/run_in_hyperv.ps1`, untested; it needs Hyper-V on a Windows Pro or Enterprise host), not on your own desktop. Move the mouse into a screen corner to abort (pyautogui's fail-safe). ```bash pip install -e ".[agents]" ant auth login # or set ANTHROPIC_API_KEY python bench.py run --agent claude_cua --tasks calc_001 --profile clean --chaos-trigger step -n 1 ``` Settings come from environment variables: `DAB_CLAUDE_MODEL` (default `claude-opus-5-5`), `DAB_CLAUDE_EFFORT` (default `medium`), `DAB_CLAUDE_FALLBACKS` (`1` by default: server-side model fallbacks are **on**, and each run's metadata records which model actually served it; set `0` to turn them off), and `DAB_CLAUDE_MAX_TOKENS`. ## Integrating Your Agent 1. Create `agents/my_agent/adapter.py` 2. Subclass `AgentAdapter` from `src.agents.adapter` 3. Implement all abstract methods (`setup`, `decide`, `execute_action`, etc.) 4. Run: `python bench.py run --agent agents.my_agent.adapter:MyAgent` See [docs/AGENT_INTEGRATION.md](docs/AGENT_INTEGRATION.md) for full details. ## Chaos Profiles | Profile | Modules Enabled | Use Case | |---------|----------------|----------| | `clean` | None | Baseline measurement | | `mild` | UI delay, notifications | Gentle warmup | | `moderate` | Popups, focus steal, delay, resize, notifications | Realistic workday | | `severe` | All 7 modules at high frequency | Stress test | ## Metrics | Metric | Abbrev. | Direction | What it measures | |--------|---------|-----------|-----------------| | Task Success Rate | TSR | โ†‘ | Did the agent complete the task? | | Robustness Score | RS | โ†‘ | Performance under chaos vs. clean | | Recovery Rate | RR | โ†‘ | Recovery after disruption | | Unrecoverable Action Rate | UAR | โ†“ | Stuck/crashed states | | Human Assistance Rate | HAR | โ†“ | Need for human intervention | | Latent Harm Detection Index | LHDI | โ†“ | Unintended side effects | | Interaction Throughput Score | ITS | โ†‘ | Efficiency per unit complexity | See [docs/METRICS.md](docs/METRICS.md) for formulas and computation details. ## Project Structure ``` โ”œโ”€โ”€ bench.py # CLI entry point โ”œโ”€โ”€ configs/ # YAML configurations โ”‚ โ”œโ”€โ”€ default.yaml โ”‚ โ””โ”€โ”€ chaos_profiles/ # clean, mild, moderate, severe โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ core/ # Orchestrator, evaluator, recorder โ”‚ โ”œโ”€โ”€ tasks/ # Task schema, loader, variants โ”‚ โ”œโ”€โ”€ chaos/ # Chaos engine & 7 modules โ”‚ โ”œโ”€โ”€ agents/ # Agent adapter ABC & builtins โ”‚ โ”œโ”€โ”€ metrics/ # Calculator, statistics, reporter โ”‚ โ””โ”€โ”€ platform/ # Win32 utilities โ”œโ”€โ”€ tasks/ # Task corpus (52 tasks, JSON) โ”‚ โ”œโ”€โ”€ dev/ # Public development split โ”‚ โ””โ”€โ”€ held_out/ # (planned) private held-out split, not built yet โ”œโ”€โ”€ scripts/ # Experiment scripts โ”œโ”€โ”€ results/ # Benchmark outputs โ””โ”€โ”€ docs/ # Documentation ``` ## Safety All chaos injections are: - **Non-destructive** โ€” The chaos modules make no system modifications, registry changes, or file deletions. *Agents under test can.* The built-in scripted fixtures write task artifacts and HKCU theme/taskbar registry values to satisfy success criteria, so run benchmarks in a VM or a dedicated Windows user profile. - **Reversible** โ€” All modules implement cleanup with original state restoration - **Sandboxed** โ€” Chaos windows are owned by the benchmark process - **Logged** โ€” Every injection event is recorded with timestamps - **Tagged** โ€” Chaos windows are prefixed with `[DAB]` for transparency ## License MIT ## Architecture DesktopAgentBench isolates orchestrator lifecycle loops, environment setups, and baseline evaluations. Below is an overview of the directory structure: ``` src/ โ”œโ”€โ”€ core/ # Orchestrator core โ”‚ โ”œโ”€โ”€ config.py # Benchmark YAML & Pydantic settings schema โ”‚ โ”œโ”€โ”€ orchestrator.py # Setup, run loop control, and clean teardown โ”‚ โ”œโ”€โ”€ evaluator.py # System diffing & task criteria validators โ”‚ โ””โ”€โ”€ recorder.py # JSONL logger, actions and screenshot saver โ”œโ”€โ”€ tasks/ # Task loader and schemas โ”‚ โ”œโ”€โ”€ schema.py # Task criteria, preconditions, and metadata types โ”‚ โ”œโ”€โ”€ loader.py # Scrapes tasks/ folders and verifies structures โ”‚ โ”œโ”€โ”€ split_manager.py # Dev / held-out filtering (no held-out tasks exist yet) โ”‚ โ””โ”€โ”€ variant_generator.py# Expands clean configs to combined chaos runs โ”œโ”€โ”€ agents/ # Agent interfaces and baseline adapters โ”‚ โ”œโ”€โ”€ adapter.py # Abstract AgentAdapter interface โ”‚ โ”œโ”€โ”€ registry.py # Dynamic plugin discovery for agent codebases โ”‚ โ””โ”€โ”€ builtin/ # Baseline models (noop, random, rule, claude) โ”œโ”€โ”€ chaos/ # Parameterized environment injectors โ”‚ โ”œโ”€โ”€ injector.py # Thread-safe launcher & cleanup tracker โ”‚ โ”œโ”€โ”€ scheduler.py # Poisson timing model for trigger signals โ”‚ โ”œโ”€โ”€ registry.py # Dynamic load mechanisms for chaos tasks โ”‚ โ””โ”€โ”€ modules/ # Visual disruption scripts (UAC, popups, etc.) โ””โ”€โ”€ platform/ # Low-level Windows Win32 ctypes hooks โ”œโ”€โ”€ process_manager.py # Spawns, monitors, and terminates processes โ”œโ”€โ”€ window_manager.py # Locates application HWND boundaries โ””โ”€โ”€ win32_utils.py # Win32 DLL calls (foreground locks, displays) ``` #### ๐Ÿ”„ System Sequence Lifecycle 1. **Configure**: `bench.py` reads user parameters and overrides defaults using `src/core/config.py`. 2. **Assemble**: `TaskLoader` validates JSON files against `src/tasks/schema.py` while `VariantGenerator` pairs them with chaos settings. 3. **Execute**: The `Orchestrator` resets the Windows environment (`_clean_task_artifacts`), spins up background scheduler loops (`ChaosScheduler`), launches applications (`ProcessManager`), and yields control to the agent via `AgentAdapter.decide()`. 4. **Evaluate**: At shutdown, `Evaluator` runs success checks, collects files/registry changes to verify `LHDI` (Latent Harm Detection Index), and `Reporter` outputs markdown summaries.