--- title: web-agent sdk: docker app_port: 7860 --- # web-agent — live application The working product surface for **web-agent**, the autonomous agent that operates web interfaces end to end. Pick a task and watch the agent actually run it: a real headless Chromium session, driven live by the agent's own observe → act → verify → recover loop, with the step log and screenshots streamed to the page as they happen. Nothing is simulated or replayed — every run is a fresh execution. ## Run Two modes, one command each: **Development** — uses the web-agent system's own virtual environment (which provides Playwright and its Chromium), and the system checkout at `~/workspace/browser-agent-lab`: ```bash ~/workspace/browser-agent-lab/.venv/bin/python app.py ``` **Deployment / standalone** — any Python with Playwright installed (`pip install -r requirements.txt`); the agent system is vendored byte-identical under `system/` in this directory, so nothing outside this folder is needed: ```bash python3 app.py ``` Then open http://localhost:8000 — set `PORT` to use a different port. The runner resolves the system directory in this order: `WEB_AGENT_LAB_DIR` env var → the vendored `system/` copy → the `~/workspace/browser-agent-lab` checkout. ## Deploy (Hugging Face Spaces, Docker SDK) This directory is the Space repo. The `Dockerfile` builds on the official Playwright Python image (`mcr.microsoft.com/playwright/python:v1.64.1-jammy` — the exact Playwright version the system was verified against, with its Chromium and system libraries preinstalled), copies this directory in, and runs `app.py` on port 7860 (declared as `app_port` in the metadata above). The vendored `system/` copy is what makes the container self-contained: it is a byte-for-byte copy of the system's `src/`, `fixtures/` and `results/` from `~/workspace/browser-agent-lab`, re-vendored whenever the system changes. `DEPLOY_MANIFEST.txt` lists every file in the Space repo with its size. ## What you get - **Live run** — all 36 tasks from the system's suite (27 controls, 9 adversarial), grouped by category, including a Business workflows group (CRM record update, vendor application, lead entry) and a Portal navigation group (three tasks that follow links inside a multi-page CRM portal). Choose a task, choose whether recovery is on or off, press Run. The stream shows each observation (fresh DOM snapshot), each verified step, each failure, each recovery (re-grounding, overlay dismissal), a screenshot after every step, and the final verdict with attempts and recoveries used. Each task's recorded full-suite result is shown beside the picker, and the raw task page itself can be opened via "View task page". - **Evaluation** — the recorded full-suite results: recovery ON passed 36/36, recovery OFF passed 27/36; on the adversarial tasks, 9/9 with recovery on versus 0/9 with it off. The view reads the system's own run files (`results/run_on.json`, `results/run_off.json`) at request time — no number is hand-entered, and the recorded suite runs are presented separately from the single live runs. ## How live runs execute - `app.py` is a pure Python-standard-library HTTP server (`http.server.ThreadingHTTPServer`) — the environment has no web framework and none is needed. It serves the UI, the task pages, a JSON API, and runs as Server-Sent Events. - `runner.py` is the thinnest possible wrapper around the system's own code. The agent that runs is the system's `src.agent.Agent`, imported unchanged — from the vendored `system/` copy in deployment, or from `~/workspace/browser-agent-lab` in development; tasks come from the system's `src.tasks.TASKS`; the fixture page is loaded from its real location on disk, in a fresh browser context, exactly as the system's own evaluation runner does it. - The wrapper adds only presentation hooks: a `StreamLog` with the same `write()` interface as the system's file-based `RunLog` (the Agent accepts any object with that method), which forwards events to the stream; and a subclass that captures a screenshot after each step and after an overlay dismissal. Grounding, actions, verification and recovery logic are not altered. ## Tests ```bash ~/workspace/browser-agent-lab/.venv/bin/python tests/test_app.py ``` Boots the real server on a scratch port and verifies over HTTP: the Evaluation payload matches the recorded run files (recomputed independently in the test), the catalogue lists all 36 tasks, and two live runs are executed end to end — `adversarial_rename_under_overlay` passes with exactly 2 recoveries and 5 attempts (the recorded behaviour), and the control task `login` passes with 0 recoveries. ## Limitations - Runs execute on the machine hosting the app, against the system's local task pages; each run takes a few seconds (browser launch plus the task's steps). - At most 2 runs execute concurrently; further run requests are refused with a clear message rather than queued. - A run is bounded by the agent's own per-action and verification timeouts; the stream itself gives up after 180 seconds.