Overview
Tools are functions that expand what your agent can do beyond basic browser actions. Add custom tools to:- Call external APIs
- Access databases
- Implement human-in-the-loop workflows
- Handle 2FA codes
- Execute custom JavaScript
- Integrate with Playwright or Selenium
- Send emails or notifications
Creating Your First Tool
1
Initialize Tools
2
Add a Simple Tool
Use the
@tools.action() decorator:3
Pass Tools to Agent
Tool Response Types
Simple String Return
ActionResult (Advanced)
extracted_content: Main result shown to agentlong_term_memory: Info to remember across stepserror: Error messageis_done: Mark task as completesuccess: Whether action succeededattachments: List of file paths
Accessing Browser State
Real-World Examples
Human-in-the-Loop Approval
2FA Code Generation
API Integration
Custom JavaScript Execution
Database Operations
Domain Filtering
Restrict tools to specific domains for safety:'example.com'- Onlyhttps://example.com/*'*.example.com'- All subdomains'http*://example.com'- Both HTTP and HTTPS'chrome-extension://*'- Chrome extensions
Removing Default Tools
Exclude built-in tools you don’t need:Tool Parameter Types
The agent automatically fills parameters based on type hints:Advanced: Actor Integration
Use the Actor for deterministic browser control:Best Practices
1
Clear Descriptions
Write descriptions that tell the LLM when and why to use the tool:✅ Good:❌ Bad:
2
Return Useful Content
Give the agent context about what happened:
3
Handle Errors Gracefully
4
Use Type Hints
Help the LLM understand parameter types:
Next Steps
Available Tools
See all built-in browser actions
Actor Reference
Direct browser control methods
Data Extraction
Extract structured data from pages
Production
Deploy with @sandbox decorator