libretto-playwright-debug lets an existing Playwright script keep its current
browser provider, retries, logging, and fallback logic while adding one agent
call in the failure path.
agent.model value uses Libretto’s provider/model-id convention. For
example, openai/gpt-5.4 resolves to provider openai and model id gpt-5.4.
The first version supports openai/... and anthropic/....
What It Captures
debugPlaywrightFailure() captures the error message, stack trace, page URL,
page title, screenshot, and DOM snapshot from the failed page. It uses the stack
frames — plus any paths you pass in includeFiles — to read the relevant source
files from GitHub at baseBranch.
includeFiles is optional. When the error stack references files inside the
repository, the debugger discovers them automatically; pass includeFiles when
the stack does not cover the file that needs the fix (for example bundled or
minified stacks, or a cross-file change).
How It Investigates
The debugger does not guess a fix from a static snapshot. It runs an agent loop built on thelibretto-browser-tools
SDK: the model is given the failure context and source files, then drives a real
browser to confirm the root cause before proposing a change. It stays attached
to the supplied failed Page, preserving its authentication, storage, routes,
open tabs, and in-memory state. It can:
browser_statusthe existing pages in the failed browser context,browser_snapshotthe live accessibility tree (and a screenshot), andbrowser_execPlaywright code against the page — for example counting a selector’s matches to check whether it actually resolves.
status: "no_changes".
The debugger does not launch or close a second browser. Debugger infrastructure
failures resolve with status: "debugger_failed" so the caller’s existing
fallback and original error handling can continue.
Model Keys
Set the provider API key in the environment where the Playwright script runs:agent.apiKey directly when the key is provided by your
secrets manager.
GitHub Authentication
The debugger uses Libretto’s public GitHub App through Libretto Cloud. First use the Libretto setup flow to connect the repository. The flow verifies the GitHub user can access the installed Libretto GitHub App and stores the tenant/repository link. Then provide:owner/repo and only the
permissions needed to read/write contents and open pull requests.
For local development, you can pass github.token or set
LIBRETTO_GITHUB_TOKEN / GITHUB_TOKEN. The token needs permission to read
contents, write contents, and open pull requests on the target repository.
The GitHub App should request these repository permissions:
- Contents: read and write
- Pull requests: read and write
- Metadata: read