Skip to main content
The ShellTool allows agents to execute shell commands in a controlled environment with timeout support and custom execution contexts.

Class Signature

Parameters

executor
Callable[[ShellCommandRequest], str]
default:"None"
Custom command executor function. If not provided, uses the default _shell_executor that runs commands using subprocess.run.
verbose
bool
default:"False"
Enable verbose output to print commands before execution and results after completion.
*args
tuple
Additional positional arguments passed to BaseTool.
**kwargs
dict
Additional keyword arguments passed to BaseTool.

Methods

run

Execute a shell command with the specified parameters.
request
ShellCommandRequest
required
A request object containing command execution parameters.
Returns: Command output (stdout + stderr) as a string.

ShellCommandRequest

The request model for shell command execution.
command
str
required
The shell command to execute. Will be properly split using shlex.split().
working_directory
str
default:"None"
Working directory for command execution. Defaults to current working directory.
env
dict
default:"None"
Additional environment variables to set. Merged with existing environment.
timeout_ms
int
default:"None"
Execution timeout in milliseconds. No timeout if not specified.

Usage Example

With Agentor Agent

Custom Executor

You can provide a custom executor function for specialized command handling:

Error Handling

The tool handles various error conditions:
  • Timeout: Returns “Command execution timed out”
  • Command not found: Returns “Error executing command: …”
  • Permission denied: Returns subprocess error message
  • Other exceptions: Returns descriptive error message

Security Considerations

  • Commands are properly escaped using shlex.split() to prevent injection
  • Both stdout and stderr are captured
  • Timeout support prevents runaway processes
  • Custom executors can implement additional validation
  • Consider restricting available commands in production environments

Alias

LocalShellTool is an alias for ShellTool:
Source: /home/daytona/workspace/source/src/agentor/tools/shell.py:18
Last modified on May 5, 2026