Skip to content

a11y extract #617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 30, 2025
Merged

a11y extract #617

merged 2 commits into from
Mar 30, 2025

Conversation

seanmcguire12
Copy link
Member

why

  • fast

what changed

  • use a11y tree

test plan

  • evals

Copy link

changeset-bot bot commented Mar 30, 2025

🦋 Changeset detected

Latest commit: c702aaa

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 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

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR updates extraction logic in Stagehand by replacing the previous chunk‐based DOM extraction with an accessibility tree‐based approach, streamlining the process and potentially improving performance.

  • Modified extraction flow in /lib/handlers/extractHandler.ts to use getAccessibilityTree for DOM-to-text conversion.
  • Simplified deduplication and formatting now rely on the accessibility tree output instead of recursive chunking.
  • New approach reduces processing complexity but depends on the accessibility tree's completeness for accurate extraction.

💡 (2/5) Greptile learns from your feedback when you react with 👍/👎!

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@seanmcguire12 seanmcguire12 added the extract These changes pertain to the extract function label Mar 30, 2025
@kamath kamath merged commit affa564 into main Mar 30, 2025
16 of 30 checks passed
@github-actions github-actions bot mentioned this pull request Mar 30, 2025
@MrChrisRodriguez
Copy link

@seanmcguire12 , I'm just becoming familiar with this, but does it really make sense to replace the old method with the a11y method (as opposed to introducing it as a third option?)

With the a11y method, we're no longer able to easily extract hyperlink information (like the href of an anchor tag) since that frequently isn't explicitly made available to the accessibility tree. In the old DOM method we'd have a lot more input tokens, but we would have access to that data (which is the point of using the domExtract method instead of textExtract)

Please correct me if I'm way off base or misunderstanding!

@seanmcguire12
Copy link
Member Author

@MrChrisRodriguez Hey Christian, I appreciate the feedback, and you're not off base at all! The thought process here was that we wanted to prioritize speed (got a lot of feedback from people saying extract was too slow). We could have added a third option, but we didn't want to overwhelm people with too many confusing parameters.

We have plans to add support for link extraction very soon, so we can give users the best of both worlds!

If you have any more feedback about what you liked about the old version of extract/what you'd might want in the future, please feel free to join the slack channel!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extract These changes pertain to the extract function
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants