Skip to content

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

remove `run` command and agent infrastructure from CLI

ShawnPana0dc2fc5a6fb7
diff --git a/browser_use/skill_cli/README.md b/browser_use/skill_cli/README.md
index f491c8e75..7efed3f77 100644
--- a/browser_use/skill_cli/README.md
+++ b/browser_use/skill_cli/README.md
@@ -190,20 +190,6 @@ browser-use python --reset # Clear namespace
browser-use python --file script.py # Run Python file
```
-## Agent Tasks
-
-Run AI-powered browser automation tasks.
-
-### Local Mode
-```bash
-browser-use run "Fill the contact form with test data"
-browser-use run "Extract all product prices" --max-steps 50
-browser-use run "task" --llm gpt-4o # Specify LLM model
-```
-
-Requires an LLM API key (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, etc.).
-
-
## Cloud API
Generic REST passthrough to the Browser-Use Cloud API.
@@ -277,7 +263,6 @@ browser-use open https://abc.trycloudflare.com
| `--headed` | Show browser window |
| `--profile [NAME]` | Use real Chrome (bare `--profile` uses "Default") |
| `--json` | Output as JSON |
-| `--api-key KEY` | Override API key |
| `--mcp` | Run as MCP server via stdin/stdout |
## Examples
diff --git a/browser_use/skill_cli/__init__.py b/browser_use/skill_cli/__init__.py
index 72d560e0d..dd6f24c90 100644
--- a/browser_use/skill_cli/__init__.py
+++ b/browser_use/skill_cli/__init__.py
@@ -8,7 +8,6 @@ Usage:
browser-use click 5
browser-use type "Hello World"
browser-use python "print(browser.url)"
- browser-use run "Fill the contact form"
browser-use close
"""
diff --git a/browser_use/skill_cli/commands/__init__.py b/browser_use/skill_cli/commands/__init__.py
index a94353af7..37e4849ad 100644
--- a/browser_use/skill_cli/commands/__init__.py
+++ b/browser_use/skill_cli/commands/__init__.py
@@ -1,7 +1,6 @@
"""Command handlers for browser-use CLI."""
from browser_use.skill_cli.commands import (
- agent,
browser,
doctor,
python_exec,
@@ -9,7 +8,6 @@ from browser_use.skill_cli.commands import (
)
__all__ = [
- 'agent',
'browser',
'doctor',
'python_exec',
diff --git a/browser_use/skill_cli/commands/agent.py b/browser_use/skill_cli/commands/agent.py
deleted file mode 100644
index 7325995a7..000000000
--- a/browser_use/skill_cli/commands/agent.py
+++ /dev/null
@@ -1,159 +0,0 @@
-"""Agent task command handler."""
-
-import logging
-import os
-from typing import Any
-
-from browser_use.skill_cli.sessions import SessionInfo
-
-logger = logging.getLogger(__name__)
-
-
-async def handle(session: SessionInfo, params: dict[str, Any]) -> Any:
- """Handle agent run command.
-
- Runs a task using the local browser-use agent.
- """
- task = params.get('task')
- if not task:
- return {'success': False, 'error': 'No task provided'}
-
- return await _handle_local_task(session, params)
-
-
-async def _handle_local_task(session: SessionInfo, params: dict[str, Any]) -> Any:
- """Handle task execution locally with browser-use agent."""
- task = params['task']
- max_steps = params.get('max_steps')
- model = params.get('llm') # Optional model override
-
- try:
- # Import agent and LLM
- from browser_use.agent.service import Agent
-
- # Try to get LLM from environment (with optional model override)
- llm = await get_llm(model=model)
- if llm is None:
- if model:
- return {
- 'success': False,
- 'error': f'Could not initialize model "{model}". '
- f'Make sure the appropriate API key is set (OPENAI_API_KEY, ANTHROPIC_API_KEY, or GOOGLE_API_KEY).',
- }
- return {
- 'success': False,
- 'error': 'No LLM configured. Set OPENAI_API_KEY, ANTHROPIC_API_KEY, or GOOGLE_API_KEY',
- }
-
- # Create and run agent
- agent = Agent(
- task=task,
- llm=llm,
- browser_session=session.browser_session,
- )
-
- logger.info(f'Running local agent task: {task}')
- run_kwargs = {}
- if max_steps is not None:
- run_kwargs['max_steps'] = max_steps
- result = await agent.run(**run_kwargs)
-
- # Extract result info
- final_result = result.final_result() if result else None
-
- return {
- 'success': True,
- 'task': task,
- 'steps': len(result) if result else 0,
- 'result': str(final_result) if final_result else None,
- 'done': result.is_done() if result else False,
- }
-
- except Exception as e:
- logger.exception(f'Local agent task failed: {e}')
- return {
- 'success': False,
- 'error': str(e),
- 'task': task,
- }
-
-
-def _get_verified_models() -> dict[str, set[str]]:
- """Extract verified model names from SDK sources of truth."""
- import typing
-
- from anthropic.types.model_param import ModelParam
- from openai.types.shared.chat_model import ChatModel
-
- from browser_use.llm.google.chat import VerifiedGeminiModels
-
- # OpenAI: ChatModel is a Literal type
- openai_models = set(typing.get_args(ChatModel))
-
- # Anthropic: ModelParam is Union[Literal[...], str] - extract the Literal
- anthropic_literal = typing.get_args(ModelParam)[0]
- anthropic_models = set(typing.get_args(anthropic_literal))
-
- # Google: VerifiedGeminiModels Literal
- google_models = set(typing.get_args(VerifiedGeminiModels))
-
- return {
- 'openai': openai_models,
- 'anthropic': anthropic_models,
- 'google': google_models,
- }
-
-
-_VERIFIED_MODELS: dict[str, set[str]] | None = None
-
-
-def _get_provider_for_model(model: str) -> str | None:
- """Determine the provider by checking SDK verified model lists."""
- global _VERIFIED_MODELS
- if _VERIFIED_MODELS is None:
- _VERIFIED_MODELS = _get_verified_models()
-
- for provider, models in _VERIFIED_MODELS.items():
- if model in models:
- return provider
-
- return None
-
-
-def get_llm(model: str | None = None) -> Any:
- """Get LLM instance from environment configuration.
-
- Args:
- model: Optional model name to use. If provided, will instantiate
- the appropriate provider for that model. If not provided,
- auto-detects from available API keys.
-
- Supported providers: OpenAI, Anthropic, Google.
- Model names are validated against each SDK's verified model list.
- """
- from browser_use.llm import ChatAnthropic, ChatGoogle, ChatOpenAI
-
- if model:
- provider = _get_provider_for_model(model)
-
- if provider == 'openai':
- return ChatOpenAI(model=model)
- elif provider == 'anthropic':
- return ChatAnthropic(model=model)
- elif provider == 'google':
- return ChatGoogle(model=model)
- else:
- logger.warning(f'Unknown model: {model}. Not in any verified model list.')
- return None
-
- # No model specified - auto-detect from available API keys
- if os.environ.get('OPENAI_API_KEY'):
- return ChatOpenAI(model='o3')
-
- if os.environ.get('ANTHROPIC_API_KEY'):
- return ChatAnthropic(model='claude-sonnet-4-0')
-
- if os.environ.get('GOOGLE_API_KEY'):
- return ChatGoogle(model='gemini-flash-latest')
-
- return None
diff --git a/browser_use/skill_cli/commands/browser.py b/browser_use/skill_cli/commands/browser.py
index 658808298..34a97d077 100644
--- a/browser_use/skill_cli/commands/browser.py
+++ b/browser_use/skill_cli/commands/browser.py
@@ -246,7 +246,7 @@ async def handle(action: str, session: SessionInfo, params: dict[str, Any]) -> A
query = params['query']
# This requires LLM integration
# For now, return a placeholder
- return {'query': query, 'error': 'extract requires agent mode - use: browser-use run "extract ..."'}
+ return {'query': query, 'error': 'extract is not yet implemented'}
elif action == 'hover':
index = params['index']
diff --git a/browser_use/skill_cli/daemon.py b/browser_use/skill_cli/daemon.py
index 7f40190bf..9fa33d5f5 100644
--- a/browser_use/skill_cli/daemon.py
+++ b/browser_use/skill_cli/daemon.py
@@ -137,7 +137,7 @@ class Daemon:
},
}
- from browser_use.skill_cli.commands import agent, browser, python_exec
+ from browser_use.skill_cli.commands import browser, python_exec
# Get or create the single session
session = await self._get_or_create_session()
@@ -147,8 +147,6 @@ class Daemon:
result = await browser.handle(action, session, params)
elif action == 'python':
result = await python_exec.handle(session, params)
- elif action == 'run':
- result = await agent.handle(session, params)
else:
return {'id': req_id, 'success': False, 'error': f'Unknown action: {action}'}
diff --git a/browser_use/skill_cli/main.py b/browser_use/skill_cli/main.py
index fdbc487fe..34e1c7f89 100755
--- a/browser_use/skill_cli/main.py
+++ b/browser_use/skill_cli/main.py
@@ -177,7 +177,6 @@ def _is_daemon_alive() -> bool:
def ensure_daemon(
headed: bool,
profile: str | None,
- api_key: str | None,
*,
explicit_config: bool = False,
) -> None:
@@ -213,8 +212,6 @@ def ensure_daemon(
# Set up environment
env = os.environ.copy()
- if api_key:
- env['BROWSER_USE_API_KEY'] = api_key
# Start daemon as background process
if sys.platform == 'win32':
@@ -283,13 +280,7 @@ def build_parser() -> argparse.ArgumentParser:
# Build epilog
epilog_parts = []
- epilog_parts.append("""Local Mode (default):
- browser-use run "Fill the form" # Uses local browser + your API keys
- browser-use run "task" --llm gpt-4o # Specify model (requires API key)
- browser-use open https://example.com""")
-
- epilog_parts.append("""
-Cloud API:
+ epilog_parts.append("""Cloud API:
browser-use cloud login <api-key> # Save API key
browser-use cloud v2 GET /browsers # List browsers
browser-use cloud v2 POST /tasks '{...}' # Create task
@@ -298,6 +289,7 @@ Cloud API:
epilog_parts.append("""
Setup:
+ browser-use open https://example.com # Navigate to URL
browser-use install # Install Chromium browser
browser-use init # Generate template file""")
@@ -318,7 +310,6 @@ Setup:
help='Use real Chrome with profile (bare --profile uses "Default")',
)
parser.add_argument('--json', action='store_true', help='Output as JSON')
- parser.add_argument('--api-key', help='LLM API key')
parser.add_argument('--mcp', action='store_true', help='Run as MCP server (JSON-RPC via stdin/stdout)')
parser.add_argument('--template', help='Generate template file (use with --output for custom path)')
@@ -512,16 +503,6 @@ Setup:
p.add_argument('--reset', action='store_true', help='Reset Python namespace')
p.add_argument('--vars', action='store_true', help='Show defined variables')
- # -------------------------------------------------------------------------
- # Agent Tasks
- # -------------------------------------------------------------------------
-
- p = subparsers.add_parser('run', help='Run agent task (requires API key)')
- p.add_argument('task', help='Task description')
- p.add_argument('--max-steps', type=int, help='Maximum steps')
- # Model selection
- p.add_argument('--llm', help='LLM model (gpt-4o, claude-sonnet-4-20250514, gemini-2.0-flash)')
-
# -------------------------------------------------------------------------
# Tunnel Commands
# -------------------------------------------------------------------------
@@ -732,18 +713,14 @@ def main() -> int:
print('No active browser session')
return 0
- # Set API key in environment if provided
- if args.api_key:
- os.environ['BROWSER_USE_API_KEY'] = args.api_key
-
# Ensure daemon is running
# Only restart on config mismatch if the user explicitly passed config flags
explicit_config = any(flag in sys.argv for flag in ('--headed', '--profile'))
- ensure_daemon(args.headed, args.profile, args.api_key, explicit_config=explicit_config)
+ ensure_daemon(args.headed, args.profile, explicit_config=explicit_config)
# Build params from args
params = {}
- skip_keys = {'command', 'headed', 'json', 'api_key'}
+ skip_keys = {'command', 'headed', 'json'}
for key, value in vars(args).items():
if key not in skip_keys and value is not None:
diff --git a/skills/browser-use/SKILL.md b/skills/browser-use/SKILL.md
index 7cbba789c..a6257a6fe 100644
--- a/skills/browser-use/SKILL.md
+++ b/skills/browser-use/SKILL.md
@@ -69,10 +69,6 @@ browser-use wait text "Success" # Wait for text
# Session
browser-use close # Close browser session
-
-# AI Agent
-browser-use run "Fill the contact form" # Run local agent
-browser-use run "task" --llm gpt-4o # Specify model
```
## Commands
@@ -165,14 +161,6 @@ The Python session maintains state across commands. The `browser` object provide
- `browser.screenshot(path)`, `browser.scroll(direction, amount)` — visual
- `browser.wait(seconds)`, `browser.extract(query)` — utilities
-### Agent Tasks
-```bash
-browser-use run "Fill the contact form with test data" # AI agent
-browser-use run "Extract all product prices" --max-steps 50
-browser-use run "task" --llm gpt-4o # Specify LLM model
-browser-use run "task" --llm claude-sonnet-4-20250514
-```
-
### Cloud API
```bash
browser-use cloud login <api-key> # Save API key
diff --git a/skills/remote-browser/SKILL.md b/skills/remote-browser/SKILL.md
index 58b7e0268..80fbb55bb 100644
--- a/skills/remote-browser/SKILL.md
+++ b/skills/remote-browser/SKILL.md
@@ -67,10 +67,6 @@ browser-use wait text "Success" # Wait for text
# Session
browser-use close # Close browser session
-
-# AI Agent
-browser-use run "Fill the contact form" # Run local agent
-browser-use run "task" --llm gpt-4o # Specify model
```
## Commands
@@ -161,14 +157,6 @@ The Python session maintains state across commands. The `browser` object provide
- `browser.screenshot(path)`, `browser.scroll(direction, amount)` — visual
- `browser.wait(seconds)`, `browser.extract(query)` — utilities
-### Agent Tasks
-```bash
-browser-use run "Fill the contact form with test data" # AI agent
-browser-use run "Extract all product prices" --max-steps 50
-browser-use run "task" --llm gpt-4o # Specify LLM model
-browser-use run "task" --llm claude-sonnet-4-20250514
-```
-
### Tunnels
```bash
browser-use tunnel <port> # Start tunnel (returns URL)