Files
AutoGPT/STANDALONE_MODE.md
Claude 938dff9b99 feat(platform): Add standalone mode for running without external dependencies
Implemented in-memory fallbacks for Redis, RabbitMQ, and event bus to enable
running the platform in restricted environments without Docker or external services.

Changes:
- Added standalone_mode flag to Settings configuration
- Created InMemoryRedis client with basic Redis operations
- Created InMemoryEventBus for pub/sub messaging without Redis
- Created InMemoryMessageBroker for queue management without RabbitMQ
- Updated redis_client.py to use in-memory client when standalone mode enabled
- Updated event_bus.py to use in-memory implementation when standalone mode enabled
- Updated rabbitmq.py to use in-memory implementation when standalone mode enabled
- Added .env.standalone template for easy standalone configuration
- Added STANDALONE_MODE.md documentation

This allows developers to run the platform locally without Docker, useful for:
- Development and testing
- CI/CD pipelines
- Restricted environments
- Quick demos

Limitations:
- No data persistence (all in memory)
- Single process only (no distributed execution)
- Database still required (PostgreSQL or SQLite)

Usage:
  export STANDALONE_MODE=true
  # or copy .env.standalone to .env

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 21:15:29 +00:00

6.3 KiB

Standalone Mode

This document describes how to run the AutoGPT platform in standalone mode without external dependencies like Redis, RabbitMQ, and Supabase.

Overview

Standalone mode uses in-memory implementations for:

  • Redis: In-memory key-value store and pub/sub messaging
  • RabbitMQ: In-memory message queues and task distribution
  • Event Bus: In-memory event distribution system

This is useful for:

  • Development and testing without Docker
  • Running in restricted environments
  • Quick local demos
  • CI/CD pipelines without external services

Limitations

Standalone mode has these limitations:

  • No persistence: All data is stored in memory and lost on restart
  • Single process: Cannot scale across multiple workers/servers
  • No distributed locking: Cluster coordination features are disabled
  • Database still required: You still need PostgreSQL or need to configure SQLite
  • Authentication may need adjustment: Supabase authentication won't work

How to Enable

Method 1: Environment Variable

Set the STANDALONE_MODE environment variable:

export STANDALONE_MODE=true

Method 2: Configuration File

  1. Copy the standalone environment template:

    cd autogpt_platform/backend
    cp .env.standalone .env
    
  2. Edit .env and adjust any settings as needed

  3. Add to the config (via environment or config.json):

    {
      "standalone_mode": true
    }
    

Method 3: Programmatic

In your code, you can check/set standalone mode:

from backend.util.settings import Settings

settings = Settings()
settings.config.standalone_mode = True

Running the Platform

Once standalone mode is enabled:

cd autogpt_platform/backend

# Install dependencies
poetry install

# Run migrations (if using SQLite, update schema first)
poetry run prisma migrate deploy

# Start the backend server
poetry run python -m backend.app

The platform will automatically use in-memory implementations when it detects:

  • STANDALONE_MODE=true environment variable, OR
  • standalone_mode: true in config settings

Implementation Details

Redis Client (backend/data/redis_client.py)

When standalone mode is active:

  • Returns InMemoryRedis() instead of connecting to Redis
  • Stores data in a Python dictionary (singleton)
  • Supports basic operations: get, set, delete, incr, keys, etc.
  • Pub/sub returns empty generators (use event bus instead)

Event Bus (backend/data/event_bus.py)

When standalone mode is active:

  • RedisEventBus uses InMemorySyncEventBus
  • AsyncRedisEventBus uses InMemoryAsyncEventBus
  • Events are distributed via Python queues
  • Supports pattern subscriptions with wildcards

RabbitMQ (backend/data/rabbitmq.py)

When standalone mode is active:

  • SyncRabbitMQ uses InMemorySyncRabbitMQ
  • AsyncRabbitMQ uses InMemoryAsyncRabbitMQ
  • Messages are routed via Python queues
  • Supports exchanges, queues, and routing keys
  • Implements fanout, direct, and topic exchange types

Troubleshooting

"Connection refused" errors

If you still see connection errors:

  1. Check that STANDALONE_MODE=true is set
  2. Verify the setting with: python -c "from backend.util.settings import Settings; print(Settings().config.standalone_mode)"
  3. Make sure you're not explicitly connecting to Redis/RabbitMQ elsewhere

Database connection errors

Standalone mode does NOT replace the database. You need either:

  • PostgreSQL running locally
  • SQLite (requires schema changes)
  • A remote database connection

Authentication errors

Supabase authentication won't work in standalone mode. Options:

  1. Disable authentication: ENABLE_AUTH=false in .env
  2. Implement a mock auth provider
  3. Use a different auth method

Architecture

┌─────────────────────────────────────────┐
│          Standalone Mode                │
├─────────────────────────────────────────┤
│                                         │
│  ┌──────────────────────────────────┐  │
│  │   InMemoryRedis (Singleton)      │  │
│  │   - Key-value store (dict)       │  │
│  │   - TTL not implemented          │  │
│  └──────────────────────────────────┘  │
│                                         │
│  ┌──────────────────────────────────┐  │
│  │   InMemoryEventBus (Singleton)   │  │
│  │   - Pub/sub via queues           │  │
│  │   - Pattern matching support     │  │
│  └──────────────────────────────────┘  │
│                                         │
│  ┌──────────────────────────────────┐  │
│  │   InMemoryMessageBroker          │  │
│  │   - Exchanges & queues           │  │
│  │   - Routing key matching         │  │
│  │   - Fanout/direct/topic types    │  │
│  └──────────────────────────────────┘  │
│                                         │
└─────────────────────────────────────────┘

Testing

To test standalone mode:

# Set standalone mode
export STANDALONE_MODE=true

# Run tests
cd autogpt_platform/backend
poetry run pytest

# Or run a specific service
poetry run python -m backend.rest

Production Use

⚠️ Warning: Standalone mode is NOT recommended for production use because:

  • No data persistence
  • No horizontal scaling
  • No failover or redundancy
  • Limited to single-process execution

For production, use the full Docker setup with real Redis, RabbitMQ, and PostgreSQL.

Contributing

The standalone mode implementations are in:

  • backend/data/inmemory_redis.py - In-memory Redis client
  • backend/data/inmemory_event_bus.py - In-memory event bus
  • backend/data/inmemory_queue.py - In-memory RabbitMQ

Feel free to improve these implementations or add missing features.