> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upsonic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating an Autonomous Agent

> Learn how to build Autonomous Agents with Upsonic

`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:

```python theme={null}
from upsonic import AutonomousAgent, Task

# Create with just a model and workspace
agent = AutonomousAgent(
    model="anthropic/claude-sonnet-4-5",
    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:

```python theme={null}
from upsonic import AutonomousAgent, Task

# Workspace defaults to current directory if not specified
agent = AutonomousAgent(model="anthropic/claude-sonnet-4-5")

# Or specify a workspace explicitly
agent = AutonomousAgent(
    model="anthropic/claude-sonnet-4-5",
    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:

```python theme={null}
from upsonic import AutonomousAgent, Task

agent = AutonomousAgent(
    model="anthropic/claude-sonnet-4-5",
    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:

```python theme={null}
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="anthropic/claude-sonnet-4-5",
    workspace="/path/to/project",
    memory=memory
)
```

## Selective Toolkits

Enable only the tools you need:

```python theme={null}
from upsonic import AutonomousAgent

# Filesystem only (no shell access)
agent = AutonomousAgent(
    model="anthropic/claude-sonnet-4-5",
    workspace="/path/to/project",
    enable_filesystem=True,
    enable_shell=False
)

# Shell only (no filesystem access)
agent = AutonomousAgent(
    model="anthropic/claude-sonnet-4-5",
    workspace="/path/to/project",
    enable_filesystem=False,
    enable_shell=True
)
```

## Adding Custom Tools

Add your own tools alongside the default ones:

```python theme={null}
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="anthropic/claude-sonnet-4-5",
    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

* [Running an Autonomous Agent](/concepts/autonomous-agent/running-an-autonomous-agent) - Learn execution methods
* [Filesystem Tools](/concepts/autonomous-agent/advanced/filesystem-tools) - Detailed filesystem operations
* [Shell Tools](/concepts/autonomous-agent/advanced/shell-tools) - Shell command execution
