fix(tools): remove BrowserToolSet from package init to reduce downstream bundle size#2197
Open
fix(tools): remove BrowserToolSet from package init to reduce downstream bundle size#2197
Conversation
…size Remove the direct import of BrowserToolSet from openhands/tools/__init__.py to avoid forcing downstream consumers to bundle the browser-use package and its heavy dependencies. Users who need browser tools can still import directly from openhands.tools.browser_use. Related: OpenHands/OpenHands-CLI#527 The OpenHands-CLI had to include browser-use in its PyInstaller bundle because importing openhands.tools now transitively imports browser_use. This increased the binary size unnecessarily for CLI users who don't need browser automation features. Co-authored-by: openhands <openhands@all-hands.dev>
Contributor
API breakage checks (Griffe)Result: Passed |
Remove the assertion for BrowserToolSet from the top-level exports test since it's no longer exported from openhands.tools.__init__.py. Co-authored-by: openhands <openhands@all-hands.dev>
all-hands-bot
approved these changes
Feb 24, 2026
Collaborator
all-hands-bot
left a comment
There was a problem hiding this comment.
🟢 Good taste - Pragmatic fix for a real production problem. Follows Python best practices for optional dependencies.
Key insight: Heavy optional dependencies belong behind explicit imports, not transitively loaded at package level. This is exactly how it should be done.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Remove the direct import of
BrowserToolSetfromopenhands/tools/__init__.pyto avoid forcing downstream consumers to bundle thebrowser-usepackage and its heavy dependencies.Problem
The OpenHands-CLI project (PR #527) bumped the SDK to v1.11.5, which caused all binary tests to fail. The root cause was that
openhands/tools/__init__.pynow importsBrowserToolSetat the package level:This means any import of
openhands.toolstransitively imports thebrowser-usepackage and all its dependencies. For PyInstaller bundles (like OpenHands-CLI), this:browser-useand its dependency tree (playwright, etc.)browser-usewas excluded from the bundle (the previous workaround)The CLI had to work around this by including browser-use in the PyInstaller spec, but this is not ideal.
Solution
Remove
BrowserToolSetfrom the package-level__init__.py. Users who need browser tools can still import them directly:This is consistent with how other optional/heavy features should be handled - explicit imports for optional dependencies.
Changes
BrowserToolSetimport fromopenhands/tools/__init__.pyBrowserToolSetfrom__all__Backward Compatibility
This is a minor breaking change for code that imports
BrowserToolSetvia:The fix is straightforward:
Related
@malhotra5 can click here to continue refining the PR
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.12-nodejs22golang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:2a5ace5-pythonRun
All tags pushed for this build
About Multi-Architecture Support
2a5ace5-python) is a multi-arch manifest supporting both amd64 and arm642a5ace5-python-amd64) are also available if needed