Skip to content

[fix]: omit instruction from Python observe() when not provided - #3384

Open
rome-xi wants to merge 1 commit into
browserbase:mainfrom
rome-xi:fix/python-observe-omit-null-instruction
Open

rome-xi wants to merge 1 commit into
browserbase:mainfrom
rome-xi:fix/python-observe-omit-null-instruction

Conversation

@rome-xi

@rome-xi rome-xi commented Nov 4, 2026 •

Copy link
Copy Markdown

why

Python await stagehand.observe() with no instruction failed on the worker with Invalid input: expected string, received null at params.instruction. observe() always built StagehandObserveParams(..., instruction=instruction), and exclude_unset still serializes a field that was explicitly set to None, so the request carried "instruction": null. TypeScript only sends instruction when it is defined.

Fixes #3368

what changed

  • packages/sdk-python/src/stagehand/stagehand.py: build the observe params without instruction and set it only when the caller passed one.
  • packages/sdk-python/tests/test_stagehand.py: test_observe_omits_unset_instruction_from_the_wire checks the serialized params for both observe() and observe("Find the link").
  • Patch changeset for @browserbasehq/stagehand-python.

act() and extract() are unchanged: their instruction is required by both the models and the protocol schema.

test plan

  • New test fails on main ({'page_id': 'active-page', 'instruction': None} != {'page_id': 'active-page'}) and passes with the fix.
  • ruff format --check, ruff check, ty check in packages/sdk-python: pass.
  • pytest in packages/sdk-python: 1091 passed, 9 skipped (live). 3 failures are pre-existing here because packages/extension/dist isn't built locally; 4 HTTP-teardown tests hang in this environment and were deselected; none touch observe.

AI-assisted; I reviewed the change and ran the tests.


Summary by cubic

Fixes Python observe() calls without an instruction, which previously failed on the worker with Invalid input: expected string, received null. The SDK now omits instruction from the request when the caller doesn't provide one, matching the TypeScript SDK, instead of sending null.

  • Adds a regression test covering both observe() (unset) and observe("Find the link") (set) serialization.
  • act() and extract() are unchanged since their instruction is required by the models and protocol schema.

Written for commit 8a0df54. Summary will update on new commits.

View guided diff

@changeset-bot

changeset-bot Bot commented Nov 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8a0df54

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

This PR includes changesets to release 1 package
Name Type
@browserbasehq/stagehand-python 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

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run.
Approving the latest commit mirrors it into an internal PR owned by the approver.
If new commits are pushed later, the internal PR stays open but is marked stale until someone approves the latest external commit and refreshes it.

@github-actions github-actions Bot added external-contributor Tracks PRs mirrored from external contributor forks. external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. labels Nov 4, 2026
@rome-xi

rome-xi commented Nov 9, 2026

Copy link
Copy Markdown
Author

Friendly ping in case this slipped through — CI is green and the change is small (Python observe() no longer sends instruction when it isn't provided, fixing #3368). Happy to adjust anything if you'd prefer a different shape.

This branch has not been deployed

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

Labels

external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. external-contributor Tracks PRs mirrored from external contributor forks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant