Skip to main content

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
Tools are called automatically by the LLM when it determines they’re needed for the task.

Creating Your First Tool

1

Initialize Tools

2

Add a Simple Tool

Use the @tools.action() decorator:
The description parameter is required - the LLM uses it to decide when to call your tool.
3

Pass Tools to Agent

Tool Response Types

Simple String Return

ActionResult (Advanced)

ActionResult Fields:
  • extracted_content: Main result shown to agent
  • long_term_memory: Info to remember across steps
  • error: Error message
  • is_done: Mark task as complete
  • success: Whether action succeeded
  • attachments: List of file paths

Accessing Browser State

Critical: Use parameter name browser_session with type BrowserSession (NOT browser: Browser). The agent injects parameters by name matching.

Real-World Examples

Human-in-the-Loop Approval

2FA Code Generation

See the Authentication guide for more 2FA patterns.

API Integration

Custom JavaScript Execution

Database Operations

Domain Filtering

Restrict tools to specific domains for safety:
Domain Pattern Formats:
  • 'example.com' - Only https://example.com/*
  • '*.example.com' - All subdomains
  • 'http*://example.com' - Both HTTP and HTTPS
  • 'chrome-extension://*' - Chrome extensions
Wildcards in TLDs (e.g., example.*) are not allowed for security.

Removing Default Tools

Exclude built-in tools you don’t need:
See Available Tools for the full list.

Tool Parameter Types

The agent automatically fills parameters based on type hints:
Use Pydantic models for complex structured inputs. The LLM will generate valid instances.

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