Browser Use Tools: Give Your Agent Custom Actions
Tools are how a model touches the world. In a browser agent, the tool design decides what the model can do, how much each step costs and how mistakes show up. browser-use is a good case study, because it went from 10 tools to 29 and back down to one between 2024 and 2026. This part shows why, and how to add your own tools to 1.0.9.

Problem: a fixed menu always misses something
In 0.x, every capability was an action in a registry. The model picked one per step from a menu that came with JSON schemas. In 0.13.14, tools/service.py registers actions such as search, navigate, go_back, wait, click, input, upload_file, switch, close, extract, search_page, find_elements, scroll, send_keys, find_text, screenshot, save_as_pdf, dropdown_options, select_dropdown, write_file, replace_file, read_file, evaluate and done. Our count of registered actions in that file was 27. The launch post counts 24 for 0.13.14; it may count differently.
Each new site quirk meant a new action or a new parameter. And every action's schema rode along in every prompt.
The launch post gives the full count over time:
Tools offered to the model, by versionData from the sources listed below.
Solution in 1.0: one code tool, many helpers
1.0 offers the model python plus the two finish tools. The helpers that used to be actions are now plain functions already imported in the REPL. The system prompt in agent/prompt.py lists them: new_tab, goto_url, wait_for_load, page_info, js, cdp, drain_events, click_at_xy, type_text, press_key, scroll, screenshot, wait_for_element, wait_for_network_idle, upload_file and http_get.
The difference is composition. One cell can open a page, read 50 rows, filter them in Python and click the third match. In 0.x that was many steps, each a model request.
The team reports the same effect outside browser-use. In "The Bitter Lesson of Browser Agents" they describe replacing 12 browser tools in the Hermes agent with one browser_exec tool. Mean tokens dropped 60% with Opus 4.8 and 66% with Kimi K3, over 18 of 18 runs. Those are their numbers on their tasks.
flowchart LR subgraph v0 [0.x: one action per step] A1[navigate] --> A2[scroll] --> A3[extract] --> A4[click] end subgraph v1 [1.0: one cell per step] B1["new_tab(url); rows = js(...); hit = [r for r in rows if ...]; click_at_xy(*hit[2])"] end
Problem: some things should not be code the model writes
Code is flexible, but not everything belongs in model-written code:
- calls that need your secrets or your database,
- side effects you want logged and typed, like "save this lead to the CRM",
- tasks where the model keeps failing in prose but succeeds with a clear tool.
The launch post has a clean example of the last one. On an hCaptcha test, a prose instruction in the prompt passed 0 of 3 runs, while a dedicated solve_captcha tool passed 6 of 6. (That tool runs on Browser Use's cloud. Part 8 covers what that does and does not mean.)
Solution: @tools.action for your own typed tools
You add a tool with a decorator. The function's type hints become the JSON schema the model sees. This full script ran against real headless Chromium. The "model" is scripted (see Part 4), but the tool registry, schemas and calls are the real browser-use 1.0.9 code path:
pythonimport asyncio, json from pydantic_ai.messages import ModelResponse, ToolCallPart, ModelRequest, ToolReturnPart from pydantic_ai.models.function import FunctionModel, AgentInfo from browser_use import Agent, Browser, Tools tools = Tools() NOTES = [] @tools.action('Save one finding to the research notebook. Use it once per fact.') def save_note(title: str, url: str) -> str: NOTES.append({'title': title, 'url': url}) return f'saved note {len(NOTES)}' URL = 'https://en.wikipedia.org/wiki/Headless_browser' step = {'i': 0} def model(messages, info: AgentInfo): i = step['i']; step['i'] += 1 for p in getattr(messages[-1], 'parts', []): if isinstance(p, ToolReturnPart): print(f'<- {p.tool_name} returned: {str(p.content)[:160]}') if i == 0: for t in info.function_tools: print('TOOL', t.name, '|', t.description[:60], '|', json.dumps(t.parameters_json_schema)) code = f"new_tab('{URL}'); wait_for_load()\nprint(js(\"document.querySelector('h1').textContent\"))" return ModelResponse(parts=[ToolCallPart('python', {'code': code})]) if i == 1: title = str(messages[-1].parts[0].content[0]).strip() # what the cell printed return ModelResponse(parts=[ToolCallPart('save_note', {'title': title, 'url': URL})]) return ModelResponse(parts=[ToolCallPart('finish', {'result': 'saved', 'success': True})]) async def main(): agent = Agent('Save the article title as a note', llm=FunctionModel(model), browser=Browser('chromium'), tools=tools, judge=False) r = await agent.run(max_steps=6) print('STATUS', r.status, 'STEPS', r.number_of_steps(), 'NOTES', NOTES) asyncio.run(main())
Real output (log lines trimmed to the agent's own):
textINFO [browser_use.agent.loop] step 1: new_tab('https://en.wikipedia.org/wiki/Headless_browser'); wait_for_load() INFO [browser_use.agent.service] completed in 3 steps, 7s TOOL python | Run Python in the persistent REPL (browser-harness helpers a | {"additionalProperties": false, "properties": {"code": {"type": "string"}}, "required": ["code"], "type": "object"} TOOL save_note | Save one finding to the research notebook. Use it once per f | {"additionalProperties": false, "properties": {"title": {"type": "string"}, "url": {"type": "string"}}, "required": ["title", "url"], "type": "object"} <- python returned: ['Headless browser\n'] <- save_note returned: saved note 1 STATUS completed STEPS 3 NOTES [{'title': 'Headless browser', 'url': 'https://en.wikipedia.org/wiki/Headless_browser'}]
What this proves:
- Your tool sits next to
pythonin the model's tool list, with a strict schema built fromtitle: str, url: str. - The decorator's string becomes the description. Write it like an instruction, because the model reads it as one.
- The tool's return value goes straight back to the model as the tool result.
sequenceDiagram participant M as Model participant L as Agent loop participant R as REPL + Chrome participant T as save_note (your code) M->>L: python cell: open page, print h1 L->>R: run cell R-->>L: Headless browser L-->>M: tool result M->>L: save_note(title, url) L->>T: call with validated args T-->>L: saved note 1 L-->>M: tool result M->>L: finish(result)
Problem: what happens when your tool fails?
Tools fail. A good harness turns the failure into feedback instead of a crash. The migration guide says a raised exception becomes ActionResult(error=...). We checked it:
pythonimport asyncio from pydantic_ai.messages import ModelResponse, ToolCallPart, ToolReturnPart, RetryPromptPart from pydantic_ai.models.function import FunctionModel, AgentInfo from browser_use import Agent, Browser, Tools tools = Tools() @tools.action('Look up a stock price by ticker.') def price(ticker: str) -> str: if ticker != 'ACME': raise ValueError(f'unknown ticker {ticker!r}, try ACME') return 'ACME: 42.00 (demo data)' step = {'i': 0} def model(messages, info: AgentInfo): i = step['i']; step['i'] += 1 for p in getattr(messages[-1], 'parts', []): if isinstance(p, (ToolReturnPart, RetryPromptPart)): print(f'<- {type(p).__name__} for {p.tool_name}: {p.content!s:.200}') calls = [ToolCallPart('price', {'ticker': 'XYZ'}), ToolCallPart('price', {'ticker': 'ACME'})] if i < 2: return ModelResponse(parts=[calls[i]]) return ModelResponse(parts=[ToolCallPart('finish', {'result': 'done', 'success': True})]) async def main(): r = await Agent('Get the ACME price', llm=FunctionModel(model), browser=Browser('chromium'), tools=tools, judge=False).run(max_steps=5) print('STATUS', r.status, 'STEPS', r.number_of_steps()) asyncio.run(main())
Real output:
textINFO [browser_use.agent.service] completed in 3 steps, 0s <- ToolReturnPart for price: extracted_content=None error="ValueError: unknown ticker 'XYZ', try ACME" <- ToolReturnPart for price: ACME: 42.00 (demo data) STATUS completed STEPS 3
The exception text reached the model as a normal tool result with an error field. The run did not crash. So write error messages for the model: say what was wrong and what to try. "unknown ticker 'XYZ', try ACME" is far more useful than a stack trace.
What changed for 0.x custom actions
If you are porting 0.x code, the migration guide lists what moved:
| 0.x | 1.0.9 |
|---|---|
Controller | Tools (same class) |
@registry.action(...) with a param model | @tools.action('description') on a plain function |
Injected parameters like browser_session, page_url, cdp_client | Removed. Actions get only what the model passes |
@tools.action(domains=...) | Removed. Use Browser(allowed_domains=...) |
| MCP client inside the controller | Call the MCP server from a plain @tools.action function |
The last row matters. A tool can no longer reach into the browser on its own. If a tool needs page data, the model reads it in a cell and passes it in, as save_note did above. That keeps the tool's inputs visible in the transcript.
The same idea outside the agent: CLI and MCP
browser-use 1.0 also exposes the browser to other agents. browser-use --cli-mcp serves MCP tools named browser_exec (Python with the browser-harness helpers), browser_screenshot and browser_login. The old 0.x MCP tools like browser_click and browser_navigate now return an error that points to browser_exec. So even as an MCP server, the design is "one code tool".
Try this
Add a tool with a vague description, like @tools.action('notes'), and one with a precise one. Run a real model on the same task with each. Count how often it calls the tool correctly. The description is part of your prompt.
Sources
- browser-use 1.0.9 source,
browser_use/agent/prompt.py(helper list) and theToolsclass: https://github.com/browser-use/browser-use - browser-use 0.13.14 package (
tools/service.pyaction registry): https://pypi.org/project/browser-use/0.13.14/ - MIGRATING.md, tools table and CLI/MCP section: https://github.com/browser-use/browser-use/blob/main/MIGRATING.md
- Browser Use 1.0 launch post (tool counts, hCaptcha 0/3 vs 6/6): https://browser-use.com/posts/browser-use-1-0
- The Bitter Lesson of Browser Agents (Hermes, 12 tools to browser_exec): https://browser-use.com/posts/bitter-lesson-browser-agents
- Page used: https://en.wikipedia.org/wiki/Headless_browser
