Adding Browser Use to Your Agentic App

December 25, 2025

Browser automation is becoming essential for AI agents that need to interact with the real world - searching for information, filling forms, extracting data, and navigating web applications. This guide covers how to add browser capabilities to your agentic applications.

Overview of Browser Agent Solutions

Several frameworks provide browser automation for AI agents:

SolutionFrameworkBrowser EngineKey Features
MultimodalWebSurferAutoGenPlaywright/ChromiumSet-of-mark screenshots, built-in tools
Browser UseLangChain compatiblePlaywrightDOM extraction, action chains
Playwright MCPModel Context ProtocolPlaywrightStandardized tool interface
PuppeteerStandaloneChrome DevToolsLow-level control
SeleniumStandaloneWebDriverCross-browser support

This guide focuses on AutoGen's MultimodalWebSurfer as a representative implementation, but the concepts apply broadly.


AutoGen MultimodalWebSurfer

AutoGen's MultimodalWebSurfer is a multimodal agent that can browse the web autonomously - searching, navigating pages, clicking links, filling forms, and extracting information.

Installation

pip install "autogen-ext[web-surfer]"

Quick Start

import asyncio
from autogen_agentchat.ui import Console
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.agents.web_surfer import MultimodalWebSurfer


async def main() -> None:
    web_surfer_agent = MultimodalWebSurfer(
        name="MultimodalWebSurfer",
        model_client=OpenAIChatCompletionClient(model="gpt-4o-2024-08-06"),
    )

    agent_team = RoundRobinGroupChat([web_surfer_agent], max_turns=3)

    stream = agent_team.run_stream(task="Navigate to the AutoGen readme on GitHub.")
    await Console(stream)

    # Important: Close the browser when done
    await web_surfer_agent.close()


asyncio.run(main())

How It Works

  1. Browser Initialization: Playwright launches Chromium on first call (reused for subsequent calls)
  2. Screenshot & Analysis: Takes screenshot, extracts interactive elements, creates set-of-mark (SOM) image with bounding boxes
  3. Model Decision: Sends SOM screenshot + message history + available tools to multimodal model
  4. Action Execution: Executes tool calls via PlaywrightController
  5. Response Generation: Returns screenshot, page metadata, action description, and webpage text

Configuration

web_surfer = MultimodalWebSurfer(
    name="WebSurfer",
    model_client=model_client,

    # Browser
    headless=True,                       # No visible window
    start_page="https://www.bing.com/",  # Initial page
    browser_channel=None,                # e.g., "chrome"
    browser_data_dir=None,               # Persistent data

    # Viewport (default: 1440x900)
    to_resize_viewport=True,

    # Features
    downloads_folder=None,     # Save downloads here
    animate_actions=False,     # Visual cursor animations
    to_save_screenshots=False, # Save screenshots to disk
    use_ocr=False,             # OCR for text extraction

    # Debug
    debug_dir=None,

    # Advanced: existing Playwright instance
    playwright=None,
    context=None,
)

PlaywrightController API

The PlaywrightController handles browser interactions:

Navigation

  • visit_page(page, url) - Navigate to URL
  • back(page) - Go back
  • page_down(page) / page_up(page) - Scroll viewport

Interactions

  • click_id(page, identifier) - Click element
  • hover_id(page, identifier) - Hover over element
  • fill_id(page, identifier, value, press_enter=True) - Fill form
  • scroll_id(page, identifier, direction) - Scroll within element

Content Extraction

  • get_webpage_text(page, n_lines=50) - Get page text
  • get_visible_text(page) - Get viewport text
  • get_page_metadata(page) - Get title, URL, etc.

Element Detection

  • get_interactive_rects(page) - Get interactive elements with bounding boxes
  • get_focused_rect_id(page) - Get focused element ID

Utilities

  • sleep(page, duration) - Wait (for page loads)

Windows Compatibility

import sys
import asyncio

if sys.platform == "win32":
    asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())

Model Requirements

The model must be:

  • Multimodal: Process screenshots
  • Function calling capable: Execute browser actions

Recommended: GPT-4o (gpt-4o-2024-08-06 or later)


Security Considerations

Browser agents interact with the real web, which introduces risks:

Risks

  • Agents may accept cookie agreements or click unexpected buttons
  • Susceptible to prompt injection from malicious webpages
  • May inadvertently expose credentials or sensitive data

Mitigations

  1. Run in sandboxed/containerized environments
  2. Whitelist allowed domains
  3. Monitor agent actions in real-time
  4. Never expose sensitive credentials to agents
  5. Use read-only modes when possible

Example: Research Agent

import asyncio
from autogen_agentchat.ui import Console
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.agents.web_surfer import MultimodalWebSurfer


async def research_topic(topic: str) -> None:
    web_surfer = MultimodalWebSurfer(
        name="Researcher",
        model_client=OpenAIChatCompletionClient(model="gpt-4o-2024-08-06"),
        headless=True,
        to_save_screenshots=True,
        debug_dir="./research_debug",
    )

    team = RoundRobinGroupChat([web_surfer], max_turns=5)

    task = f"""
    Research: {topic}
    1. Search on Bing
    2. Visit 2-3 relevant pages
    3. Summarize key findings
    """

    stream = team.run_stream(task=task)
    await Console(stream)
    await web_surfer.close()


if __name__ == "__main__":
    asyncio.run(research_topic("AutoGen multi-agent framework"))

References

  1. AutoGen MultimodalWebSurfer Documentation. (n.d.). Microsoft. Retrieved December 25, 2025, from https://microsoft.github.io/autogen/stable/reference/python/autogen_ext.agents.web_surfer.html

© 2025 borui. All rights reserved. This content may be freely reproduced, displayed, modified, or distributed with proper attribution to borui and a link to the article: borui (2025-12-25). Adding Browser Use to Your Agentic App. https://caiborui.com/blog/2025-12-25-en-autogen-multimodal-web-surfer-browser-agent

@misc{borui2025-e23327fa,
  author = {borui},
  title = {{Adding Browser Use to Your Agentic App}},
  year = {2025},
  publisher = {borui's blog},
  url = {https://caiborui.com/blog/2025-12-25-en-autogen-multimodal-web-surfer-browser-agent}
}