langchain-anchorbrowser package gives LangChain agents tools that read web pages, take screenshots, and run AI web tasks in Anchor Browser.
It requires Python 3.10 or later, langchain-core 1.0 or later, and the anchorbrowser SDK 1.0 or later.
Quickstart
1
Install the packages
langchain provides create_agent. langchain-openai is the model provider for this example. You can use any LangChain chat model instead. The -U flag upgrades packages that are already installed.2
Set your API keys
Get an Anchor API key from the API keys page.
3
Run an agent
agent.py
The first book listed on https://books.toscrape.com is "A Light in the Attic".Call the tools directly
Each tool is a LangChain tool, so you can call it withinvoke, without an agent.
tools.py
Available tools
AnchorWebTaskToolKit bundles the three web task tools. AnchorTaskToolKit bundles the six task tools.
The screenshot and web task tools open a browser session for each call and close it when the call ends, even if the call fails. AnchorContentTool does not open a session.
The web task tools return only the task’s result. When the task fails, the result holds the reason for the failure.
Upgrade from 0.2
Version 0.3.0 requires LangChain 1.x and theanchorbrowser 1.x SDK, so the upgrade also moves your environment to those versions. To upgrade, run the pip install -U command from the quickstart.
In LangChain 1.x, LangGraph’s create_react_agent is deprecated. Build agents with create_agent from langchain.agents.
Version 0.3.0 changes these tool behaviors:
AnchorContentToolreturns the page’s HTML, not Markdown. It no longer has aformatoption, and it ignores aformatvalue.AnchorScreenshotToolreturns a base64 string. Decode it withbase64.b64decodebefore you save it.- The web task tools return the task result as a JSON string. The task tools return the API’s JSON response body.
- The screenshot and web task tools close the browser sessions that they open.

