# microsoft/windowsagentarena architecture

> Architecture diagram of the GitHub repository microsoft/windowsagentarena, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoft/windowsagentarena
- Repository: https://github.com/microsoft/windowsagentarena

## Overview

##### Main Components
a. Docker Container Infrastructure:
- The project uses Docker extensively. Look at the Dockerfiles in src/win-arena-container and the build scripts in the scripts folder. There’s a base image (WinArena-Base) and a full image (WinArena).
b. Windows Virtual Machine (Golden Image):
- The “vm” directory contains everything for preparing a Windows 11 VM “golden image” – including setup scripts, unattend-files, and configuration files. This VM simulates a real Windows OS for running benchmark tasks.
c. Client/Agent Module:
- Under src/win-arena-container/client you have the evaluation framework, a desktop environment, various evaluation examples, and the implementation of AI agents (e.g., the Navi agent within the mm_agents subdirectory). This module handles running agents by interfacing with the Windows desktop environment.
d. External Integration & Services:
- API keys and external services (OpenAI or Azure OpenAI) are configured via config.json. They provide the LLM backends (for instance, GPT-4 variants) that the agents use.
e. Deployment & Orchestration Scripts:
- The scripts folder (including scripts/run-local.sh, scripts/run_azure.py, experiments.json, and Azure files) orchestrates both local deployment and cloud deployment on Azure ML Compute. This includes VM provisioning, image uploading to Azure Blob storage, and compute orchestration.

##### Establish Relationships and Interactions
- The Docker engine runs a container (built from the WinArena image) that encapsulates the agent environment.
- Within the container, a Windows VM is booted from the golden image (prepared through automated scripts in the vm folder). This VM runs a Windows OS with a Python server for receiving and executing agent commands.
- The client module (inside the container) sends commands to control the desktop environment within the VM. The agents (for example, the Navi agent) interact with various modules (like screen evaluators, accessibility controllers, and screen parsers in the mm_agents folder) to perform tasks.
- External APIs (OpenAI/Azure OpenAI) are contacted by specific agent modules to process language/vision tasks, and configuration files (such as config.json and experiments.json) determine the behavior of these integrations.
- For cloud execution, Azure ML orchestrates multiple compute instances. Each instance uses the startup script (compute-instance-startup.sh) and the pre-uploaded golden image from Azure Blob storage. Execution logs and agent outputs are collected back for result visualization.

##### Architectural Patterns and Design Principles
- Containerization: The entire environment is encapsulated in container images ensuring reproducibility.
- Modularity: Clear separation exists between environment setup (Docker and VM images), client/agent logic (desktop evaluation and mm_agents), and deployment orchestration (local scripts and Azure ML integration).
- Extensibility: The design supports “Bring Your Own Agent” (BYOA) where new agent implementations can be added under the mm_agents directory.

##### Relevant Technologies and Tools
- Docker – for container image building and deployment.
- QEMU/KVM – for local virtualizing a Windows 11 environment.
- Azure ML and Azure Blob Storage – for scalable cloud deployment and storage of the golden image.
- Python – the core language used in the client, agent components, and deployment scripts.
- External APIs (OpenAI/Azure OpenAI) – for LLM and vision processing capabilities.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Local Environment
    subgraph "Local Environment"
        A["Docker Engine"]:::infra
        subgraph "Container Infrastructure"
            A1["WinArena Docker Container"]:::infra
            A2["Dockerfile (WinArena)"]:::infra
            A3["Dockerfile (WinArena-Base)"]:::infra
            A4["Build Script (build-container-image.sh)"]:::infra
        end
        subgraph "Windows VM Environment"
            B1["Windows 11 Golden Image"]:::infra
            B2["VM Preparation Scripts"]:::infra
        end
        subgraph "Client & Agent Module"
            C0["Client/Agent Module"]:::client
            C1["Desktop Environment"]:::client
            C2["Evaluation Examples & mm_agents"]:::client
            C3["Run Script (run.py)"]:::client
            C4["Service Config (settings.json)"]:::client
            C5["Local Run Script (run-local.sh)"]:::deploy
        end
    end

    %% Cloud Environment
    subgraph "Cloud Environment"
        D1["Azure ML Compute Instance"]:::cloud
        D2["Azure Blob Storage (Golden Image)"]:::infra
        D3["Cloud Orchestration (run_azure.py)"]:::deploy
        D4["Experiments Config (experiments.json)"]:::deploy
        D5["Azure Files (azure_files)"]:::deploy
    end

    %% Connections for Local Environment
    A -->|"builds and deploys"| A1
    A1 -->|"boots"| B1
    C0 -->|"controls"| B1
    B1 -->|"sends evaluation data"| C2
    A1 -->|"used by"| D1

    %% Connections for Cloud Environment
    D3 -->|"orchestrates"| D1
    D2 -->|"provides image to"| D1
    D4 -->|"configures"| D3
    D5 -->|"assists"| D3

    %% Click Events for Docker Container Infrastructure
    click A2 "https://github.com/microsoft/windowsagentarena/tree/main/src/win-arena-container/Dockerfile-WinArena"
    click A3 "https://github.com/microsoft/windowsagentarena/tree/main/src/win-arena-container/Dockerfile-WinArena-Base"
    click A4 "https://github.com/microsoft/windowsagentarena/blob/main/scripts/build-container-image.sh"

    %% Click Event for Windows VM Environment
    click B2 "https://github.com/microsoft/windowsagentarena/tree/main/src/win-arena-container/vm"

    %% Click Events for Client/Agent Module
    click C0 "https://github.com/microsoft/windowsagentarena/tree/main/src/win-arena-container/client"
    click C4 "https://github.com/microsoft/windowsagentarena/blob/main/src/win-arena-container/client/settings.json"
    click C3 "https://github.com/microsoft/windowsagentarena/blob/main/src/win-arena-container/client/run.py"
    click C5 "https://github.com/microsoft/windowsagentarena/blob/main/scripts/run-local.sh"

    %% Click Events for Deployment & Orchestration Scripts (Cloud)
    click D3 "https://github.com/microsoft/windowsagentarena/blob/main/scripts/run_azure.py"
    click D4 "https://github.com/microsoft/windowsagentarena/blob/main/scripts/experiments.json"
    click D5 "https://github.com/microsoft/windowsagentarena/tree/main/scripts/azure_files"

    %% Styles
    classDef infra fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef client fill:#F9E79F,stroke:#7D6608,stroke-width:2px;
    classDef cloud fill:#A9DFBF,stroke:#1E8449,stroke-width:2px;
    classDef deploy fill:#FADBD8,stroke:#922B21,stroke-width:2px;
```
