Overview
The Tools system is the bridge between the LLM and browser actions. It provides a registry of actions the agent can perform, handles parameter validation, and manages action execution. Each tool is a function that the LLM can call to interact with the web.Architecture
Registry
Centralized catalog of available actions
Action Models
Pydantic models for type-safe parameters
Parameter Injection
Automatic dependency injection from context
Result Handling
Structured responses with ActionResult
The Tools Class
TheTools class (line 345 in tools/service.py) manages the action registry:
Creating a Tools Instance
Default Browser Actions
Navigation Actions
- search
- go_back
Search the web using a search engineImplementation (line 362 in
tools/service.py):- Encodes query for URL safety
- Constructs search URL for specified engine
- Navigates to search results
- Returns:
"Searched {engine} for '{query}'"
Interaction Actions
- click
- input
- scroll
- send_keys
Click an element by index or coordinateImplementation (line 565 for index, line 521 for coordinate):
- Looks up element from selector_map
- Highlights element visually
- Detects if click opens new tab
- Handles special cases (dropdowns, file inputs)
- Returns:
"Clicked {element_description}"
Coordinate clicking is auto-enabled for Claude Sonnet 4, Claude Opus 4, Gemini 3 Pro, and Browser Use models.
Content Extraction
- extract
- search_page
- find_elements
Extract structured data from page using LLMImplementation (line 947):
- Extracts clean markdown from page (removes ads/noise)
- Chunks content if over 100k chars
- Calls page_extraction_llm with query
- Returns structured or free-text result
- Saves to file if result is large
- Original HTML → Initial Markdown → Filtered Markdown
- Structure-aware chunking (preserves tables, lists)
- Overlap context for continuation chunks
- Stats included in response
<url>...</url><query>...</query><result>...</result>Tab Management
- switch
- close
Switch to another tabReturns:
"Switched to tab #{tab_id}"File Operations
- upload_file
- write_file
- read_file
Upload file to input[type=file]Implementation (line 721):
- Validates file exists and has content
- Finds file input near selected element
- Falls back to closest file input to scroll position
- Returns:
"Successfully uploaded file"
Form Controls
- dropdown_options
- select_dropdown
Get dropdown optionsReturns all options with values and text.
Completion
- done
- screenshot
Complete the taskSignals task completion with final output.
Creating Custom Tools
Basic Custom Tool
Tool with Browser Access
Tool with Multiple Injections
Available injectable parameters (line 77 intools/service.py):
Domain-Restricted Tools
ActionResult Response
TheActionResult class structures tool responses:
extracted_content: Main result text (shown to agent)error: Error message if action failedis_done: Mark task as completesuccess: Whether task succeeded (for done action)attachments: List of file pathsmetadata: Additional structured datalong_term_memory: Summary for agent’s memoryinclude_extracted_content_only_once: Show full content once, use memory after
Parameter Injection System
The tools system automatically injects context based on parameter names:The injection happens at execution time, not registration. You don’t need to pass these values when registering tools.
Tools Registry
TheRegistry class manages action registration:
Excluding Default Actions
Remove actions you don’t need:screenshot: Whenuse_vision != 'auto'search: For domain-restricted tasksupload_file: For read-only tasks
Coordinate Clicking
Enable coordinate-based clicking for advanced models:Structured Output Integration
Define expected output format:Real-World Examples
Human-in-the-Loop
API Integration
Database Access
Deterministic Automation
Performance Considerations
- Zero-Cost Tools
- Batch Actions
- Streaming Results
Use
search_page and find_elements for fast, LLM-free lookups:Troubleshooting
Tool not being called
Tool not being called
Check:
- Tool description is clear and specific
- Parameter types are correct
- Tool isn’t excluded in Tools(exclude_actions=[…])
- Domain restrictions don’t block current page
Parameter injection fails
Parameter injection fails
Verify:
- Parameter name matches exactly (e.g.,
browser_session) - Type hint is correct (e.g.,
BrowserSession) - Parameter is available in current context
ActionResult not working
ActionResult not working
Ensure:
- Return type is ActionResult or str
- Don’t raise exceptions, return ActionResult(error=’…’)
- Use proper field names (extracted_content, not content)
Next Steps
Available Tools
Complete list of default actions
Add Custom Tools
Detailed guide to creating tools
Tool Response
Advanced ActionResult patterns
Actor API
Playwright-like browser control