Skip to content

Zod 4.compatability issue with latest version׳s agent api #1029

@tshtark

Description

@tshtark

Summary

  • With Zod 4.0.17 installed, importing Stagehand triggers TypeScript errors coming from Stagehand’s published types that import zod/v3.
  • Pinning to Zod 3.25.76 makes the errors disappear.
  • Stagehand’s peer range allows 4.0.x (>=3.25.0 <4.1.0), so this appears to be an unintended incompatibility.

Environment

  • @browserbasehq/stagehand: 2.4.3
  • zod: 4.0.17 (errors) vs 3.25.76 (works)

Steps To Reproduce:

  1. npx create-browser-app
  2. install zod 4.0.17 (allowed by stagehand׳s peer dependencies decleration)
  3. replace index.ts with the following:
import { Stagehand } from '@browserbasehq/stagehand'

const stagehand = new Stagehand({
        env: 'BROWSERBASE',
        apiKey: '',
        projectId: '',
        modelName: 'gpt-4o',
        modelClientOptions: {
            apiKey: ''
        },
    })

;(async () => {
    try {
        await stagehand.init()
        await stagehand.page.goto('https://google.com')
        const res = await stagehand.agent().execute({
            instruction: 'search for "Browserbase"',
            maxSteps: 5
        })
        console.dir({ res }, { depth: null })
    } catch (e) {
        console.error(e)
    } finally {
        await stagehand.close()
    }
})()
  1. run and inspect logs: BadRequestError: 400 Invalid schema for response_format 'operatorResponseSchema': schema must be a JSON Schema of 'type: "object"', got 'type: "None"'.

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