Skip to content

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

Add Rust agent smoke example

Magnus Müller3509784bdb17
diff --git a/examples/rust_agent/basic.py b/examples/rust_agent/basic.py
new file mode 100644
index 000000000..97487fb28
--- /dev/null
+++ b/examples/rust_agent/basic.py
@@ -0,0 +1,26 @@
+"""Run the Rust-backed Browser Use Agent.
+
+Set BROWSER_USE_TERMINAL_BINARY when the terminal binary is not on PATH.
+Set BU_CDP_URL or BROWSER_USE_CDP_URL to attach to a remote Browser Use cloud browser.
+"""
+
+import asyncio
+import os
+
+from browser_use import Agent, BrowserSession
+
+
+async def main() -> None:
+ cdp_url = os.environ.get('BU_CDP_URL') or os.environ.get('BROWSER_USE_CDP_URL')
+ browser_session = BrowserSession(cdp_url=cdp_url) if cdp_url else None
+ task = os.environ.get('BU_TASK', 'Open https://example.com and report the page title.')
+ max_steps = int(os.environ.get('BU_MAX_STEPS', '20'))
+
+ agent = Agent(task=task, browser_session=browser_session)
+ history = await agent.run(max_steps=max_steps)
+ print(history.final_result() or '(no final result)')
+
+
+if __name__ == '__main__':
+ asyncio.run(main())
+