Skip to main content
The user states a browsing goal; the Chrome extension and bridge execute actions until the task completes. Control web browsers with AI agents through a Chrome Extension connected to PraisonAI.

Install

Browser automation lives in the standalone Tier-2 package praisonai-browser.
pip install "praisonai[all]" (or praisonai[browser]) installs praisonai-browser for you, and every praisonai browser … command keeps working unchanged.

Quick Start

1

Start the bridge server

2

Load the Chrome extension

Open chrome://extensions, enable Developer mode, and load unpacked from praisonai-chrome-extension/dist.
3

Run a goal

Press Ctrl+Shift+P in the side panel, or run from CLI:

Architecture

Flow: Chrome Extension ↔ WebSocket ↔ Bridge Server ↔ PraisonAI Agent The system consists of:
  • Chrome Extension: Captures page state and executes actions via CDP
  • Bridge Server: FastAPI WebSocket server that routes messages to agents
  • BrowserAgent: PraisonAI agent that decides actions based on observations
  • SessionManager: SQLite-based persistence for session history
  • Hybrid Mode: Falls back to on-device Gemini Nano if server unavailable

Session Flow

Session States

Smart Features

Click Fallbacks

When clicks fail, the agent automatically tries:
  1. Viewport click using getBoundingClientRect() + scrollIntoView()
  2. JavaScript click via element.click()
  3. Focus + Enter for buttons

Goal Context & Self-Correction

Every observation sent to the LLM includes:
  • Original goal: Always visible to prevent drift
  • Action history: Last 5 actions with success/failure status
  • Progress notes: Summary of steps completed

Failure Communication

When actions fail, the LLM receives explicit feedback:
This enables the agent to self-correct and find alternate paths.

CLI Commands

Run Browser Agent

Execute a goal directly from CLI with live progress display:
Options:
  • --url, -u: Start URL (default: https://www.google.com)
  • --model, -m: LLM model (default: gpt-4o-mini)
  • --timeout, -t: Timeout in seconds (default: 120)
  • --debug, -d: Debug mode - show all events
Example Output:

Scripting run

run returns a stable exit code, so CI and cron jobs can branch on the failure type:
See Browser CLI → Exit codes for the full reference.

If the bridge server is not running

Your browser agent won’t start and you see a friendly bridge-unreachable message. The fix is one command in a second terminal, not a code change.
run connects to the local bridge server, not the site in --url. When that server is down it prints:
This message replaces the raw WinError 1225 (Windows), errno 111 (Linux), and errno 61 (macOS) connection-refused errors. The failing layer is the local bridge on port 8765, not the target --url.
Recover with the two-terminal setup, then point to Start Server for the fix:
1

Terminal A — start the bridge

Leave this terminal open; the server blocks while it listens.
2

Terminal B — run the agent again

Launch Browser with Goal

Launch Chrome with the extension and optionally run a goal:
Options:
  • --url, -u: Start URL (default: https://www.google.com)
  • --model, -m: LLM model (default: gpt-4o-mini)
  • --max-steps: Maximum steps (default: 20)
  • --engine: Automation engine: extension, cdp, auto (default: auto)
  • --debug, -d: Debug mode with detailed logging
  • --record-video: Record video of browser session
  • --profile: Enable performance profiling
  • --deep-profile: Enable deep profiling with cProfile

Performance Profiling

Track execution time per step to identify bottlenecks:
Example Output:
For deep function-level profiling (cProfile):

Tab Management

Execute JavaScript

Page Inspection (New)

Inspect browser pages without the extension:
These commands work via CDP (Chrome DevTools Protocol) and require Chrome running with --remote-debugging-port=9222.

Automation Engines

Choose different execution engines with --engine:

Screenshot

Start Server

Options:
  • --port, -p: Port to listen on (default: 8765)
  • --host, -H: Host to bind to (default: 0.0.0.0)
  • --model, -m: LLM model (default: gpt-4o-mini)
  • --max-steps: Maximum steps per session (default: 20)
  • --verbose, -v: Enable verbose logging

”Already running” behaviour

Starting the server on a port that is already in use exits cleanly instead of failing. Before binding, the CLI probes the port with _port_in_use(host, port). If a server is already there, it prints a friendly message and exits with code 0:
If the port slips through the pre-check and binding fails at runtime, the CLI catches the OSErrorWinError 10048 on Windows or errno.EADDRINUSE on Linux/macOS — prints the same message, and still exits 0. Any other OSError prints Error: <message> and exits 1.
Because a duplicate start is exit code 0, you can add praisonai browser start to a script or Makefile without guarding against a second launch — the first server keeps running and the second call is a clean no-op.

Windows notes

Startup banners are ASCII (no emoji) and the console script forces stdout/stderr to UTF-8, so cp1252 Windows consoles run praisonai browser start without a UnicodeEncodeError. This works out of the box — no code page changes required. See PraisonAI issue #3094 for background.

Binding to IPv6

Pass an IPv6 literal to --host and it works:
The duplicate-start check resolves the address family with getaddrinfo, so IPv6 hosts like ::1 are probed on the correct family instead of being silently missed.

List Sessions

Options:
  • --status, -s: Filter by status (running, completed, failed)
  • --limit, -l: Maximum sessions to show

View History

Clear Sessions

Reload Extension

Reload the Chrome extension after making changes:

Health Diagnostics

Your agent is trying to drive the browser, but nothing happens. One command tells you which layer broke:
Run health checks for the browser automation system:
doctor extension reads the bridge /health extension_connections count — a success there means the extension is loaded and reachable, even when running in your daily Chrome instead of the automated debug profile. See Manual extension load for the recovery recipe when it fails.
Example Output:
The bridge check is ground truth: extension_connections >= 1 means the extension is working. The CDP line is optional — it’s empty when you use your daily Chrome (no --remote-debugging-port), which is expected, not a failure.

Python API

Import the public classes from praisonai_browser.
The old path still works: from praisonai.browser import BrowserServer, BrowserAgent maps to praisonai_browser through a compatibility shim.

Run Return Shape

When run cannot reach the bridge, it returns a structured result so scripts can detect the failure without parsing text:
Other failures keep their existing generic error output — behaviour on reachable-but-failing runs is unchanged.

Session Management

Hybrid Mode (Extension)

The Chrome Extension supports hybrid mode:
  1. Bridge Mode: Connect to PraisonAI server for cloud LLMs
  2. Built-in Mode: Use Chrome’s Gemini Nano on-device
If the bridge server is unavailable, it automatically falls back to built-in AI.

Keyboard Shortcuts

Supported Actions

Error Detection & Recovery (v1.3+)

The agent automatically detects and recovers from errors:

Detected Errors

  • Garbled/duplicated text in input fields
  • Wrong page navigation (user or browser interference)
  • Failed actions (click not working, submit didn’t fire)
  • Blocking elements (popups, consent dialogs, login walls)

Recovery Actions

When errors are detected, the agent will:
  1. Set error_detected: true with description
  2. Report input_field_value showing actual text visible
  3. Use clear_input to fix garbled input
  4. Use navigate to return to correct URL if off-track

Step Timestamps

Debug mode now shows elapsed time for each step:
Output:

Performance Optimized

Action delays have been optimized for faster execution:
  • Click: 200ms (was 500ms)
  • Submit: 300ms (was 500ms)
  • Search: 400ms (was 1000ms)

WebSocket Protocol

Connect to ws://localhost:8765/ws and send/receive JSON messages:

Environment Variables


Best Practices

praisonai browser doctor checks server, Chrome debugging, extension, and session DB in one pass.
Use --engine cdp or playwright when the Chrome extension is not available in your pipeline.
Pass --max-steps so runaway loops stop instead of burning tokens.
Built-in Gemini Nano keeps the side panel working when the bridge server is offline.

praisonai-browser Package

The standalone Tier-2 package: install, CLI, imports, and backward compatibility.

Web Tools

Built-in web search and fetch tools for agents without browser control.

CLI

Full praisonai browser command reference and flags.

Code Execution

Run scripts alongside browser automation in agent workflows.

Observability Hooks

Trace browser agent steps and LLM calls in production.