Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: run command tool. resolves #252 #356

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

hiromesh
Copy link

feat: Execute Command Tool for Agent

Description

Implemented a robust shell command execution tool system for the AgentUniverse framework. This enhancement enables agents to execute local system commands either synchronously or asynchronously and query their status, providing a solid foundation for agent-driven system operations, file manipulation, and external process interaction. The implementation supports both blocking and non-blocking command execution with comprehensive result tracking.

Features

Command Execution Tool Implementation (run_command_tool.py):

  • Thread-based execution management with unique thread identifiers
  • Support for both synchronous (blocking) and asynchronous (non-blocking) execution
  • Shell command support with proper subprocess integration
  • Robust error handling and status tracking
  • Automatic handling of oversized stdout/stderr to prevent token limit issues

Command Status Tool Implementation (command_status_tool.py):

  • Query execution results of previous commands by thread ID
  • Status retrieval for both completed and running commands
  • Proper error handling for invalid thread IDs

Testing Implementation:

  • Unit tests for both synchronous and asynchronous command execution
  • Error handling verification for invalid commands
  • Special character escape handling tests
  • Asynchronous command completion verification
  • Command status retrieval testing
  • image
  • image

Technical Details

  • Thread-based execution model using Python's threading module
  • Subprocess management with shell=True for proper command interpretation
  • JSON output formatting for consistent API response structure

Dependencies

  • Python's subprocess module
  • Python's threading module
  • JSON for result formatting

Checklist

  • [✓] Code follows project's coding style
  • [✓] Added comprehensive test cases
  • [✓] All tests pass
  • [✓] Added proper error handling
  • [✓] Implemented both synchronous and asynchronous execution
  • [✓] Proper result tracking and formatting

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.

1 participant