-
Notifications
You must be signed in to change notification settings - Fork 54
feat(tools): add use_browser tool to Strands tools repository #88
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
Open
jimbrub
wants to merge
15
commits into
strands-agents:main
Choose a base branch
from
jimbrub:use_browser
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1ae6085
feat(tools): add use_browser tool to Strands tools repository
jimbrub b3afd62
test(use_browser): add more unit testing for use_browser tool
jimbrub 43d33d1
feat(tools): add retry and multi-tab support to use_browser tool
jimbrub 0df1045
feat: add more retry logic and environment variables
jimbrub 233ab91
fix(use_browser): fix screenshot error and using Playwright specific …
jimbrub 9128479
fix(use_browser): fix logs and fix how actions are being called, now …
jimbrub 3532dce
fix(use_browser): fix merge conflicts in README file
jimbrub 3db4b74
Delete src/strands_tools/use_computer.py
jimbrub c416228
test(use_browser): add more unit testing for use_browser tool
jimbrub f64a0d8
fix(use_browser): Resolving merge conflicts and updating README.md
jimbrub bedf960
Update use_browser.py
jimbrub 0ff8110
test(use_browser): add more unit testing for use_browser tool
jimbrub 74c3601
fix(use_browser): fix merge conflicts in README file
jimbrub 04c29a2
feat(use_browser): Added BrowserApiMethods class which has all the br…
jimbrub f4fface
fix: Remove use_computer.py
jimbrub File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,8 @@ Strands Agents Tools provides a powerful set of tools for your agents to use. It | |
- 🧠 **Advanced Reasoning** - Tools for complex thinking and reasoning capabilities | ||
- 🐝 **Swarm Intelligence** - Coordinate multiple AI agents for parallel problem solving with shared memory | ||
- 🔄 **Multiple tools in Parallel** - Call multiple other tools at the same time in parallel with Batch Tool | ||
|
||
- 🔍 **Browser Tool** - Tool giving an agent access to perform automated actions on a browser (chromium) | ||
|
||
## 📦 Installation | ||
|
||
### Quick Install | ||
|
@@ -121,6 +122,7 @@ Below is a comprehensive table of all available tools, how to use them with an a | |
| use_llm | `agent.tool.use_llm(prompt="Analyze this data", system_prompt="You are a data analyst")` | Create nested AI loops with customized system prompts for specialized tasks | | ||
| workflow | `agent.tool.workflow(action="create", name="data_pipeline", steps=[{"tool": "file_read"}, {"tool": "python_repl"}])` | Define, execute, and manage multi-step automated workflows | | ||
| batch| `agent.tool.batch(invocations=[{"name": "current_time", "arguments": {"timezone": "Europe/London"}}, {"name": "stop", "arguments": {}}])` | Call multiple other tools in parallel. | | ||
| use_browser | `agent.tool.use_browser(action="navigate", url="https://www.example.com") ` | Web scraping, automated testing, form filling, web automation tasks | | ||
|
||
\* *These tools do not work on windows* | ||
|
||
|
@@ -301,6 +303,32 @@ result = agent.tool.batch( | |
) | ||
``` | ||
|
||
### Use Browser | ||
```python | ||
from strands import Agent | ||
from strands_tools import use_browser | ||
|
||
agent = Agent(tools=[use_browser]) | ||
|
||
# Simple navigation | ||
result = agent.tool.use_browser(action="navigate", url="https://example.com") | ||
|
||
# Sequential actions for form filling | ||
result = agent.tool.use_browser(actions=[ | ||
{"action": "navigate", "args": {"url": "https://example.com/login"}}, | ||
{"action": "type", "args": {"selector": "#username", "text": "[email protected]"}}, | ||
{"action": "click", "args": {"selector": "#submit"}} | ||
]) | ||
|
||
# Web scraping with content extraction | ||
result = agent.tool.use_browser(actions=[ | ||
{"action": "navigate", "args": {"url": "https://example.com/data"}}, | ||
{"action": "get_text", "args": {"selector": ".content"}}, | ||
{"action": "click", "args": {"selector": ".next-page"}}, | ||
{"action": "get_html", "args": {"selector": "main"}} | ||
]) | ||
``` | ||
|
||
## 🌍 Environment Variables Configuration | ||
|
||
Agents Tools provides extensive customization through environment variables. This allows you to configure tool behavior without modifying code, making it ideal for different environments (development, testing, production). | ||
|
@@ -443,6 +471,20 @@ The Mem0 Memory Tool supports three different backend configurations: | |
| FILE_READ_USE_GIT_DEFAULT | Default setting for using git in time machine mode | true | | ||
| FILE_READ_NUM_REVISIONS_DEFAULT | Default number of revisions to show in time machine mode | 5 | | ||
|
||
#### Use Browser Tool | ||
|
||
| Environment Variable | Description | Default | | ||
|----------------------|-------------|---------| | ||
| DEFAULT_WAIT_TIME | Default setting for wait time with actions | 1 | | ||
| BROWSER_MAX_RETRIES | Default number of retries to perform when an action fails | 3 | | ||
| BROWSER_SCREENSHOTS_DIR | Default directory where screenshots will be saved | screenshots | | ||
| BROWSER_USER_DATA_DIR | Default directory where data for reloading a browser instance is stored | ~/.browser_automation | | ||
| BROWSER_HEADLESS | Default headless setting for launching browsers | false | | ||
| BROWSER_WIDTH | Default width of the browser | 1280 | | ||
| BROWSER_HEIGHT | Default height of the browser | 800 | | ||
| ENABLE_DEBUG_BROWSER_LOGS | Default enable of the browser's debug logs | false | | ||
|
||
|
||
## Contributing ❤️ | ||
|
||
We welcome contributions! See our [Contributing Guide](CONTRIBUTING.md) for details on: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How heavy is this dependency?
I'm leaning towards this being an optional dependency as I don't want everyone to need to download playwright just to use
memory
for instanceThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't too sure on the acceptable way to add these dependencies. As long as adding them as optional dependencies keeps the same functionality with the tool, I would rather do it that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you can make it optional and then the installs are done via: