Source: github.com/browserbase/stagehand/releases/tag/stagehand-python%404.4.0a0.dev1660
Stagehand's Python prerelease 4.4.0a0.dev1660 adds a watchdog to its browser extension that detects when an SDK client is lost without calling disconnect() or close(), such as after a crash, a SIGKILL or a dropped connection. Before this change, a local Chrome instance launched by Stagehand kept running with the extension still initialized, so reconnecting could fail with an already-initialized error.
On connect, the SDK creates a hidden target over its own CDP connection, and Chrome destroys that target when the connection ends. The extension watches for the destruction event without heartbeats or timers. On loss, a local browser launched without keepAlive is closed, while other browsers keep running, but the extension releases the instance and closes its own connection so a new client can attach.
disconnect() detaches first, which disarms the watchdog, before closing. If the detach is not acknowledged, the socket and handle stay open so the close is not mistaken for a loss. The SDK also checks that the hidden target is really hidden, and with an older extension or a Chrome build without hidden targets it warns once and continues without the watchdog. The change is built on an earlier pull request and has a matching TypeScript version.
Why it matters if you build agents
Agent processes that crash no longer leave a locally launched browser running with a stuck instance, so a restart can reconnect without manual cleanup. Browsers started with keepAlive remain available for reattachment after a client is lost.
Only one client can be connected to a browser at a time, and a second client gets an error until the first one disconnects or is detected as lost. Test the reconnect path if your agents restart after crashes.
Get stories like this every weekday
One short email with the day's agent tooling news.