• Documentation
  • Pricing
© 2026 Serverless, Inc. All rights reserved.

Framework

  • Overview
  • Documentation
  • Plugins360
  • Pricing

Learn

  • Blog
  • GuidesUpdated
  • Examples240
  • Courses

Resources

  • Support
  • Security
  • Trust Center
  • Status

Community

  • Slack
  • GitHub47k
  • Forum
  • Meetups

Company

  • About
  • Careers
  • Contact
  • Partners

Legal

  • Terms of Service
  • Privacy Policy
  • Trademark
  • DMCA
Serverless, inc.

Bedrock AgentCore: LangGraph Agent with Managed Browser (Python)

by

LangGraph agent using AgentCore Browser via LangChain's browser toolkit for web automation.

  1. Bedrock AgentCore: LangGraph Agent with Managed Browser (Python)

LangGraph Browser Example

This example demonstrates using AgentCore Browser with LangChain/LangGraph for web automation and research tasks.

Features

  • LangChain Integration - Uses langchain_aws.tools.create_browser_toolkit
  • React Agent - LangGraph's create_react_agent for tool orchestration
  • Full Browser Control - Navigate, click, type, extract, screenshot

Project Structure

langgraph-browser/
├── serverless.yml      # Serverless configuration
├── agent.py            # LangGraph agent with browser toolkit
├── pyproject.toml      # Python dependencies
├── Dockerfile          # Container configuration
├── test-invoke.py      # Test script
└── README.md           # This file

Quick Start

1. Deploy

serverless deploy

2. Note the Runtime Endpoint URL

After deployment, note the runtime endpoint URL from the output (the ARN is embedded in the URL path):

ai:
  agents:
    browserAgent: https://bedrock-agentcore.us-east-1.amazonaws.com/runtimes/arn:aws:bedrock-agentcore:us-east-1:123456789012:runtime/xxx/invocations

3. Test

export RUNTIME_ARN="arn:aws:bedrock-agentcore:us-east-1:123456789012:runtime/xxx"
python test-invoke.py

How It Works

Browser Toolkit

The example uses langchain_aws.tools.create_browser_toolkit which provides these tools:

ToolDescription
navigate_browserNavigate to a URL
click_elementClick on an element using CSS selector
type_textType text into an input field
extract_textExtract all text content from the page
extract_hyperlinksExtract all hyperlinks from the page
get_elementsGet elements matching a CSS selector
current_webpageGet the current page URL and title
navigate_backGo back to the previous page
take_screenshotTake a screenshot of the page
scroll_pageScroll the page in a direction
wait_for_elementWait for an element to appear

LangGraph Agent

from langchain.chat_models import init_chat_model
from langchain_aws.tools import create_browser_toolkit
from langgraph.prebuilt import create_react_agent

# Create toolkit
toolkit, browser_tools = create_browser_toolkit(region="us-east-1")

# Initialize chat model (default: global.anthropic.claude-sonnet-5, override via MODEL_ID)
llm = init_chat_model(
    MODEL_ID,
    model_provider="bedrock_converse",
)

# Create agent with browser tools
agent = create_react_agent(
    model=llm,
    tools=browser_tools,
)

# Run with session isolation
config = {"configurable": {"thread_id": "session-123"}}
result = await agent.ainvoke(
    {"messages": [{"role": "user", "content": "Navigate to example.com"}]},
    config=config
)

Session Isolation

Each thread_id gets its own browser session, enabling concurrent usage:

# Each thread gets its own browser session
config_user1 = {"configurable": {"thread_id": "user-1"}}
config_user2 = {"configurable": {"thread_id": "user-2"}}

Example Prompts

Navigation:

Navigate to https://example.com and tell me the main heading

Extract Links:

Navigate to https://aws.amazon.com and extract the first 5 hyperlinks

Page Analysis:

Navigate to https://python.org and describe the main sections

Form Interaction:

Navigate to https://google.com, type "AWS Lambda" in the search box

Dependencies

  • langchain-aws - AWS integrations for LangChain
  • langgraph - Agent orchestration
  • playwright - Browser automation (required by browser toolkit)
  • beautifulsoup4 - HTML parsing

Reference

  • LangChain AgentCore Browser Docs
  • AWS AgentCore Browser Documentation

Cleanup

serverless remove

Next Steps

  • Gateway Example - Add custom Lambda tools
  • Memory Example - Add conversation persistence
  • Browser Documentation - Full configuration reference

Contents

  • LangGraph Browser Example
  • Features
  • Project Structure
  • Quick Start
  • 1. Deploy
  • 2. Note the Runtime Endpoint URL
  • 3. Test
  • How It Works
  • Browser Toolkit
  • LangGraph Agent
  • Session Isolation
  • Example Prompts
  • Dependencies
  • Reference
  • Cleanup
  • Next Steps

Related

GuidesPluginsExamplesSlack CommunitySupport