[CLI]: snapshot/eval fail with a recoverable "browser not open" state error — agent callers retry instead of recovering
Author: AprilJoyCreated Sep 17, 2026Updated Sep 17, 2026
What's going on?
When no browser has been opened yet, playwright-cli snapshot exits 1 with a human-readable message that callers have to parse in order to recover:
$ playwright-cli snapshot
The browser 'default' is not open, please run open first
playwright-cli open [params]
$ echo $?
1
For an agent/automation caller this is a recoverable state (a prior open is required), not a failure. In a real session with 699 tool calls and 152 failures, this same signal was retried 11 times before the caller worked out that open had to run first — i.e. the interface is not self-describing to a non-human caller.
Related: it is invisible until runtime which commands need an open browser; snapshot, eval and run-code all fail the same way.
Suggestion
Either:
- Auto-open the default browser on first use for
snapshot/eval/run-code(or accept an implicit open), or - Return a stable, machine-readable error (e.g.
error.type = "browser_not_open") in addition to the human text, so callers can branch instead of retry.
Happy to test a fix if that helps.
Version
@playwright/[email protected]
Source: microsoft/playwright