Using AgentKit with Browserbase
Develop AI Agents that can browse the web
Browserbase provides managed headless browsers to enable Agents to browse the web autonomously.
There are two ways to use Browserbase with AgentKit:
- Create your own Browserbase tools: useful if you want to build simple actions on webpages with manual browser control.
- Use Browserbase’s Stagehand library as tools: a better approach for autonomous browsing and resilient scraping.
Building AgentKit tools using Browserbase
Creating AgentKit tools using the Browserbase TypeScript SDK is straightforward.
Install AgentKit
Within an existing project, install AgentKit, Browserbase and Playwright core:
2. Setup an AgentKit Newtork with an Agent
Create a Agent and its associated Network, for example a Reddit Search Agent:
Create a Browserbase tool
Let’s configure the Browserbase SDK and create a tool that can search Reddit:
Configure your BROWSERBASE_API_KEY
and BROWSERBASE_PROJECT_ID
in the
.env
file. You can find your API key and project ID from the Browserbase
dashboard.
We recommend building tools using Browserbase using Inngest’s step.run()
function. This ensures that the tool will only run once across multiple runs.
More information about using step.run()
can be found in the Multi steps tools page.
Example: Reddit Search Agent using Browserbase
You will find a complete example of a Reddit search agent using Browserbase in the Reddit Search Agent using Browserbase example:
Reddit Search Agent using Browserbase
This examples shows how to build tools using Browserbase to power a Reddit search agent.
AgentsToolsNetworkIntegrations
Enable autonomous browsing with Stagehand
Building AgentKit tools using Stagehand gives more autonomy to your agents.
Stagehand comes with 4 primary API that can be directly used as tools:
goto()
: navigate to a specific URLobserve()
: observe the current pageextract()
: extract data from the current pageact()
: take action on the current page
These methods can be easily directly be used as tools in AgentKit, enabling agents to browse the web autonomously.
Below is an example of a simple search agent that uses Stagehand to search the web:
These 4 AgentKit tools using Stagehand enables the Web Search Agent to browse the web autonomously.
The getStagehand()
helper function is used to retrieve the persisted instance created for the network execution (see full code below).
You will find the complete example on GitHub:
Simple Search Agent using Stagehand
This examples shows how to build tools using Stagehand to power a simple search agent.
AgentsToolsNetworkIntegrations