Webwright - Microsoft's open-source, terminal-native web intelligence framework
Webwright is an open-source, terminal-native web-based intelligent agent framework from Microsoft Research. With only about 1000 lines of code, it allows AI models to write Playwright code, execute bash commands, view logs, and iteratively correct errors within the terminal...
What is Webwright?
Webwright is an open-source, terminal-native web-based intelligent agent framework from Microsoft Research. With only about 1000 lines of code, it allows AI models to write Playwright code, execute bash commands, view logs, and iteratively correct errors within the terminal to complete complex web page tasks. Webwright enables models to directly control the browser by writing code in the terminal. Based on GPT-5.4, Webwright achieved a score of 60.8% on the Odysseys long-link browsing benchmark, a 35.1% improvement over the previous best result and an 81.49% improvement over the base GPT-5.4; it also achieved an accuracy of 86.67% on the Online-Mind2Web task involving 300 real-world websites.
Webwright's main functions
-
Terminal code to control the browserThe AI model writes Playwright scripts on the terminal to directly start, check, and close browser sessions, rather than predicting clicks or inputs one by one.
-
Shell commands can be executed freely.It supports executing bash commands, combining code and system-level operations to flexibly handle files, logs, and environment configurations.
-
Self-reflection and verification mechanismAfter the task is completed, the model must run the final script in a new folder, and reflect on its performance by combining logs and screenshots to prevent "prematurely declaring completion".
-
Context compression managementIt automatically compresses the historical trajectory into a summary every 20 steps, solving the context bloat problem of long-link tasks.
-
Reusable tool generationCompleted task scripts can be parameterized into CLI tools and saved to the workspace for later reuse, avoiding redundant exploration.
Webwright's technical principles
-
Three-module minimalist architectureThe entire framework consists of only a Runner (about 150 lines, responsible for loop orchestration), a Model Endpoint (about 550 lines, encapsulating LLM API calls), and an Environment (about 300 lines, executing shell commands and interacting with the terminal), without multi-agent orchestration or complex hierarchical planning.
-
Code as Action ParadigmExpressing multi-step web page tasks (such as form filling, date selection, and cross-page operations) with code, leveraging loops, functions, and abstraction for reuse, is more efficient than traditional single-step action chains.
-
Observation-Action CycleRunner sends task history and terminal observations to the model → Model returns thought process and shell commands → Environment executes and returns terminal output, logs, screenshots, or errors → Iterates until completion.
-
Workspace persistenceAll scripts, logs, screenshots, and outputs are saved in the local workspace, ultimately generating a reusable task program.
How to use Webwright
-
Environmental preparationClone the repository and install dependencies, then configure the LLM API key.
-
Start task:run
run.pyInput a natural language task description (e.g., "Search for 33-49 inch 240Hz OLED displays, budget under $1000"). -
Observe the cycleThe framework automatically enters the Runner-Model-Environment loop, where the model writes scripts, executes commands, and captures output.
-
Self-verificationAfter the task is completed, the model is in
final_runs/Rerun the script in the directory, viaself_reflectionVerification results. -
Multiplexed output:from
workspace/Extract the generated.pyThe script serves as a reusable CLI tool.
Webwright's core advantages
-
Minimalist implementationIt has only about 1,000 lines of harness code, with a clear architecture that is easy to understand and extend.
-
Performance BreakthroughIt significantly outperforms the visual baseline model on the Odysseys long-link task, with an 81.49% improvement on GPT-5.4 and a significant gain on Claude Opus 4.7.
-
terminal nativeIt gives AI true terminal freedom, allowing browser sessions to be created and destroyed at will, and code and logs to be persistently retained.
-
Output can be reusedIt supports the generation of programs that can be saved, shared, and reused, reducing the cost of subsequent similar tasks.
Webwright's project address
- Project official websitehttps://microsoft.github.io/Webwright/
- GitHub repositoryhttps://github.com/microsoft/webwright
Webwright's Competitive Comparison
| Dimension | Webwright | Browser Use |
|---|---|---|
| Developer | Microsoft Research | Independent open-source project (browser-use.com) |
| Core Paradigm | Terminal code priority: AI writes Playwright scripts in the terminal and can freely execute bash commands. | DOM distillation priority: After stripping away irrelevant HTML elements, feed them to the LLM to predict the next action. |
| Architectural complexity | ~1000 lines of code, a minimalist three-module architecture of Runner + Model + Environment, without multi-agent orchestration. | Medium complexity, based on Playwright's SDK, including modules for DOM manipulation and multi-tab management. |
| Code reusability | powerfulAfter the task is completed, a reusable CLI tool is generated and saved to the workspace for direct use later. | middleAn SDK is provided for developers to integrate, but it is primarily for single-task use, requiring manual encapsulation of reusable logic. |
| Native support for terminals | yesA complete terminal closed loop allows the model to autonomously write, execute, and view logs within the terminal. | noIt is in the form of a Python SDK, requiring developers to write the calling code; it is not a native terminal interaction. |
| Visual dependence | Browser driven purely by code, without relying on screenshots or DOM state. | Blended Mode: Supports dual-channel processing of visual model screenshots and text DOM distillation. |
| Context Management | The history is automatically compressed into a summary every 20 steps to prevent context bloat. | It relies on SDK-level conversation history management and lacks an automatic compression mechanism. |
| Task verification mechanism | Self-reflection gatingThe model must be rerun in a completely new folder with the final script, and only after verification through logs and screenshots will it be marked as complete. | It lacks built-in self-verification and relies on external checks to determine whether the task was successful. |
| Representative performance | Odysseys 60.8% (35.1% improvement over state-of-the-art), Mind2Web 86.7% | WebVoyager 89.1%, GAIA 66.6% |
| Applicable Model | 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 can build reusable web page automation tools, generate scripts for long-chain tasks, and perform end-to-end testing. | Developers can quickly build custom AI browser proxies, handle complex multi-tab tasks, and integrate with existing applications. |
| Deployment method | Running on a local terminal requires configuring an LLM API key. | Local Python environment + Playwright, supports Docker deployment |
| Anti-detection capability | No built-in anti-detection features; relies on Playwright's basic capabilities. | Built-in stealth plugin, proxy rotation, CAPTCHA handling and other anti-detection mechanisms |
| Multi-tab support | Free control through code; requires self-management of the model. | Native supportAutomatically tracks tab status and supports cross-tab tasks. |
Webwright's application scenarios
-
Automated web page data collectionAI writes Playwright scripts on the terminal to batch capture tables, fill out forms, and integrate information across pages, ultimately generating a reusable data extraction tool.
-
End-to-end web page testingThe model autonomously generates and executes test code, captures screenshots and logs, verifies the correctness of the function through self-reflection, and outputs a standardized test report.
-
Long-link online tasksFor multi-step processes such as flight price comparison and hotel booking, loops and functions are used to abstract complex operations in one go, avoiding the inefficiency of traditional single-step clicks.
-
Reusable tool developmentHigh-frequency tasks are encapsulated into parameterized CLI tools and saved to the workspace for direct execution later, eliminating the need for repeated exploration.