Skip to main content

Overview

Kortix agents can control a real browser using natural language commands. This enables agents to interact with any website just like a human would - clicking buttons, filling forms, scrolling pages, and extracting structured data. The browser automation capability is powered by Stagehand, running in a sandboxed environment with full visual feedback through screenshots.

Core Functions

The browser tool provides four essential functions that handle all web automation tasks:
Navigates to any URL and loads the page.

Perform Actions

Performs any browser action using natural language descriptions:
  • Click any element (buttons, links, images)
  • Fill forms (text, emails, passwords)
  • Select dropdown options
  • Scroll pages
  • Keyboard input (Enter, Tab, Escape)
  • Upload files (with filePath parameter)

Extract Content

Extracts structured data from web pages using natural language instructions.

Take Screenshots

Captures the current page state. Screenshots are automatically included with every action for visual validation.

Real-World Examples

Example 1: Login Flow

Example 2: Data Extraction

Example 3: Multi-Step Research

Implementation Details

From the source code (browser_tool.py:108-542):

Architecture

  1. Stagehand API Server: Runs on port 8004 inside the sandbox
  2. Health Checks: Automatic retry with exponential backoff
  3. Screenshot Validation: Every action returns a screenshot for verification
  4. Secure Variables: Sensitive data (passwords) not logged to LLM providers

Validation and Error Handling

From browser_tool.py:127-194:

Security Features

Variables Parameter

For sensitive data like passwords, use the variables parameter:
Variables are NOT shared with LLM providers for security.

Sandboxed Execution

All browser actions run in an isolated sandbox environment:
  • No access to host system
  • Temporary, disposable instances
  • Safe for any website

File Upload Support

For actions involving file uploads:
Always include the filePath parameter when dealing with upload-related elements to prevent accidental file dialog triggers.

Best Practices

1. Direct URL Research

When researching a specific website, browse it directly:

2. Screenshot Validation

Every action returns a screenshot. Review it to verify expected results:

3. Information Reuse

Once content is extracted, use it as the primary source:

When to Use Browser vs Other Tools

Use Browser For

  • Interacting with dynamic websites
  • Filling forms or multi-step flows
  • Sites requiring clicks/JavaScript
  • Visual inspection needed
  • Login-protected content

Use Alternative Tools

  • Static content → scrape_webpage
  • API data → API tools
  • GitHub URLs → gh CLI
  • Simple page reads → web_search

Limitations

  • Requires GEMINI_API_KEY configuration
  • Browser startup takes a few seconds
  • Not suitable for high-frequency automation
  • Screenshots consume additional storage

Configuration

Browser automation requires:
The Stagehand API server starts automatically in the sandbox and listens on port 8004.