Skip to content

Python observe() without an instruction sends null and fails worker validation #3368

Open

Description

@vishalanton16

Summary

await stagehand.observe() (no instruction) is a supported API. Python sends "instruction": null. The worker schema accepts an omitted string, not null.

Repro

import asyncio, os
from stagehand import Stagehand, browserbase

async def main():
    browser = await browserbase.launch(api_key=os.environ["BROWSERBASE_API_KEY"])
    try:
        stagehand = await Stagehand.create(
            browser=browser,
            model="google/gemini-3.8-flash",
        )
        page = await browser.context.active_page()
        await page.goto("https://example.com", wait_until="load")
        await stagehand.observe()
    finally:
        await browser.close()

asyncio.run(main())

Expected

Instruction is omitted on the wire (same as TypeScript). Default observe runs.

Actual

Live Browserbase session on https://example.com/: failed in ~1.6s with

Invalid input: expected string, received null
path: ["params", "instruction"]

Notes

Python always constructs StagehandObserveParams(..., instruction=instruction), so default None is serialized. TypeScript only spreads instruction when it is defined.

Possible direction: omit the field when the caller did not pass an instruction.

Activity

  1. rome-xi commented on Nov 4, 2026

    @rome-xi

    I can reproduce this on main (1e50db6): Stagehand.observe() in packages/sdk-python always builds StagehandObserveParams(..., instruction=instruction), so None goes out as null. Working on a fix that omits the field when no instruction is passed, with a test on the serialized request.

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

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