Overview
The shell tool executes commands via asyncio subprocess with configurable timeout, working directory enforcement, and a multi-layer safety system that blocks dangerous operations.Tool
exec
Execute a shell command and return stdout/stderr.Shell command to execute
Timeout in seconds. Defaults to the configured shell_timeout.
Safety System
The shell tool implements a multi-layer deny system to prevent dangerous operations:Layer 1: Blocked Commands
Commands that are always dangerous regardless of arguments:- Filesystem destruction:
mkfs,mkfs.ext4,mkfs.xfs, etc. - System control:
shutdown,reboot,halt,poweroff - System actions:
systemctl poweroff/reboot/halt,init 0/6
Layer 2: Parsed rm Detection
The tool parsesrm commands to detect dangerous flag and target combinations:
- Normalizes short (
-rf) and long (--recursive --force) flags - Blocks
rmwith--no-preserve-rootand recursive flag - Blocks
rm -rfon critical paths:/,/home,/etc,/var,/usr,/bin,/lib,/boot,/root
Layer 3: Interpreter Escape Detection
Blocks inline code execution via-c flags for interpreters:
- Python:
python -c,python3 -c - Shells:
bash -c,sh -c,zsh -c - Others:
perl -c,ruby -c,node -c,eval
Layer 4: Regex Fallback
Pattern-based detection for operations that are hard to parse structurally: Fork bombs:Configuration
Timeout Settings
The default timeout is configured in the agent profile:Working Directory
All commands execute in the workspace directory (ctx.workspace_path). This cannot be changed via cd in the command string — use separate commands instead:
Error Handling
Timeout Errors
Non-Zero Exit Codes
Stderr and exit code are included in the output:Blocked Commands
Best Practices
- Use specific commands instead of complex shell scripts
- Set appropriate timeouts for long-running operations
- Check exit codes in returned output to detect failures
- Avoid sudo unless absolutely necessary (requires trust)
- Test commands in dry-run mode first when possible
Implementation
Defined ingrip/tools/shell.py. Uses:
asyncio.create_subprocess_shellfor async executionshlex.split()for token parsing with quote handling- Recursive safety checking up to 3 levels deep
- Quote-aware command splitting for chained commands (
;,&&,||)