Skip to content

Conversation

@tkattkat
Copy link
Collaborator

why

currently we pass stagehand page to agent, this results in our page management having issues when facing new tabs

what changed

the stagehand object is now passed instead of stagehandPage

test plan

tested locally

@changeset-bot
Copy link

changeset-bot bot commented Sep 17, 2025

🦋 Changeset detected

Latest commit: c2bd4a3

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

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.

Greptile Summary

This PR refactors the agent tool architecture to pass the full Stagehand instance instead of the StagehandPage instance to agent tools. This change improves page management capabilities when handling new tabs and provides tools with access to the complete Stagehand API surface.

Key Changes:

  • Updated all agent tool creation functions to accept Stagehand instead of StagehandPage
  • Modified StagehandAgentHandler constructor and createTools() method to use the new parameter type
  • Updated tool implementations to access page functionality via stagehand.page instead of direct stagehandPage calls
  • Removed deprecated screenshot evaluation test file
  • Cleaned up screenshot-related type definitions that are no longer needed

Impact:

  • Enables better handling of multi-tab scenarios by giving tools access to the full browser context
  • Maintains backward compatibility as all existing functionality is preserved through stagehand.page
  • Improves the overall architecture by providing tools with more complete browser automation capabilities

Confidence score: 4/5

  • This PR is safe to merge with minimal risk
  • The refactoring is straightforward and maintains backward compatibility by accessing page functionality through stagehand.page. All tools continue to work the same way, just with access to more capabilities. The changes are consistent across all affected files and follow a clear pattern.
  • No files require special attention

11 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@tkattkat tkattkat merged commit 8c0fd01 into main Sep 22, 2025
15 checks passed
miguelg719 pushed a commit that referenced this pull request Oct 7, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @browserbasehq/stagehand@2.5.1

### Patch Changes

- [#1082](#1082)
[`8c0fd01`](8c0fd01)
Thanks [@tkattkat](https://github.com/tkattkat)! - Pass stagehand object
to agent instead of stagehand page

- [#1104](#1104)
[`a1ad06c`](a1ad06c)
Thanks [@miguelg719](https://github.com/miguelg719)! - Fix logging for
stagehand agent

- [#1066](#1066)
[`9daa584`](9daa584)
Thanks [@tkattkat](https://github.com/tkattkat)! - Add playwright
arguments to agent execute response

- [#1077](#1077)
[`7f38b3a`](7f38b3a)
Thanks [@tkattkat](https://github.com/tkattkat)! - adds support for
stagehand agent in the api

- [#1032](#1032)
[`bf2d0e7`](bf2d0e7)
Thanks [@miguelg719](https://github.com/miguelg719)! - Fix for zod peer
dependency support

- [#1014](#1014)
[`6966201`](6966201)
Thanks [@tkattkat](https://github.com/tkattkat)! - Replace operator
handler with base of new agent

- [#1089](#1089)
[`536f366`](536f366)
Thanks [@miguelg719](https://github.com/miguelg719)! - Fixed info logs
on api session create

- [#1103](#1103)
[`889cb6c`](889cb6c)
Thanks [@tkattkat](https://github.com/tkattkat)! - patch custom tool
support in anthropic cua client

- [#1056](#1056)
[`6a002b2`](6a002b2)
Thanks [@chrisreadsf](https://github.com/chrisreadsf)! - remove need for
duplicate project id if already passed to Stagehand

- [#1090](#1090)
[`8ff5c5a`](8ff5c5a)
Thanks [@miguelg719](https://github.com/miguelg719)! - Improve failed
act error logs

- [#1014](#1014)
[`6966201`](6966201)
Thanks [@tkattkat](https://github.com/tkattkat)! - replace operator
agent with scaffold for new stagehand agent

- [#1107](#1107)
[`3ccf335`](3ccf335)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix: url
extraction not working inside an array

- [#1102](#1102)
[`a99aa48`](a99aa48)
Thanks [@miguelg719](https://github.com/miguelg719)! - Add current page
and date context to agent

- [#1110](#1110)
[`dda52f1`](dda52f1)
Thanks [@miguelg719](https://github.com/miguelg719)! - Add support for
new Gemini Computer Use models

## @browserbasehq/stagehand-evals@1.1.0

### Minor Changes

- [#1057](#1057)
[`b7be89e`](b7be89e)
Thanks [@filip-michalsky](https://github.com/filip-michalsky)! - added
web voyager ground truth (optional), added web bench, and subset of
OSWorld evals which run on a browser

### Patch Changes

- [#1072](#1072)
[`dc2d420`](dc2d420)
Thanks [@filip-michalsky](https://github.com/filip-michalsky)! - improve
evals screenshot service - add img hashing diff to add screenshots and
change to screenshot intercepts from the agent

- Updated dependencies
\[[`8c0fd01`](8c0fd01),
[`a1ad06c`](a1ad06c),
[`9daa584`](9daa584),
[`7f38b3a`](7f38b3a),
[`bf2d0e7`](bf2d0e7),
[`6966201`](6966201),
[`536f366`](536f366),
[`889cb6c`](889cb6c),
[`6a002b2`](6a002b2),
[`8ff5c5a`](8ff5c5a),
[`6966201`](6966201),
[`3ccf335`](3ccf335),
[`a99aa48`](a99aa48),
[`dda52f1`](dda52f1)]:
    -   @browserbasehq/stagehand@2.5.1

## @browserbasehq/stagehand-examples@1.0.10

### Patch Changes

- Updated dependencies
\[[`8c0fd01`](8c0fd01),
[`a1ad06c`](a1ad06c),
[`9daa584`](9daa584),
[`7f38b3a`](7f38b3a),
[`bf2d0e7`](bf2d0e7),
[`6966201`](6966201),
[`536f366`](536f366),
[`889cb6c`](889cb6c),
[`6a002b2`](6a002b2),
[`8ff5c5a`](8ff5c5a),
[`6966201`](6966201),
[`3ccf335`](3ccf335),
[`a99aa48`](a99aa48),
[`dda52f1`](dda52f1)]:
    -   @browserbasehq/stagehand@2.5.1

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

3 participants