Skip to content

Act with model option fails #1347

@gal-checksum

Description

@gal-checksum

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions