Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

cleanup

Matic Zavadlala433c476d18d
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index c4ce7864c..2dcad7d43 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -24,7 +24,6 @@ from langchain_core.messages import (
SystemMessage,
)
from lmnr import observe
-from memory_profiler import profile
from openai import RateLimitError
from PIL import Image, ImageDraw, ImageFont
from pydantic import BaseModel, ValidationError
@@ -268,7 +267,6 @@ class Agent:
@observe(name='agent.step', ignore_output=True, ignore_input=True)
@time_execution_async('--step')
- @profile
async def step(self, step_info: Optional[AgentStepInfo] = None) -> None:
"""Execute one step of the task"""
logger.info(f'📍 Step {self.n_steps}')
@@ -531,7 +529,6 @@ class Agent:
)
@observe(name='agent.run', ignore_output=True)
- @profile
async def run(self, max_steps: int = 100) -> AgentHistoryList:
"""Execute the task with maximum number of steps"""
try:
diff --git a/browser_use/browser/context.py b/browser_use/browser/context.py
index c56e50db5..80cdbbb02 100644
--- a/browser_use/browser/context.py
+++ b/browser_use/browser/context.py
@@ -13,7 +13,6 @@ import uuid
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Optional, TypedDict
-from memory_profiler import profile
from playwright.async_api import Browser as PlaywrightBrowser
from playwright.async_api import (
BrowserContext as PlaywrightBrowserContext,
@@ -598,7 +597,6 @@ class BrowserContext:
return await page.evaluate(script)
@time_execution_sync('--get_state') # This decorator might need to be updated to handle async
- @profile
async def get_state(self) -> BrowserState:
"""Get the current state of the browser"""
await self._wait_for_page_and_frames_load()
diff --git a/browser_use/dom/service.py b/browser_use/dom/service.py
index 8aebc9f50..4255de97f 100644
--- a/browser_use/dom/service.py
+++ b/browser_use/dom/service.py
@@ -3,7 +3,6 @@ import logging
from importlib import resources
from typing import Optional
-from memory_profiler import profile
from playwright.async_api import Page
from browser_use.dom.history_tree_processor.view import Coordinates
@@ -29,7 +28,6 @@ class DomService:
# region - Clickable elements
- @profile
async def get_clickable_elements(
self,
highlight_elements: bool = True,
@@ -42,7 +40,6 @@ class DomService:
return dom_state
- # @profile
async def _build_dom_tree(
self,
highlight_elements: bool,
diff --git a/examples/simple.py b/examples/simple.py
index cd3c34c7e..c0f22de0b 100644
--- a/examples/simple.py
+++ b/examples/simple.py
@@ -2,7 +2,6 @@ import asyncio
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
-from memory_profiler import profile
from browser_use import Agent
@@ -18,7 +17,6 @@ task = 'Go to apple.com and find the latest iphone model and return the link so
agent = Agent(task=task, llm=llm)
-@profile
async def main():
await agent.run()