Bring Your Own Agent (BYOA)
mainTo test your own agents, create a new folder under src/win-arena-container/client/mm_agents. Your agent's agent.py file must implement the following two functions:
predict()reset()
repository·main·Indexed 21 days ago
https://github.com/microsoft/windowsagentarenaA scalable platform for testing and benchmarking multi-modal AI agents within a realistic Windows OS environment. WAA supports reproducible research and large-scale deployment via Azure ML, featuring a Windows 11 VM snapshot and support for various accessibility backends and screen element detection methods like Omniparser. It allows users to run benchmarks locally on WSL/Linux or parallelize them using Azure Machine Learning Compute VMs, and provides a 'Bring Your Own Agent' (BYOA) framework for testing custom agents.
To test your own agents, create a new folder under src/win-arena-container/client/mm_agents. Your agent's agent.py file must implement the following two functions:
predict()reset()If you are developing agents or extensions, you can launch the Docker container without automatically starting the VM or client processes. This allows you to control the lifecycle of each component manually.
cd scripts
./run-local.sh --interactive truebash), run processes manually:./start_vm.sh./start_client.shcd scripts
./run-local.sh --interactive true
# Inside the container:
./start_vm.sh
./start_client.shPlaywright is used for browser automation.
Installation:
pip install playwright
playwright installBasic Usage Example:
from playwright.sync_api import sync_playwright
def run(playwright):
browser = playwright.chromium.launch()
page = browser.new_page()
page.goto("http://example.com")
## other actions...
browser.close()
with sync_playwright() as playwright:
run(playwright)from playwright.sync_api import sync_playwright
def run(playwright):
browser = playwright.chromium.launch()
page = browser.new_page()
page.goto("http://example.com")
## other actions...
browser.close()
with sync_playwright() as playwright:
run(playwright)Local deployment on WSL or Linux involves two main steps: configuring the configuration file and preparing the Windows Arena Docker image.
Ensure your configuration file is set up according to the project requirements.
Use the provided build script to prepare the Docker image. If you have made changes to Dockerfile-WinArena-Base, you must use the --build-base-image flag to rebuild the base image locally.
# Build the image including the base image if Dockerfile-WinArena-Base was changed
./build-container-image.sh --build-base-image true
# View all available build options
./build-container-image.sh --helpTo create multiple VMs with the same configuration without re-running the full setup, you can back up and reuse the Windows image files.
Back up all files located in src/win-arena-container/vm/storage:
data.imgwindows.basewindows.bootwindows.macwindows.romwindows.varswindows.verDepending on which LibreOffice component you are evaluating, install the following Python libraries:
For LibreOffice Present:
pip install python-pptxFor LibreOffice Writer:
pip install python-docx odfpypip install python-pptx
pip install python-docx odfpyFollow these steps to prepare your Azure environment:
agents) in your preferred region.agents_ml). Ensure you enable the automatic creation of:Notebooks tab. In your user-assigned folder, create a bash file named compute-instance-startup.sh and copy the contents from scripts/azure_files/compute-instance-startup.sh into it. This script applies base configurations to new VMs.Standard_D8_v3 VM sizes (8 cores) which require support for nested virtualization.When developing or testing initialization scripts in src/win-arena-container/vm/setup or the Python server in src/win-arena-container/vm/setup/server, use the --mode dev flag.
In dev mode, a shared folder is mounted between the Docker host and the Windows 11 VM at \host.lan\Data. This allows code changes made to the src/win-arena-container/vm/setup folder on your host machine to be immediately reflected inside the Windows 11 VM, accelerating the development loop.
# Prepare the image in dev mode
cd ./scripts
./run-local.sh --mode dev --prepare-image true
# Run the full setup including the client
./run-local.sh --mode dev --start-client trueTo evaluate LibreOffice Calc files, ensure the following libraries are installed:
openpyxl
pandas
lxml
xmltodictYou can export specific sheets from an XLSX file to CSV using the following command:
libreoffice --convert-to "csv:Text - txt - csv (StarCalc):44,34,UTF8,,,,false,true,true,false,false,1" --out-dir /home/user /home/user/abc.xlsxNote: The last 1 in the conversion options specifies the sheet number (starting from 1) to export. Refer to CSV Filter Options for details.
compare_table for XLSX evaluationEvaluation of .xlsx files relies on the compare_table function. It accepts two filenames and a list of options (rules).
Rule Types:
sheet_data: Compares internal cell values via pandoc.sheet_print: Compares shown cell values via CSV (requires a generated CSV).Sheet Selection (sheet_idx0, sheet_idx1, or sheet_idx):
i: Extracts the $i$-th sheet from the result (0-indexed).RI: Extract from Result xlsx, sheet Index.RN: Extract from Result xlsx, sheet Name.EI: Extract from Expected (golden) xlsx, sheet Index.EN: Extract from Expected (golden) xlsx, sheet Name.Matching Rules:
Rules can use a structure like {"method": "eq", "ref": "abc"}. These are processed by the utils._match_value_to_rule function.
libreoffice --convert-to "csv:Text - txt - csv (StarCalc):44,34,UTF8,,,,false,true,true,false,false,1" --out-dir /home/user /home/user/abc.xlsxAfter preparing the golden image, you can verify that the Python server has booted (allow up to 1 minute for initialization) and is listening for connections by connecting to the running Docker and sending a request to the screenshot endpoint.
# Connect to the running docker
cd scripts
./run-local.sh --connect true
# Test the server endpoint
curl -v -X GET http://20.20.20.21:5000/screenshot
# Expected: HTTP/1.1 200 OKctrl + s.The 'golden image' is a 30GB Windows 11 VM snapshot that includes all necessary programs and a Python server for agent commands. This setup is performed once.
setup.iso.WindowsAgentArena/src/win-arena-container/vm/image.Execute the following command to begin the ~20 minute provisioning process:
cd ./scripts
./run-local.sh --prepare-image trueImportant Notes:
http://localhost:8006.WindowsAgentArena/src/win-arena-container/vm/storage.src/win-arena-container in the image during development, use --skip-build false with run-local.sh (the default is true)./bin/bash: bad interpreter: No such file or directory on WSL2, run dos2unix on the scripts:cd ./scripts
find . -maxdepth 1 -type f -exec dos2unix {}