Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/warping-colorful-shellfish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stagehand": patch
---

Patch issue with passing a created session_id to init on api mode
1 change: 1 addition & 0 deletions stagehand/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Collaborator

Choose a reason for hiding this comment

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

if a session exists, it resumes it, correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that's right, this fixes

"browserbaseSessionCreateParams": (
browserbase_session_create_params
if browserbase_session_create_params
Expand Down
10 changes: 1 addition & 9 deletions stagehand/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down