Skip to content

Fix malformed snapshot Unicode#2345

Merged
monadoid merged 3 commits into
mainfrom
STG-2500
Jul 9, 2026
Merged

Fix malformed snapshot Unicode#2345
monadoid merged 3 commits into
mainfrom
STG-2500

Conversation

@monadoid

@monadoid monadoid commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

why

BYOK/direct provider calls reject when page snapshot text we passed in contained malformed UTF-16. I

what changed

Normalize captured accessibility snapshot strings with toWellFormed() at the snapshot boundary and add unit/integration coverage for lone-surrogate page text.

test plan

Red/greened the new unit and local SDK observe regressions, and the focused unicode-well-formed integration test.


Summary by cubic

Fixes malformed Unicode in accessibility snapshots by normalizing text with String.prototype.toWellFormed() at capture and during frame merge, so both local SDK and provider prompts always get well-formed UTF-16. Adds tests that confirm lone surrogates are repaired to U+FFFD in prompts.

  • Bug Fixes

    • Normalize outline strings during capture and frame merge; per-frame and combined trees are well-formed before prompting.
    • Add integration test asserting U+FFFD appears in the model prompt and a unit test verifying combined tree repair.
  • Dependencies

    • Add changeset to publish a patch for @browserbasehq/stagehand.

Written for commit 143ac0e. Summary will update on new commits.

Review in cubic

@changeset-bot

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 143ac0e

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

This PR includes changesets to release 3 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-evals Patch
@browserbasehq/stagehand-server-v3 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

@monadoid monadoid marked this pull request as ready for review July 9, 2026 20:58

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed against the latest diff

Confidence score: 5/5

  • Safe to merge after the addressed issues were fixed.

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/core/lib/v3/understudy/a11y/snapshot/capture.ts
@monadoid monadoid merged commit 21826c7 into main Jul 9, 2026
250 checks passed
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.

2 participants