Skip to content

Conversation

Copy link

Copilot AI commented Dec 19, 2025

Review and improvement of bp_tools.py per request, adding commonly needed file/path utilities and fixing run_os_command limitations.

Bug Fixes

  • run_os_command: Fixed input=""input=b"" for proper subprocess bytes handling
  • Added errors='replace' to UTF-8 decode for robustness

New run_os_command Shell Mode

Added use_shell parameter for commands requiring pipes, redirects, or chaining:

# Shell features now work
run_os_command('ls -la | grep .py', use_shell=True)
run_os_command('find / -name "*.py" 2>/dev/null | head -5', use_shell=True)

New Tools (18)

File Operations

  • move_file, rename_file, file_exists, directory_exists
  • join_files, delete_lines_from_file

Text/Content

  • find_and_replace_regex — pattern-based replacements
  • read_first_n_lines, read_last_n_lines — memory-efficient partial reads
  • count_occurrences_in_file, find_line_numbers

Path Utilities

  • get_file_extension, get_filename, get_parent_directory
  • get_absolute_path, path_join

Execution/Environment

  • run_python_file — mirrors existing run_php_file
  • get_working_directory, change_directory

Tests

Added 42 tests covering all new functionality. Total: 103 tests passing.

Original prompt

Hello super-intelligence!

Can you have a look please at src/smolagents/bp_tools.py ? I would like you to review this file, test the tools and add new tools or improove the existing tools as you see fit.

Feel free to show your skills!


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Review and improve BP tools in bp_tools.py Enhance bp_tools.py with new utilities and shell mode support Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants