-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
Reopenning #1263 as it was closed wrongly.
See repro below. Act with instructions and custom model fails as well
/**
* Bug: stagehand.act() fails when passing model override parameter
*
* Expected: act() should work with model override, like observe() does
* Actual: act() throws "An unexpected error occurred"
*/
const { Stagehand } = require("@browserbasehq/stagehand");
async function reproduceActBug() {
const stagehand = new Stagehand({
env: "BROWSERBASE",
apiKey: process.env.BROWSERBASE_API_KEY,
projectId: process.env.BROWSERBASE_PROJECT_ID,
verbose: 1,
model: {
modelName: "google/gemini-2.5-pro",
apiKey: process.env.GOOGLE_API_KEY,
},
});
await stagehand.init();
const page = stagehand.context.pages()[0];
await page.goto("https://example.com");
// ✅ This works - observe() with model override
console.log("Testing observe() with model override...");
const observations = await stagehand.observe("Find the first link", {
model: { modelName: "google/gemini-2.5-pro" },
});
console.log("✅ observe() SUCCESS -", observations.length, "elements found");
// ❌ This fails - act() with model override
console.log("\nTesting act() with model override...");
try {
await stagehand.act("Click on the first link", {
model: { modelName: "anthropic/claude-sonnet-4-5" },
});
console.log("✅ act() SUCCESS");
} catch (error) {
console.log("❌ act() FAILED:", error.message);
}
await stagehand.close();
}
reproduceActBug().catch(console.error);
Metadata
Metadata
Assignees
Labels
No labels