SuperAPI AI Directory

Webwright - Microsoft's Open-Source Terminal-Native Web Agent Framework

Author: AI小集 · Original source: AI工具集

What is Webwright

Webwright is an open-source terminal-native web agent framework from Microsoft Research. With only about 1,000 lines of code, it enables AI models to write Playwright code in the terminal, execute bash commands, view logs, and iteratively correct themselves to complete complex web tasks. Webwright lets models directly write code in the terminal to control the browser. Based on GPT-5.4 Webwright scored 60.8% on the Odysseys long-horizon browsing benchmark, a 35.1% improvement over the previous best result and an 81.49% improvement over base GPT-5.4; it achieved 86.67% accuracy on 300 real-website tasks in Online-Mind2Web.

Webwright

Webwright's Main Features

  • Terminal Code-Controlled Browser: The AI model writes Playwright scripts in the terminal to directly launch, inspect, and close browser sessions, rather than predicting clicks or inputs step by step.
  • Free Execution of Shell Commands: Supports executing bash commands, combining code with system-level operations to flexibly handle files, logs, and environment configuration.
  • Self-Reflection and Verification Mechanism: After completing a task, the model must run the final script in a fresh folder and use logs and screenshots for self-reflective judgment, preventing "premature declaration of completion."
  • Context Compression Management: Automatically compresses the historical trajectory into a summary every 20 steps, addressing context bloat in long-horizon tasks.
  • Reusable Tool Generation: Completed task scripts can be parameterized into CLI tools and saved to the workspace for later reuse, avoiding repeated exploration.

Webwright's Technical Principles

  • Three-Module Minimalist Architecture: The entire framework consists of only the Runner (about 150 lines, responsible for loop orchestration), Model Endpoint (about 550 lines, encapsulating LLM API calls), and Environment (about 300 lines, executing shell commands and terminal interaction), with no multi-agent orchestration or complex hierarchical planning.
  • Code-as-Action Paradigm: Expresses multi-step web tasks (such as form filling, date selection, and cross-page operations) in code, leveraging loops, functions, and abstraction reuse to be more efficient than traditional single-step action chains.
  • Observe-Act Loop: The Runner sends the task history and terminal observations to the model → the model returns its reasoning and shell commands → the environment executes them and returns terminal output, logs, screenshots, or errors → the loop iterates until completion.
  • Workspace Persistence: All scripts, logs, screenshots, and outputs are saved in the local workspace, ultimately generating a reusable task program.

How to Use Webwright

  • Environment Preparation: Clone the repository and install dependencies, and configure the LLM API key.
  • Start a Task: Run run.py, and enter a natural language task description (e.g., "search for 33-49 inch 240Hz OLED monitors under a $1,000 budget").
  • Observation Loop: The framework automatically enters the Runner-Model-Environment loop, where the model writes scripts, executes commands, and captures output.
  • Self-Verification: After the task is completed, the model reruns the script in the final_runs/ directory and verifies the result via self_reflection .
  • Reuse Output: Extract the generated workspace/ script from .py as a reusable CLI tool.

Webwright's Core Advantages

  • Minimal Implementation: Only about 1,000 lines of harness code, with a clear architecture that is easy to understand and extend.
  • Performance Breakthrough: It greatly surpasses visual baseline models on long-chain Odysseys tasks, with GPT-5.4 improving by 81.49%, and Claude Opus 4.7 also showing significant gains.
  • Terminal Native: It gives AI true terminal freedom; browser sessions can be created and destroyed at will, while code and logs are persistently retained.
  • Reusable Output: It supports generating programs that can be saved, shared, and reused, reducing the cost of similar tasks in the future.

Webwright's Project Address

  • Project Website:https://microsoft.github.io/Webwright/
  • GitHub Repository:https://github.com/microsoft/webwright

Comparison of Webwright with Similar Competitors

Dimension Webwright Browser Use
Developer Microsoft Research Independent open-source project (browser-use.com)
Core Paradigm Terminal code first: AI writes Playwright scripts in the terminal and freely executes bash commands DOM distillation first: strips irrelevant HTML elements before feeding them to the LLM to predict the next action
Architectural Complexity ~1,000 lines of code; a minimalist architecture with three modules: Runner + Model + Environment, with no multi-agent orchestration Medium complexity, an SDK wrapper based on Playwright, including modules such as DOM processing and multi-tab management
Code Reusability Strong: After task completion, it generates a reusable CLI tool and saves it to the workspace for direct use later Medium: Provides an SDK for developers to integrate, but it is mainly for single tasks and requires manual encapsulation of reuse logic
Terminal Native Support Yes: A complete terminal loop, where the model autonomously writes code, executes it, and views logs within the terminal No: In the form of a Python SDK, developers need to write calling code; it is not terminal-native interaction
Visual Dependency Does not rely on screenshots/DOM state; drives the browser purely through code Hybrid mode: supports dual channels of visual model screenshot understanding + textual DOM distillation
Context Management Automatically compresses history into a summary every 20 steps to prevent context bloat Relies on SDK-level conversation history management, with no automatic compression mechanism
Task Verification Mechanism Self-reflection gating: The model must rerun the final script in a completely new folder and mark it complete only after verification through logs and screenshots No built-in self-verification; relies on external judgment of whether the task succeeded
Representative Performance Odysseys 60.8% (35.1% improvement relative to SOTA), Mind2Web 86.7% WebVoyager 89.1%,GAIA 66.6%
Applicable Models GPT-5.4, Claude Opus 4.7, Qwen-3.5-9B, etc. GPT-5.5 Instant, Claude 4.0 Sonnet, DeepSeek, etc.
Open-Source License MIT(GitHub: microsoft/Webwright) MIT(GitHub: browser-use/browser-use)
Main Applicable Scenarios Developers building reusable web automation tools, long-chain task script generation, end-to-end testing Developers quickly building custom AI browser agents, complex multi-tab tasks, integrating existing applications
Deployment method Runs in a local terminal, requires configuring an LLM API key Local Python environment + Playwright, supports Docker deployment
Anti-detection capabilities No built-in anti-detection, relies on Playwright's basic capabilities Built-in anti-detection mechanisms such as stealth plugins, proxy rotation, and CAPTCHA handling
Multi-tab support Freely controlled through code, requiring the model to manage it itself Native support: automatically tracks tab states and supports cross-tab tasks

Webwright application scenarios

  • Automated web data collection: AI writes Playwright scripts in the terminal to batch-scrape tables, fill out forms, and integrate information across pages, ultimately generating reusable data extraction tools.
  • End-to-end web testing: the model autonomously generates and executes test code, captures screenshots and logs, verifies functional correctness through self-reflection, and outputs standardized test reports.
  • Long-chain online tasks: for multi-step processes such as flight price comparison and hotel booking, using loops and function abstraction to complete complex operations in one go, avoiding the inefficiency of traditional step-by-step clicking.
  • Reusable tool development: encapsulate high-frequency tasks as parameterized CLI tools and save them to the workspace for direct invocation and execution later, without the need for repeated exploration.