diff --git a/.changeset/warping-colorful-shellfish.md b/.changeset/warping-colorful-shellfish.md new file mode 100644 index 0000000..9b3292a --- /dev/null +++ b/.changeset/warping-colorful-shellfish.md @@ -0,0 +1,5 @@ +--- +"stagehand": patch +--- + +Patch issue with passing a created session_id to init on api mode diff --git a/stagehand/api.py b/stagehand/api.py index 6639df2..1773de5 100644 --- a/stagehand/api.py +++ b/stagehand/api.py @@ -30,6 +30,7 @@ async def _create_session(self): "modelName": self.model_name, "verbose": 2 if self.verbose == 3 else self.verbose, "domSettleTimeoutMs": self.dom_settle_timeout_ms, + "browserbaseSessionID": self.session_id, "browserbaseSessionCreateParams": ( browserbase_session_create_params if browserbase_session_create_params diff --git a/stagehand/main.py b/stagehand/main.py index f6918c1..ccdb8af 100644 --- a/stagehand/main.py +++ b/stagehand/main.py @@ -399,15 +399,7 @@ async def init(self): if self.env == "BROWSERBASE": # Create session if we don't have one if self.use_api: - if not self.session_id: - await self._create_session() # Uses self._client and api_url - self.logger.debug( - f"Created new Browserbase session via Stagehand server: {self.session_id}" - ) - else: - self.logger.debug( - f"Using existing Browserbase session: {self.session_id}" - ) + await self._create_session() # Uses self._client and api_url # Connect to remote browser try: