Skip to content

feat: add browser tool powered by browser-use - #35844

Closed
laithrw wants to merge 1 commit into
anomalyco:devfrom
laithrw:feat/browser-tool
Closed

feat: add browser tool powered by browser-use#35844
laithrw wants to merge 1 commit into
anomalyco:devfrom
laithrw:feat/browser-tool

Conversation

@laithrw

@laithrwlaithrw commented Jul 8, 2026

Copy link
Copy Markdown

Issue for this PR

N/A

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Gives the agent a built-in browser tool, so it can open pages, click, run JavaScript, and pull content out of a real browser. The agent can only webfetch pages. This returns static HTML and means the agent cannot interact with anything.

The browser tool is useful, as the agent can now:

  • Test what it builds. After writing a web app, the agent can open it, click through it, read console errors, and fix what it finds.
  • Use the web. Docs, issue trackers, and dashboards are JS-rendered; webfetch sees an empty shell, and a browser sees the page.

The tool uses the Browser Use CLI (3.0). The CLI lets the model run short Python scripts inside a managed browser session.

Solution:

  • New BrowserTool in packages/opencode/src/tool/browser.ts. The model sends a short Python script using pre-imported helpers (new_tab, js, click_at_xy, …); the tool pipes it to browser-use over stdin and returns stdout. The CLI's daemon keeps the browser session alive between calls, so tabs and page state persist even though each call is a short-lived process.
  • Provisioning copies ripgrep (packages/core/src/ripgrep/binary.ts): use browser-use from PATH if the user has it; otherwise uvx browser-use; otherwise download the uv binary into Global.Path.bin (new UvBinary service, a near-mirror of RipgrepBinary) and run the package through it. Nothing runs or installs until the first browser call.
  • Wired through the existing gates: the tool registry, and the standard permission prompt on every call (browser permission, script shown as metadata). The tool description steers the model to keep preferring webfetch for static content.

How did you verify your code works?

  • bun test: new test/tool/browser.test.ts exercises the real execute path against stub binaries — stdin piping, output capture, nonzero exit codes, and both fallback tiers (uvx, provisioned uv). Registry test asserts the tool is exposed. All pass, typecheck and oxlint clean.
  • Manually via bun dev .: GPT-5.5 used the tool unprompted for a web task — navigated, extracted content with js(), reused page state across calls, and correctly switched to webfetch for static article pages.
  • Verified the uv release archive layouts (tar.gz nests uv-<target>/, Windows zips are flat) against the real 0.11.28 assets before writing the extract step.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

Hey! Your PR title add browser tool powered by browser-use doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actionsgithub-actionsBot added the needs:compliance This means the issue will auto-close after 2 hours. label Jul 8, 2026
@laithrwlaithrw changed the title add browser tool powered by browser-usefeat: add browser tool powered by browser-useJul 8, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on the search results, I found a related PR:

PR #7302: "Added in-built browser tools using playwright and a parallel playwright node process using spawn for bun-playwright issues"
#7302

Why it's related: This is a previous attempt to add browser tool functionality to the agent. However, that implementation used Playwright, while the current PR (#35844) uses browser-use. The new approach appears to be a replacement/improvement using a different tool and implementation strategy.

No other duplicate PRs found for the specific browser-use feature implementation.

@github-actionsgithub-actionsBot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 8, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@laithrw