Browser Agents
AI-powered agents that autonomously complete browser tasks
What is a Browser Agent?#
A Browser Agent combines:
- Large Language Models (LLMs) for reasoning and decision-making
- Browser Sessions for executing actions
- Vision capabilities to understand web pages
- Autonomous planning to complete multi-step tasks
Unlike scripted automation, agents can adapt to changes, handle unexpected scenarios, and complete tasks without predefined workflows.
Quick Start#
from notte_sdk import NotteClient
client = NotteClient()
with client.Session(open_viewer=True) as session:
agent = client.Agent(session=session, max_steps=5)
response = agent.run(
task="Browse on Notte docs and book a demo for me",
url="https://docs.notte.cc"
)
print(response)import { NotteClient } from 'notte-sdk';
const client = new NotteClient({
apiKey: process.env.NOTTE_API_KEY,
});
await client.Session({ open_viewer: true }).use(async (session) => {
const agent = client.Agent({ session, max_steps: 5 });
const response = await agent.run({
task: 'Browse on Notte docs and book a demo for me',
url: 'https://docs.notte.cc',
});
console.log(response);
});Tip: Agents run within browser sessions. Use context managers to ensure sessions are automatically stopped when done. This prevents orphaned sessions and unexpected costs.
How Agents Work#
1. Observation#
The agent observes the current page state: visible elements and their properties, interactive components (buttons, forms, links), text content and structure, current URL and page metadata.
2. Reasoning#
Using the LLM, the agent understands the current page, plans the next action, decides which element to interact with, and determines when the task is complete.
3. Action#
The agent executes browser actions: navigate to URLs, click buttons and links, fill forms, extract data, scroll and interact with dynamic content.
4. Iteration#
This cycle repeats until the task is successfully completed, the maximum steps are reached, or an error occurs that can't be resolved.
Agents vs Scripted Automation#
Both agents and scripted automation run on browser sessions, the cloud browser infrastructure. The difference is how you control what happens in that session.
| Aspect | Scripted Automation | Agent |
|---|---|---|
| Control | You write the code | AI decides each step |
| Flexibility | Fixed workflow | Adapts to changes |
| Speed | Fast (direct execution) | Slower (LLM reasoning per step) |
| Cost | Browser minutes only | Browser minutes + LLM calls |
| Reliability | Deterministic | Can vary based on page state |
| Use Case | Known, stable workflows | Unknown or dynamic workflows |
Use scripted automation when: you know the exact steps to take, speed and cost are critical, or the target pages rarely change.
Use agents when: you don't know the exact steps, pages change frequently, or you need intelligent decision-making.
Note: You can combine both approaches: use an agent to figure out a workflow, then convert it to a function for faster, cheaper repeated execution.
Agent Capabilities#
-
Structured Output — Get type-safe responses using Pydantic models
-
Vaults & Personas — Use credentials and identities in automations
-
Replay & Debugging — Debug with MP4 replays of agent execution
-
Agent Fallback — Automatic recovery from script failures
Key Concepts#
Natural Language Tasks#
with client.Session() as session:
agent = client.Agent(session=session)
agent.run(task="Find the cheapest laptop under $1000 and add it to cart")Structured Output#
from pydantic import BaseModel
class ContactInfo(BaseModel):
email: str
phone: str | None
with client.Session() as session:
agent = client.Agent(session=session)
result = agent.run(task="Extract contact information", response_format=ContactInfo)Step Limits#
with client.Session() as session:
agent = client.Agent(session=session)
agent.run(
task="Find and summarize the top 5 AI news from today",
max_steps=20, # Limit to 20 actions
)Error Handling#
agent = client.Agent(session=session)
result = agent.run(task="Complete task")
if result.success:
print(result.answer)
else:
print(f"Agent failed: {result.answer}")Next Steps#
-
Agent Lifecycle — Create, manage, and stop agents
-
Agent Configuration — All configuration options
-
Structured Output — Get typed responses from agents
-
Convert to Functions — Turn agent runs into reusable code