fix(integrations): propagate facade close requests - #2824
Conversation
Signed-off-by: Shrey Pandya <shrey@browserbase.com>
|
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Signed-off-by: Shrey Pandya <shrey@browserbase.com>
Signed-off-by: Shrey Pandya <shrey@browserbase.com>
There was a problem hiding this comment.
All reported issues were addressed across 4 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Signed-off-by: Shrey Pandya <shrey@browserbase.com>
Signed-off-by: Shrey Pandya <shrey@browserbase.com>
Signed-off-by: Shrey Pandya <shrey@browserbase.com>
Summary
closeRequestedsignal throughStagehandFacadeToolsWhy
The Stagehand V4 compatibility runtime already recognizes
await browser.close(), but the facade previously dropped that signal when returning the model value. Code Mode could therefore report a successful close while the Node host still retained its browser resources. Cleanup belongs in the host because the browser-side worker does not own host credentials or session state.This is complementary to #2818:
stagehand.close()now disposes a Stagehand instance while intentionally leaving its browser open; this PR transports a model-authored compatibilitybrowser.close()request to the host that owns and can terminate that browser.Discovery and reproduction
This was found experimentally while running the official Eve integration against live Browserbase sessions, not from a type or mock failure. A browser task returned successfully after model code called
await browser.close(), but the Browserbase API still reported the session asRUNNING, and the next tool call reused the same facade and session.The trace led to the dropped boundary: the worker-side runtime set
closeRequested, whileStagehandFacadeToolsreturned only the model value/error and the host never saw the close request.Minimal live reproduction on the affected implementation:
await browser.close(); return "closed";throughStagehandFacadeTools.run()."closed".RUNNING.The signal-loss bug is deterministic whenever execution reaches compatibility
browser.close(): the flag had no path out of the batch result. Agent-level symptoms can look less consistent when a model omits close or an earlier browser error prevents it from reaching close. In the exact live A/B, the baseline reproduced on 1/1 close attempt; in the broader eight-task official-integration baseline, cleanup succeeded through this path on 0/8 tasks.This is distinct from the intermittent Undici socket-close error seen during earlier Eve-fork teardown testing: that was a false-negative reported by 1/3 focused close calls even though all three remote sessions reached
COMPLETED. #2824 fixes the official facade's deterministic loss ofcloseRequested, where the remote session actually remainedRUNNING.RUNNINGin the exact reproCOMPLETEDThis is the prerequisite for #2821; #2822 remains the optional web-tool follow-up.
Validation
RUNNING; the fixed path created fresh resources and completed both probe sessionsCOMPLETED(one task created a recovery replacement)No changeset is included because the Core integration package is private.