Repository navigation
feat: Add BashTool and FileEditorTool subclasses for simplified tool initialization - #88
Merged
Merged
Conversation
…initialization - Create BashTool class that inherits from Tool and accepts working_dir/username parameters - Create FileEditorTool class that inherits from Tool with automatic executor initialization - Update all __init__.py files to export new tool classes (BashTool, FileEditorTool) - Simplify examples to use new tool classes instead of manual executor setup - Add advanced_tools_with_glob.py example showing both simplified and advanced patterns - Add comprehensive unit tests for both new tool classes - Update documentation to reflect the new simplified architecture This change eliminates the need for manual executor instantiation and set_executor() calls, reducing tool initialization from 5 lines to 2 lines in typical usage. Fixes #86 Co-authored-by: openhands <openhands@all-hands.dev>
- Rewrite GlobExecutor to use bash commands (find and shell globbing) instead of Python's glob module - Use bash executor for file pattern matching with proper sorting by modification time - Demonstrate proper executor reuse pattern in advanced example - Add security_risk parameter to ExecuteBashAction calls Co-authored-by: openhands <openhands@all-hands.dev>
- Replace GlobTool with GrepTool for content search using regex patterns
- Use bash grep commands instead of file pattern matching
- Support file filtering with include parameter (e.g., '*.py', '*.{ts,tsx}')
- Return matching lines with file paths and line numbers
- Demonstrate proper bash executor reuse pattern
- Update example conversation to search for 'class' keyword in Python files
- Rename file from advanced_tools_with_glob.py to advanced_tools_with_grep.py
Co-authored-by: openhands <openhands@all-hands.dev>
- Move BashTool class from tool.py to execute_bash/definition.py - Move FileEditorTool class from tool.py to str_replace_editor/definition.py - Update __init__.py files to import from definition.py instead of tool.py - Remove separate tool.py files to consolidate code organization - Add local imports to avoid circular import issues - All tests still pass and functionality remains unchanged This follows the cleaner pattern of keeping Tool definitions alongside their schemas and base tool definitions in a single file. Co-authored-by: openhands <openhands@all-hands.dev>
xingyaoww
enabled auto-merge (squash)
September 3, 2025 20:38
StressTestor
pushed a commit
to StressTestor/software-agent-sdk
that referenced
this pull request
Jun 1, 2026
…initialization (OpenHands#88) Co-authored-by: openhands <openhands@all-hands.dev>
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
This PR implements issue #86 by creating
BashToolandFileEditorToolsubclasses that inherit fromTool, providing a simplified API for tool initialization.Changes
Core Implementation
Created
BashToolclass inopenhands/tools/execute_bash/tool.pyTool[ExecuteBashAction, ExecuteBashObservation]working_dirand optionalusernameparametersBashExecutorinternallyCreated
FileEditorToolclass inopenhands/tools/str_replace_editor/tool.pyTool[StrReplaceEditorAction, StrReplaceEditorObservation]FileEditorExecutorinternallyAPI Improvements
__init__.pyfiles to include new tool classesExamples and Documentation
hello_world.py,hello_world_with_registry.py) to use simplified patternadvanced_tools_with_glob.py) demonstrating:.openhands/microagents/repo.mdto reflect new architectureTesting
BashToolandFileEditorToolBenefits
set_executor()callsTesting
All tests pass and pre-commit hooks are satisfied.
Fixes #86
@xingyaoww can click here to continue refining the PR