-
Notifications
You must be signed in to change notification settings - Fork 169
browser use Integration
weego edited this page May 28, 2026
·
1 revision
The browser-use package can be wrapped as a LightAgent tool for browser-based data collection.
Use browser automation when no direct API is available, page interaction is required, or data is only visible after navigation. Prefer direct API tools when possible.
pip install browser-use langchain-openaibrowser-use 0.11 and newer may expect the LangChain LLM object to expose a provider attribute. Use this helper when needed:
def ensure_browser_use_provider(llm, provider: str = "openai"):
if hasattr(llm, "provider"):
return llm
try:
setattr(llm, "provider", provider)
except Exception:
object.__setattr__(llm, "provider", provider)
return llmimport os
from browser_use import Agent
from langchain_openai import ChatOpenAI
async def fetch_data_with_browser(task_description: str) -> str:
llm = ensure_browser_use_provider(ChatOpenAI(
model=os.getenv("BROWSER_USE_MODEL", "gpt-4.1-mini"),
api_key=os.getenv("OPENAI_API_KEY"),
base_url=os.getenv("OPENAI_BASE_URL", "https://api.openai.com/v1"),
))
browser_agent = Agent(
task=task_description,
llm=llm,
use_vision=False,
)
result = await browser_agent.run()
return result.final_result()Attach tool_info and pass it as a normal LightAgent tool.
- Keep browser tasks narrow and explicit.
- Use environment variables for keys.
- Expect browser tasks to be slower than API calls.
- Avoid letting arbitrary users describe unrestricted browser actions.
- Log task metadata, not secrets.
Reference example: example/08.browser_use.py.
LightAgent Wiki - see the repository, releases, and issues.
- Home
- Quick Start
- Core Concepts
- API Reference
- Examples Cookbook
- Migration Guide
- Tools
- Tool Generator
- Memory
- MCP
- Skills
- LightFlow
- Tree of Thought
- Self-Learning
- Multi-Agent
- Tracing and Debugging
- Langfuse Observability
- Model Providers
- browser-use Integration
- Testing and CI
- Deployment Guide
- Architecture
- Security
- Known Limitations
- FAQ
- FAQ 中文
- Roadmap
- Release Process
- Contributing