Skip to content

Handle no-object act inference failures#2016

Draft
monadoid wants to merge 2 commits intomainfrom
stg-1827
Draft

Handle no-object act inference failures#2016
monadoid wants to merge 2 commits intomainfrom
stg-1827

Conversation

@monadoid
Copy link
Copy Markdown
Contributor

@monadoid monadoid commented Apr 20, 2026

Why

  • A customer reported stagehand.act surfacing an HTTP error after Gemini returned a schema-invalid action object with an empty elementId.
  • The AI SDK correctly raises NoObjectGeneratedError, but that previously bypassed ActHandler's existing No action found result path.

What changed

  • Catch AI SDK NoObjectGeneratedError at the ActHandler inference boundary using NoObjectGeneratedError.isInstance(error).
  • Convert only that structured-output failure into the existing success: false result, while rethrowing other LLM/provider errors.
// before
const response = await actInference(...);

// after
try {
  response = await actInference(...);
} catch (error) {
  if (NoObjectGeneratedError.isInstance(error)) return {};
  throw error;
}

Testing

  • Added a regression test for NoObjectGeneratedError returning Failed to perform act: No action found.
  • Added a guard test that ordinary LLM errors still reject.
  • Ran pnpm --filter @browserbasehq/stagehand run test:core -- packages/core/dist/esm/tests/unit/timeout-handlers.test.js and pnpm --filter @browserbasehq/stagehand run typecheck.

Summary by cubic

Prevents HTTP errors when act inference returns no schema-valid action. ActHandler now maps NoObjectGeneratedError to the existing “No action found” result and rethrows other provider errors.

  • Bug Fixes
    • Catch NoObjectGeneratedError at the ActHandler boundary, log it, and return the “No action found” path instead of surfacing an HTTP error.
    • Added tests and a changeset to ship a patch for @browserbasehq/stagehand; non-structured-output errors still reject.

Written for commit 91de32e. Summary will update on new commits. Review in cubic

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 20, 2026

🦋 Changeset detected

Latest commit: 91de32e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-evals Patch
@browserbasehq/stagehand-server-v3 Patch
@browserbasehq/stagehand-server-v4 Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant