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

Copy link

changeset-bot bot commented Sep 17, 2025

⚠️ No Changeset found

Latest commit: 3ea4178

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a 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

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.

1 participant