Skip to main content
AutonomousAgent is perfect for tasks that require filesystem or shell access. It comes pre-configured with:
  • InMemoryStorage as the default storage backend
  • Full session memory enabled for conversation history persistence
  • Filesystem and shell tools ready to use
This means you can focus on your task without any configuration.

Basic Creation

The simplest way to create an autonomous agent:
from upsonic import AutonomousAgent, Task

# Create with just a model and workspace
agent = AutonomousAgent(
    model="openai/gpt-4o",
    workspace="/path/to/project"
)

# The agent has filesystem and shell tools ready to use
task = Task("List all Python files and count the total lines of code")
agent.print_do(task)

Workspace Configuration

The workspace is where all file and shell operations take place. It’s sandboxed for security:
from upsonic import AutonomousAgent, Task

# Workspace defaults to current directory if not specified
agent = AutonomousAgent(model="openai/gpt-4o")

# Or specify a workspace explicitly
agent = AutonomousAgent(
    model="openai/gpt-4o",
    workspace="/home/user/projects/my-app"
)

# All paths are relative to the workspace
task = Task("Read src/main.py")  # Reads /home/user/projects/my-app/src/main.py
agent.print_do(task)

Adding Agent Identity

Give your agent a role and personality:
from upsonic import AutonomousAgent, Task

agent = AutonomousAgent(
    model="openai/gpt-4o",
    workspace="/path/to/project",
    name="CodeReviewer",
    role="Senior Software Engineer",
    goal="Review code for bugs and suggest improvements",
    instructions="Be thorough but constructive. Focus on security and performance."
)

task = Task("Review the authentication module for security issues")
agent.print_do(task)

Custom Storage

Use custom storage instead of the default InMemoryStorage:
from upsonic import AutonomousAgent
from upsonic.storage import SqliteStorage, Memory

# Create custom storage
storage = SqliteStorage(db_file="agent_sessions.db")
memory = Memory(
    storage=storage,
    session_id="session_001",
    full_session_memory=True
)

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

Selective Toolkits

Enable only the tools you need:
from upsonic import AutonomousAgent

# Filesystem only (no shell access)
agent = AutonomousAgent(
    model="openai/gpt-4o",
    workspace="/path/to/project",
    enable_filesystem=True,
    enable_shell=False
)

# Shell only (no filesystem access)
agent = AutonomousAgent(
    model="openai/gpt-4o",
    workspace="/path/to/project",
    enable_filesystem=False,
    enable_shell=True
)

Adding Custom Tools

Add your own tools alongside the default ones:
from upsonic import AutonomousAgent, Task
from upsonic.tools import tool

@tool
def deploy_to_staging() -> str:
    """Deploy the current code to staging environment."""
    return "Deployed successfully to staging!"

agent = AutonomousAgent(
    model="openai/gpt-4o",
    workspace="/path/to/project",
    tools=[deploy_to_staging]  # Added alongside filesystem and shell tools
)

task = Task("Run tests and if they pass, deploy to staging")
agent.print_do(task)

Next Steps