Uh oh!
There was an error while loading. Please reload this page.
feat: add browser tool powered by browser-use - #35844
Conversation
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
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" 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 No other duplicate PRs found for the specific |
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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:
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. |
Issue for this PR
N/A
Type of change
What does this PR do?
Gives the agent a built-in
browsertool, so it can open pages, click, run JavaScript, and pull content out of a real browser. The agent can onlywebfetchpages. This returns static HTML and means the agent cannot interact with anything.The
browsertool is useful, as the agent can now:webfetchsees 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:
BrowserToolinpackages/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 tobrowser-useover 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.packages/core/src/ripgrep/binary.ts): usebrowser-usefrom PATH if the user has it; otherwiseuvx browser-use; otherwise download the uv binary intoGlobal.Path.bin(newUvBinaryservice, a near-mirror ofRipgrepBinary) and run the package through it. Nothing runs or installs until the first browser call.browserpermission, script shown as metadata). The tool description steers the model to keep preferringwebfetchfor static content.How did you verify your code works?
bun test: newtest/tool/browser.test.tsexercises 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.bun dev .: GPT-5.5 used the tool unprompted for a web task — navigated, extracted content withjs(), reused page state across calls, and correctly switched towebfetchfor static article pages.uv-<target>/, Windows zips are flat) against the real 0.11.28 assets before writing the extract step.Screenshots / recordings
N/A
Checklist