Skip to content

feat(tools): add use_browser tool to Strands tools repository #102

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 19 commits into from
Jul 2, 2025

Conversation

jimbrub
Copy link
Contributor

@jimbrub jimbrub commented Jun 27, 2025

Description

Adding a use_browser tool, that gives an agent actions, so they interact with browsers (just chromium right now). This tool relies on Playwright to perform automated actions on a browser. Playwright allows for a browser to be launched with different launch options. One of these launch options is persistent_context, which allows users to launch a browser and load in the saved data from whatever the specified user_data_dir is. This feature is used to save cookie settings, local storage, sessions storage, browser history, saved passwords, etc. Right now you can ask an agent to use the use_browser tool to launch a browser with persistent_context set to true and specify a file path for user_data_dir. Then, any usernames, bookmarks you create, or search history should be stored in the user_data_dir and then the browser can be relaunched at a later date.

Related Issues

https://github.com/strands-agents/private-sdk-python-staging/issues/72
This PR addressed the concerns with the original PR for this tool: #88

Documentation PR

Added some documentation on how to use this tool in the README

Type of Change

  • New Tool

Testing

[How have you tested the change?]

  • hatch fmt --linter
  • hatch fmt --formatter
  • hatch test --all

Checklist

  • I have read the CONTRIBUTING document

  • I have added tests that prove my fix is effective or my feature works

  • I have updated the documentation accordingly

  • I have added an appropriate example to the documentation to outline the feature

  • My changes generate no new warnings

  • Any dependent changes have been merged and published

  • By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@jimbrub jimbrub requested a review from a team as a code owner June 27, 2025 15:38
@cagataycali
Copy link
Member

When I tried to use the tool I hit this error:

Tool #1: use_browser
Failed to initialize browser: BrowserType.launch: Executable doesn't exist at /Users/cagatay/Library/Caches/ms-playwright/chromium-1179/chrome-mac/Chromium.app/Contents/MacOS/Chromium
╔════════════════════════════════════════════════════════════╗
║ Looks like Playwright was just installed or updated.       ║
║ Please run the following command to download new browsers: ║
║                                                            ║
║     playwright install                                     ║
║                                                            ║
║ <3 Playwright Team                                         ║
╚════════════════════════════════════════════════════════════╝
Action 'navigate' attempt 1 failed: BrowserType.launch: Executable doesn't exist at /Users/cagatay/Library/Caches/ms-playwright/chromium-1179/chrome-mac/Chromium.app/Contents/MacOS/Chromium

I think use_browser tool should handle this error gradually and install required dependencies ^^

Copy link
Member

@mehtarac mehtarac left a comment

Choose a reason for hiding this comment

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

LGTM

@mehtarac mehtarac merged commit 3d69fa2 into strands-agents:main Jul 2, 2025
14 checks passed
cagataycali pushed a commit to cagataycali/tools that referenced this pull request Jul 2, 2025
…s-agents#102)

* feat(tools): add use_browser tool to Strands tools repository

* test(use_browser): add more unit testing for use_browser tool

* feat(tools): add retry and multi-tab support to use_browser tool

Adding functionality so use_browser tool has some retry functionality and supports multiple tabs and switching between them.

* feat: add more retry logic and environment variables

* fix(use_browser): fix screenshot error and using Playwright specific errors for better error handling

* fix(use_browser): fix logs and fix how actions are being called, now actions are only called with their required arguments

* fix(use_browser): fix merge conflicts in README file

* Delete src/strands_tools/use_computer.py

* test(use_browser): add more unit testing for use_browser tool

* Update use_browser.py

* test(use_browser): add more unit testing for use_browser tool

* fix(use_browser): fix merge conflicts in README file

* feat(use_browser): Added BrowserApiMethods class which has all the browser actions as methods

* feat: Updating readme and pyproject.toml

* feat: Adding use_browser tool

* fix: fixing README file

* fix: fixing dependencies for testing

* fix: cleaning logs and updating README file

* fix: fixing log statements to pass all checks
@jimbrub jimbrub deleted the use_browser_final branch July 17, 2025 21:12
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