Skip to content

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

added Laminar instrumentation

Robert Kimd3322a14cfa5
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 0dbf687fb..b1177cb74 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -20,6 +20,7 @@ from langchain_core.messages import (
BaseMessage,
SystemMessage,
)
+from lmnr import observe
from openai import RateLimitError
from PIL import Image, ImageDraw, ImageFont
from pydantic import BaseModel, ValidationError
@@ -338,7 +339,7 @@ class Agent:
parsed: AgentOutput = response['parsed']
if parsed is None:
- raise ValueError(f'Could not parse response.')
+ raise ValueError('Could not parse response.')
# cut the number of actions to max_actions_per_step
parsed.action = parsed.action[: self.max_actions_per_step]
@@ -420,6 +421,7 @@ class Agent:
)
)
+ @observe(name='agent.run')
async def run(self, max_steps: int = 100) -> AgentHistoryList:
"""Execute the task with maximum number of steps"""
try:
diff --git a/pyproject.toml b/pyproject.toml
index 81d2ecfd1..bc0a952c6 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -27,7 +27,8 @@ dependencies = [
"requests>=2.32.3",
"posthog>=3.7.0",
"playwright>=1.49.0",
- "setuptools>=75.8.0"
+ "setuptools>=75.8.0",
+ "lmnr[langchain]>=0.4.53"
]
[project.optional-dependencies]