Skip to content

Prepare and release shared Stagehand sessions - #4320

Draft
Ji-One1 wants to merge 1 commit into
jb/storefront-e2e-v2-12-model-instructionsfrom
jb/storefront-e2e-v2-13-stagehand-session
Draft

Ji-One1 wants to merge 1 commit into
jb/storefront-e2e-v2-12-model-instructionsfrom
jb/storefront-e2e-v2-13-stagehand-session

Conversation

@Ji-One1

@Ji-One1 Ji-One1 commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Stagehand can miss cross-origin frames that already exist when it attaches. The browser and later buyer need one shared observer attached before navigation, with a release that confirms the SDK no longer controls the browser.

What this changes

  • Add prepareStagehandSession to attach Stagehand over the owned browser's CDP connection, without buyer model configuration or inference.
  • Preserve the original browser-session identity for recorder lookups.
  • Confirm detach through observer.context.close() with a deadline. Run SDK housekeeping separately, and always close the owned browser during session close.
  • Bound initialization and cleanup, and close the browser after preparation failure.
  • Refuse Stagehand flow-log environment settings before loading the SDK and suppress its own logger.
  • Add a shared settlement helper and extend readiness fixtures to use the prepared observer.

Developer impact

Internal tooling only; no published Hydrogen changes or changeset. No buyer is created here. Startup needs no buyer key, although the SDK constructor can inspect native-provider environment settings for its unused default client.

Risk

Early attachment does not remove Stagehand's frame limitations, including A→B→A nesting. SDK error messages remain unchanged within the wrapper; excluding request/response properties is not secret redaction.

Stack: 12/15. Previous: #4319. Next: #4321.

@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-13-stagehand-session branch from 893a2c2 to ced2040 Compare November 5, 2026 16:23
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-12-model-instructions branch from 2f7f777 to e272579 Compare November 5, 2026 18:41
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-13-stagehand-session branch from ced2040 to 69113cc Compare November 5, 2026 18:42
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-12-model-instructions branch from e272579 to ae3da56 Compare November 6, 2026 00:01
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-13-stagehand-session branch from 69113cc to 4be3104 Compare November 6, 2026 00:01
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-12-model-instructions branch from ae3da56 to 625b6b8 Compare November 6, 2026 01:36
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-13-stagehand-session branch from 4be3104 to 2a9e932 Compare November 6, 2026 01:36
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-12-model-instructions branch from 625b6b8 to afaa6fb Compare November 6, 2026 01:45
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-13-stagehand-session branch 2 times, most recently from 455aa6d to 24ff7f6 Compare November 6, 2026 14:27
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-12-model-instructions branch from afaa6fb to 36121b3 Compare November 6, 2026 14:27
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-13-stagehand-session branch from 24ff7f6 to ce515e4 Compare November 6, 2026 15:08
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-12-model-instructions branch from 36121b3 to 4cc83cb Compare November 6, 2026 15:08
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-13-stagehand-session branch from ce515e4 to 009b1ad Compare November 6, 2026 16:20
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-12-model-instructions branch from b67a4d2 to 27d2151 Compare November 6, 2026 19:01
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-13-stagehand-session branch 2 times, most recently from 043eda2 to 856fb5d Compare November 6, 2026 20:01
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-12-model-instructions branch 2 times, most recently from 2b8b89d to 863a3fb Compare November 6, 2026 20:32
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-13-stagehand-session branch 3 times, most recently from fd89361 to 25dfdbf Compare November 9, 2026 00:01
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-12-model-instructions branch from 065af23 to 069f70d Compare November 9, 2026 00:01
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-13-stagehand-session branch from 25dfdbf to b8eed31 Compare November 9, 2026 00:37
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-12-model-instructions branch 2 times, most recently from b49fa33 to e92da17 Compare November 9, 2026 04:23
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-13-stagehand-session branch from b8eed31 to 75084f9 Compare November 9, 2026 04:23
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-12-model-instructions branch from e92da17 to 6e7de57 Compare November 9, 2026 06:55
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-13-stagehand-session branch from 75084f9 to 374ba19 Compare November 9, 2026 06:55

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant