Skip to main content
The AutonomousShellToolKit enables secure terminal command execution within the workspace.

Available Tools

ToolDescription
run_commandExecute shell commands
run_pythonExecute Python code snippets
check_command_existsVerify if a command is available

Configuration Options

OptionDefaultDescription
shell_timeout120Default command timeout in seconds
shell_max_output10000Maximum output characters before truncation
blocked_commandsSecurity defaultsCommands that are blocked

Example: Running Commands

from upsonic import AutonomousAgent, Task

agent = AutonomousAgent(
    model="openai/gpt-4o",
    workspace="/path/to/project",
    shell_timeout=60
)

# Run development tasks
task = Task("Run the test suite and report any failures")
agent.print_do(task)

Example: Python Execution

from upsonic import AutonomousAgent, Task

agent = AutonomousAgent(
    model="openai/gpt-4o",
    workspace="/path/to/project"
)

# Execute Python code
task = Task("Write and run a Python script that calculates the Fibonacci sequence up to 100")
agent.print_do(task)

Command Blocking

By default, dangerous commands are blocked. You can customize the blocklist:
from upsonic import AutonomousAgent

agent = AutonomousAgent(
    model="openai/gpt-4o",
    workspace="/path/to/project",
    blocked_commands=["rm -rf", "sudo", "chmod 777"]
)

Environment Variables

Pass custom environment variables to commands:
from upsonic import AutonomousAgent, Task

agent = AutonomousAgent(
    model="openai/gpt-4o",
    workspace="/path/to/project"
)

# The shell toolkit supports environment variables
# Commands run in the workspace directory
task = Task("Set DEBUG=true and run the application")
agent.print_do(task)

Direct Toolkit Access

Access the shell toolkit directly:
from upsonic import AutonomousAgent

agent = AutonomousAgent(
    model="openai/gpt-4o",
    workspace="/path/to/project"
)

# Direct execution
result = agent.shell_toolkit.run_command("python3 --version")
print(result)

# Check command availability
exists = agent.shell_toolkit.check_command_exists("docker")
print(f"Docker available: {exists}")

# Run Python code
output = agent.shell_toolkit.run_python("print([x**2 for x in range(5)])")
print(output)