Shell Agent
Shell command execution tools for AI agents.
Prerequisites
- Python 3.10 or higher
- PraisonAI Agents package installed
- Basic understanding of shell commands
Shell Tools
Use Shell Tools to execute shell commands with AI agents.
Install Dependencies
First, install the required package:
Import Components
Import the necessary components:
Create Agent
Create a shell command agent:
Define Task
Define the shell task:
Run Agent
Initialize and run the agent:
Understanding Shell Tools
What are Shell Tools?
Shell Tools provide command-line capabilities for AI agents:
- Command execution
- Process management
- Output handling
- Error handling
- Environment management
Key Components
Shell Agent
Create specialized shell agents:
Shell Task
Define shell tasks:
Process Types
Sequential or parallel processing:
Shell Options
Customize shell operations:
Advanced Shell Management with Multiple Agents
Available Functions
Function Details
execute_command(command: str, cwd: Optional[str] = None, timeout: int = 30, shell: bool = False, env: Optional[Dict[str, str]] = None, max_output_size: int = 10000)
Safely executes shell commands:
- Timeout protection
- Output capture
- Error handling
- Environment control
- Working directory control
list_processes()
Lists running system processes:
- Process details
- Resource usage
- User information
- Performance metrics
kill_process(pid: int, force: bool = False)
Terminates system processes:
- Graceful termination
- Force kill option
- Error handling
- Access control
get_system_info()
Retrieves system information:
- CPU statistics
- Memory usage
- Disk space
- Platform details
- Boot time
Example Agent Configuration
Dependencies
The shell tools require the following package:
- psutil: For system and process information
This will be automatically installed when needed.
Error Handling
All functions include comprehensive error handling:
- Command execution errors
- Process access errors
- Permission errors
- Timeout errors
- Resource errors
Errors are handled consistently:
- Success cases return expected data type
- Error cases return error details in result
- All errors are logged for debugging
Common Use Cases
- System Monitoring:
- Process Management:
- Command Execution:
Best Practices
Common Patterns
Shell Command Pipeline
Was this page helpful?