Skip to content

Commit 2b2d1ea

Browse files
committed
Properly serialize os on browserbase session create params
1 parent 77e7113 commit 2b2d1ea

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"stagehand": patch
3+
---
4+
5+
Properly serialize os on browserbase session create params

stagehand/config.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ class StagehandConfig(BaseModel):
7171
alias="domSettleTimeoutMs",
7272
description="Timeout for DOM to settle (in ms)",
7373
)
74-
browserbase_session_create_params: Optional[
75-
Union[BrowserbaseSessionCreateParams, dict[str, Any]]
76-
] = Field(
74+
browserbase_session_create_params: Optional[dict[str, Any]] = Field(
7775
None,
7876
alias="browserbaseSessionCreateParams",
7977
description="Browserbase session create params",
@@ -124,11 +122,25 @@ class StagehandConfig(BaseModel):
124122
@classmethod
125123
def validate_browserbase_params(cls, v, info):
126124
"""Validate and convert browserbase session create params."""
127-
if isinstance(v, dict) and "project_id" not in v:
128-
values = info.data
129-
project_id = values.get("project_id") or values.get("projectId")
130-
if project_id:
131-
v = {**v, "project_id": project_id}
125+
if isinstance(v, dict):
126+
# Make a copy to avoid mutating the original
127+
v = dict(v)
128+
129+
# Add project_id if not present
130+
if "project_id" not in v:
131+
values = info.data
132+
project_id = values.get("project_id") or values.get("projectId")
133+
if project_id:
134+
v["project_id"] = project_id
135+
136+
# Handle browser_settings
137+
if "browser_settings" in v:
138+
# Make a copy of browser_settings to avoid mutating
139+
v["browser_settings"] = dict(v["browser_settings"])
140+
141+
# Normalize 'os' key to lowercase
142+
if "os" in v["browser_settings"]:
143+
v["browser_settings"]["os"] = v["browser_settings"]["os"].lower()
132144
return v
133145

134146
def with_overrides(self, **overrides) -> "StagehandConfig":

0 commit comments

Comments
 (0)