Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:CrewAIInc CrewAI Bedrock Browser Toolkit

From Leeroopedia
Revision as of 11:06, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/CrewAIInc_CrewAI_Bedrock_Browser_Toolkit.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains AWS, Browser_Automation, Tools
Last Updated 2026-02-11 00:00 GMT

Overview

Comprehensive toolkit providing 7 browser automation tools for CrewAI agents through AWS Bedrock, with thread-safe session management and both sync/async support.

Description

This module implements a complete browser automation solution integrated with AWS infrastructure. It provides the following tool classes, all inheriting from BrowserBaseTool:

  • NavigateTool (navigate_browser): Navigate to URLs with HTTP/HTTPS scheme validation
  • ClickTool (click_element): Click elements by CSS selector with visibility filtering and Playwright strict mode
  • NavigateBackTool (navigate_back): Navigate back to the previous page in browser history
  • ExtractTextTool (extract_text): Extract all text from the current webpage using BeautifulSoup
  • ExtractHyperlinksTool (extract_hyperlinks): Extract all hyperlinks with text and URL as JSON
  • GetElementsTool (get_elements): Query elements by CSS selector and return their text content
  • CurrentWebPageTool (current_webpage): Get URL and title of the current webpage

The BrowserBaseTool base class provides:

  • Session manager integration via BrowserSessionManager
  • Automatic asyncio loop detection with nest_asyncio patching for sync operation in async contexts
  • Thread-based isolation through thread_id parameter on all tools
  • Both sync (_run) and async (_arun) execution methods

The BrowserToolkit manager class coordinates the lifecycle:

  • Initializes all 7 tools with a shared session manager
  • Provides get_tools() and get_tools_by_name() accessors
  • Handles cleanup with both async cleanup() and sync_cleanup() methods

Usage

Use this toolkit when CrewAI agents need to browse the web, extract content, click through pages, or gather data from websites. The thread-based isolation enables parallel browsing across multiple agents.

Code Reference

Source Location

  • Repository: CrewAI
  • File: lib/crewai-tools/src/crewai_tools/aws/bedrock/browser/browser_toolkit.py
  • Lines: 1-612

Signature (BrowserToolkit)

class BrowserToolkit:
    """Toolkit for navigating web with AWS Bedrock browser."""

    def __init__(self, region: str = "us-west-2"):
        self.region = region
        self.session_manager = BrowserSessionManager(region=region)
        self.tools: list[BaseTool] = []

Signature (BrowserBaseTool)

class BrowserBaseTool(BaseTool):
    """Base class for browser tools."""

    def __init__(self, session_manager: BrowserSessionManager):
        ...

    async def get_async_page(self, thread_id: str) -> Any: ...
    def get_sync_page(self, thread_id: str) -> Any: ...

Factory Function

def create_browser_toolkit(
    region: str = "us-west-2",
) -> tuple[BrowserToolkit, list[BaseTool]]:
    """Create a BrowserToolkit and return (toolkit, tools)."""

Import

from crewai_tools.aws.bedrock.browser.browser_toolkit import (
    BrowserToolkit,
    create_browser_toolkit,
)

I/O Contract

Inputs (BrowserToolkit)

Name Type Required Description
region str No AWS region for the browser client (default: "us-west-2")

Tool Input Schemas

Tool Parameters Description
NavigateTool url (str), thread_id (str) URL to navigate to and session thread ID
ClickTool selector (str), thread_id (str) CSS selector for element to click
NavigateBackTool thread_id (str) Thread ID for the browser session
ExtractTextTool thread_id (str) Thread ID for the browser session
ExtractHyperlinksTool thread_id (str) Thread ID for the browser session
GetElementsTool selector (str), thread_id (str) CSS selector for elements to query
CurrentWebPageTool thread_id (str) Thread ID for the browser session

Outputs

Name Type Description
get_tools() list[BaseTool] List of 7 browser tools
get_tools_by_name() dict[str, BaseTool] Dictionary mapping tool names to tool instances
NavigateTool._run() str Status message with URL and HTTP status code
ClickTool._run() str Confirmation message or error description
ExtractTextTool._run() str Extracted text content from the page
ExtractHyperlinksTool._run() str JSON array of {text, url} objects
GetElementsTool._run() str Newline-separated element text content
CurrentWebPageTool._run() str URL and title of the current page

Usage Examples

Basic Usage

from crewai import Agent, Task, Crew
from crewai_tools.aws.bedrock.browser import create_browser_toolkit

# Create the browser toolkit
toolkit, browser_tools = create_browser_toolkit(region="us-west-2")

# Create a CrewAI agent with browser tools
research_agent = Agent(
    role="Web Researcher",
    goal="Research and summarize web content",
    backstory="You're an expert at finding information online.",
    tools=browser_tools,
)

# Create a task
research_task = Task(
    description="Navigate to https://example.com and extract all text content.",
    agent=research_agent,
)

# Run the crew
crew = Crew(agents=[research_agent], tasks=[research_task])
result = crew.kickoff()

# Clean up browser resources
import asyncio
asyncio.run(toolkit.cleanup())

ClickTool Configuration

# ClickTool has additional configuration options
click_tool = ClickTool(session_manager=session_manager)
click_tool.visible_only = True          # Only consider visible elements
click_tool.playwright_strict = False     # Non-strict mode for clicking
click_tool.playwright_timeout = 1_000    # 1 second timeout for element readiness

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment