Skip to content

Allow session id to be passed through env vars #760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

saksham-chawla
Copy link

@saksham-chawla saksham-chawla commented May 15, 2025

If a user instantiates a browserbase session ( which would support live view url ), this allows them to continue the session with stagehand.

why

This is helpful for developers who want to embed the stagehand session in their product since they can now use the live view url provided by browserbase instantiation.

what changed

Allow session id to be passed through env vars

test plan

Backward compatible change since default will still be undefined.

If a user instantiates a browserbase session ( which would supports live view url ), this allows them to continue the session with stagehand.
This is helpful for developers who want to embed the stagehand session in their product since they can now use the live view url provided by browserbase instantiation.
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Added support for resuming Browserbase sessions via environment variables by modifying browserbaseSessionID configuration in stagehand.config.ts to read from BROWSERBASE_SESSION_ID.

  • Modified stagehand.config.ts to read browserbaseSessionID from process.env.BROWSERBASE_SESSION_ID
  • Enables seamless session resumption for developers embedding Stagehand in their products
  • Maintains backward compatibility as environment variable defaults to undefined if not set
  • Allows reuse of live view URL from existing Browserbase sessions

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -20,7 +20,7 @@ const StagehandConfig: ConstructorParams = {
apiKey: process.env.BROWSERBASE_API_KEY /* API key for authentication */,
projectId: process.env.BROWSERBASE_PROJECT_ID /* Project identifier */,
browserbaseSessionID:
undefined /* Session ID for resuming Browserbase sessions */,
process.env.BROWSERBASE_SESSION_ID /* Session ID for resuming Browserbase sessions */,
browserbaseSessionCreateParams: {
projectId: process.env.BROWSERBASE_PROJECT_ID!,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Non-null assertion operator (!) used here could cause runtime errors if BROWSERBASE_PROJECT_ID is undefined

Suggested change
projectId: process.env.BROWSERBASE_PROJECT_ID!,
projectId: process.env.BROWSERBASE_PROJECT_ID,

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated to my change

Copy link
Author

@saksham-chawla saksham-chawla May 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also the suggestion seems wrong since BROWSERBASE_PROJECT_ID is required env var.

@saksham-chawla
Copy link
Author

@kamath slack community links in readme seem to be broken so i am unable to learn more

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