← All tools

Web & HTTP

Browser (Chromium)

Real Chromium browser automation — click, type, fill forms, screenshot, evaluate JS.

browser

Overview

Drives an actual Chromium browser the way a human would — clicking links, typing into search boxes, filling out forms, taking screenshots. Use this when the page is too JavaScript-heavy for the lightweight 'browse' tool, or when the agent needs to interact with the page rather than just read it.

How it works

Powered by Microsoft Playwright over the Chrome DevTools Protocol. Supports three connection modes: launch a fresh Chromium, attach to an existing Chrome session (inheriting all cookies and logins), or use a Playwright-managed persistent profile. Operations include navigate, click, type, fill, fill_form, screenshot (file or base64), scrape, evaluate_js, wait_for, and close. The page state is preserved across tool calls, so multi-step flows like login → search → click result work without re-establishing context. Marked DANGEROUS — agents need explicit permission, and a host allow-list (`allowedHosts`) hard-restricts navigation at the framework layer.

Example

When a user asks:

Log in to my dashboard and download today's report.

the agent calls the tool:

browser(operation="fill_form", fields={"#username": "alice", "#password": "…"}); browser(operation="click", selector="button[type=submit]"); browser(operation="click", selector="a.download-report")

and gets back: the form is filled, the login button is clicked, and the report link is clicked — all in the same persisted browser session.

Configuration

Set these before calling the tool. Values marked required must be present or the tool call will fail.

swarmai.tools.browser.enabled required

Must be set to 'true' to register the tool — off by default because browser automation is high-blast-radius.

swarmai.tools.browser.mode optional

Connection mode: 'launch' (fresh Chromium, default), 'attach' (CDP attach to running Chrome — inherits cookies/logins), or 'persistent' (Playwright-managed profile).

swarmai.tools.browser.headless optional

Run Chromium headless. Defaults to true. Set false to see a real window during development.

swarmai.tools.browser.cdp-url optional

CDP endpoint when mode=attach (e.g. http://localhost:9222 after starting Chrome with --remote-debugging-port=9222).

swarmai.tools.browser.user-data-dir optional

Profile directory when mode=persistent. Logins survive restarts.

swarmai.tools.browser.allowed-hosts optional

Hard allow-list of host suffixes the tool may navigate to (e.g. ['github.com','wikipedia.org']). Empty list = no restriction (dev only).

swarmai.tools.browser.timeout-ms optional

Default operation timeout in milliseconds (default 30000).

swarmai.tools.browser.viewport-width optional

Viewport width in pixels (default 1280).

swarmai.tools.browser.viewport-height optional

Viewport height in pixels (default 800).

Use it in a workflow

Wire this tool into a SwarmAI crew. Use the YAML DSL for declarative workflows, or the Java builder API when you want full programmatic control.

YAML DSL

# browser-automation.yaml
name: browser-automation-crew
process: SEQUENTIAL

agents:
  - id: operator
    role: Web UI Operator
    goal: Drive a real browser to perform multi-step user flows
    tools:
      - browser

tasks:
  - id: download-report-task
    agent: operator
    description: Log in to the dashboard, navigate to Reports, and download today's PDF.

Java

import ai.intelliswarm.swarmai.agent.Agent;
import ai.intelliswarm.swarmai.task.Task;
import ai.intelliswarm.swarmai.swarm.Swarm;
import ai.intelliswarm.swarmai.swarm.SwarmOutput;
import ai.intelliswarm.swarmai.process.ProcessType;
import ai.intelliswarm.swarmai.tool.common.BrowserTool;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;

@Autowired ChatClient chatClient;
@Autowired BrowserTool browserTool;

Agent operator = Agent.builder()
    .role("Web UI Operator")
    .goal("Drive a real browser to perform multi-step user flows")
    .chatClient(chatClient)
    .tool(browserTool)
    .build();

Task downloadTask = Task.builder()
    .description("Log in to the dashboard, navigate to Reports, and download today's PDF.")
    .agent(operator)
    .build();

SwarmOutput result = Swarm.builder()
    .agent(operator)
    .task(downloadTask)
    .process(ProcessType.SEQUENTIAL)
    .build()
    .kickoff();

What it's good for

Real scenarios where agents put this tool to work.

Multi-step authenticated flows (login → navigate → download)
Form filling and submission on JS-heavy SPAs
Screenshot capture for visual regression or audit trails
Scraping pages where 'browse' (HtmlUnit) can't render the content
Attach mode for inheriting an analyst's existing Chrome login state
Building inbox dashboards — e.g. a Gmail Analysis UI that scrapes your real inbox and runs a local LLM over each email (see the gmail-dashboard example)

Source

Implementation lives at swarmai-tools/src/main/java/ai/intelliswarm/swarmai/tool/common/BrowserTool.java in the swarm-ai repository.

Open browser on GitHub →