Skip to content

Conversation

@seanmcguire12
Copy link
Member

why

  • needed for CU/vision

what changed

  • handle scrolling inside performPlaywrightMethod

example usage

await stagehand.page.goto("https://aigrant.com/");
await stagehand.page.act({
  action: "scroll 50% down the page.",
  slowDomBasedAct: false,
});

@changeset-bot
Copy link

changeset-bot bot commented Mar 6, 2025

🦋 Changeset detected

Latest commit: c63bb73

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

@seanmcguire12 seanmcguire12 marked this pull request as ready for review March 6, 2025 20:05
@seanmcguire12 seanmcguire12 added the act These changes pertain to the act function label Mar 6, 2025
@sameelarif
Copy link
Member

tested and confirmed scrolling with act works on my end! did run into some issues though:

  1. when slowDomBasedAct is true, the scrolling works but is then ignored by verifyActCompletion, which scrolls down and back to the top of the page.
  2. when slowDomBasedAct is false, the underlying observe does not always return a valid _performPlaywrightMethod method. For example, it returned .evaluate instead of scroll/scrollTo/mouse.wheel. This may be an underlying issue with our schema for the observe LLM call response, but it's causing scrolling to fail here.

@seanmcguire12
Copy link
Member Author

seanmcguire12 commented Mar 12, 2025

tested and confirmed scrolling with act works on my end! did run into some issues though:
1. when slowDomBasedAct is true, the scrolling works but is then ignored by verifyActCompletion, which scrolls down and back to the top of the page.
2. when slowDomBasedAct is false, the underlying observe does not always return a valid _performPlaywrightMethod method. For example, it returned .evaluate instead of scroll/scrollTo/mouse.wheel. This may be an underlying issue with our schema for the observe LLM call response, but it's causing scrolling to fail here.

yeah its not supposed to work if slowDomBasedAct is true. should prob add docs on this. nice find on the _performPlaywrightMethod issue. if only #569 was in, then i could easily debug 👀 @kamath


throw new PlaywrightCommandException(e.message);
}
} else if (method === "scrollTo" || method === "scroll") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see the llm calling scroll by pixel. If anything by % or maybe like we had in chunking something like 'scroll down'. It would be interesting to add some sort of feedback loop like 'successfully scrolled all the way to the bottom' so the agent doesn't get stuck. It seems performPlaywrightMethod doesn't return anything?

@seanmcguire12 seanmcguire12 merged commit 98166d7 into main Mar 13, 2025
12 checks passed
@github-actions github-actions bot mentioned this pull request Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act These changes pertain to the act function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants