From ea9531d1d2c1997bb126cb186c77c024a7d2c92b Mon Sep 17 00:00:00 2001 From: Krishav Raj Singh Date: Thu, 21 Aug 2025 03:57:30 +0530 Subject: [PATCH] upgrade stagehand:2.4.3 and switch to gpt-5 --- backend/agent/tools/browser_tool.py | 2 +- backend/sandbox/docker/browserApi.ts | 6 +----- backend/sandbox/docker/package-lock.json | 10 +++++----- backend/sandbox/docker/package.json | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/backend/agent/tools/browser_tool.py b/backend/agent/tools/browser_tool.py index 82dd4bb5..f3eb2b89 100644 --- a/backend/agent/tools/browser_tool.py +++ b/backend/agent/tools/browser_tool.py @@ -150,7 +150,7 @@ class BrowserTool(SandboxToolsBase): return True else: # If the browser api is not healthy, we need to restart the browser api - model_api_key = config.ANTHROPIC_API_KEY + model_api_key = config.OPENAI_API_KEY response = await self.sandbox.process.exec(f"curl -X POST 'http://localhost:8004/api/init' -H 'Content-Type: application/json' -d '{{\"api_key\": \"{model_api_key}\"}}'", timeout=90) if response.exit_code == 0: diff --git a/backend/sandbox/docker/browserApi.ts b/backend/sandbox/docker/browserApi.ts index fc72c066..1825fd5f 100644 --- a/backend/sandbox/docker/browserApi.ts +++ b/backend/sandbox/docker/browserApi.ts @@ -19,12 +19,10 @@ class BrowserAutomation { private stagehand: Stagehand | null; public browserInitialized: boolean; - private currentApiKey: string | null; private page: Page | null; constructor() { this.router = express.Router(); this.browserInitialized = false; - this.currentApiKey = null; this.stagehand = null; this.page = null; @@ -38,7 +36,6 @@ class BrowserAutomation { async init(apiKey: string): Promise<{status: string, message: string}> { try{ if (!this.browserInitialized) { - this.currentApiKey = apiKey; console.log("Initializing browser with api key"); this.stagehand = new Stagehand({ env: "LOCAL", @@ -47,7 +44,7 @@ class BrowserAutomation { logger: (logLine: LogLine) => { console.log(`[${logLine.category}] ${logLine.message}`); }, - modelName: "claude-3-7-sonnet-20250219", + modelName: "openai/gpt-5", modelClientOptions: { apiKey }, @@ -129,7 +126,6 @@ class BrowserAutomation { this.stagehand?.close(); this.stagehand = null; this.page = null; - this.currentApiKey = null; return { status: "shutdown", message: "Browser shutdown" diff --git a/backend/sandbox/docker/package-lock.json b/backend/sandbox/docker/package-lock.json index 73718529..6a5be965 100644 --- a/backend/sandbox/docker/package-lock.json +++ b/backend/sandbox/docker/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@browserbasehq/stagehand": "^2.4.2", + "@browserbasehq/stagehand": "^2.4.3", "express": "^5.1.0", "tsx": "^4.19.2", "typescript": "^5.9.2" @@ -359,9 +359,9 @@ "license": "MIT" }, "node_modules/@browserbasehq/stagehand": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/@browserbasehq/stagehand/-/stagehand-2.4.2.tgz", - "integrity": "sha512-JEneBRa7Xanc5L6Z7iucseWoTUqAqW6z0/IC6VUpgGMCY5k38+voz7pBxI12hWOtWpvyy9wTaVkLY8YiWZrBUw==", + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/@browserbasehq/stagehand/-/stagehand-2.4.3.tgz", + "integrity": "sha512-iloQM/SbDH2ip7RC7yO/fbRoDPtdoaHbOeob3US0OvFBiSb6rMMLP2PQ+euEGhsc7sNMcs9+UJiA1Ts5H+jhiA==", "license": "MIT", "dependencies": { "@anthropic-ai/sdk": "0.39.0", @@ -394,7 +394,7 @@ "peerDependencies": { "deepmerge": "^4.3.1", "dotenv": "^16.4.5", - "zod": "^3.23.8" + "zod": ">=3.25.0 <4.1.0" } }, "node_modules/@esbuild/aix-ppc64": { diff --git a/backend/sandbox/docker/package.json b/backend/sandbox/docker/package.json index 7324b0e9..9ec9361c 100644 --- a/backend/sandbox/docker/package.json +++ b/backend/sandbox/docker/package.json @@ -10,7 +10,7 @@ "author": "", "license": "ISC", "dependencies": { - "@browserbasehq/stagehand": "^2.4.2", + "@browserbasehq/stagehand": "^2.4.3", "express": "^5.1.0", "tsx": "^4.19.2", "typescript": "^5.9.2"