stagehand icon indicating copy to clipboard operation
stagehand copied to clipboard

Error: Invalid schema for function 'json': schema must be a JSON Schema of 'type: "object"', got 'type: "None"'.

Open j opened this issue 1 year ago • 3 comments

Before submitting an issue, please:

  • [x] Check the documentation for relevant information
  • [x] Search existing issues to avoid duplicates

Environment Information

Please provide the following information to help us reproduce and resolve your issue:

Stagehand:

  • Typescript
  • Stagehand version: 2.5.2

AI Provider:

  • Provider: OpenAI / Gemini
  • Model: Default / google/gemini-2.5-computer-use-preview-10-2025 google/gemini-2.5-computer-use-preview-10-2025

Issue Description

I get the error: "Invalid schema for function 'json': schema must be a JSON Schema of 'type: "object"', got 'type: "None"'."

Steps to Reproduce

  1. New Repo
  2. Use Code
const stagehand = new Stagehand({
		env: 'LOCAL',
		// modelName: 'google/gemini-2.5-computer-use-preview-10-2025',
		// modelClientOptions: {
		// 	apiKey: env.GEMINI_API_KEY,
		// },
	});

	await stagehand.init();

	const page = stagehand.page;

	await page.goto('https://github.com/browserbase');

	await page.act('click on the stagehand repo link');

Minimal Reproduction Code

// Your minimal reproduction code here
import { Stagehand } from '@browserbase/stagehand';

const stagehand = new Stagehand({
	env: 'LOCAL'
});

await stagehand.init();

const page = stagehand.page;

await page.goto('https://github.com/browserbase');

await page.act('click on the stagehand repo link');

Error Messages / Log trace

StagehandDefaultError: 
Hey! We're sorry you ran into an error. 
Stagehand version: 2.5.2 
If you need help, please open a Github issue or reach out to us on Slack: https://stagehand.dev/slack

Full error:
Invalid schema for function 'json': schema must be a JSON Schema of 'type: "object"', got 'type: "None"'.
    at _StagehandPage.<anonymous> (/Users/j/Code/@j/DRS/node_modules/.bun/@[email protected]+3a7d84e035fa9623/node_modules/@browserbasehq/stagehand/dist/index.js:4402:15)
    at Generator.throw (<anonymous>)
    at rejected (/Users/j/Code/@j/DRS/node_modules/.bun/@[email protected]+3a7d84e035fa9623/node_modules/@browserbasehq/stagehand/dist/index.js:73:29)

j avatar Oct 22 '25 23:10 j

This is due to me using v4, even though I was using zod/v3 as an import. So I don't think you can use v4 in general.

j avatar Oct 23 '25 03:10 j

@j Did you override this in package.json or downgrade zod in your project.

tibrownace avatar Oct 23 '25 21:10 tibrownace

going to close this one as support for zod 4 was added here and is currently available on the latest alpha release of stagehand

seanmcguire12 avatar Nov 21 '25 05:11 seanmcguire12