suna/backend
sharath beeabc5940
fix(setup): new API key collections and encryption key generation
- Added support for collecting Smithery, QStash, and MCP API keys.
- Introduced a function to generate a secure base64-encoded encryption key for MCP credentials.
- Updated the total steps in the setup wizard from 11 to 14 to accommodate new configurations.
- Modified environment variable loading to include new services.
- Updated dependency management in `pyproject.toml` and `uv.lock` to include new packages.
2025-06-23 15:51:29 +00:00
..
agent chore(dev): workflows feature-flagged 2025-06-23 17:29:19 +05:30
agentpress fix(thread_manager): implement batching for message retrieval to enhance database performance and mitigate db limits 2025-06-22 16:42:55 +00:00
docs chore(dev): fix issues 2025-05-25 15:21:20 +05:30
flags chore(dev): import fix - n 2025-06-05 17:16:34 +05:30
mcp_local chore(dev): workflows feature-flagged 2025-06-23 17:26:06 +05:30
sandbox chore(dev): workflows feature-flagged 2025-06-23 17:29:19 +05:30
scheduling fix: RabbitMQ connection fix 2025-06-23 19:03:32 +05:30
services feat(llm): add fallback parameters for Claude model in LLM service 2025-06-22 19:01:00 +00:00
supabase chore(dev): fix templates migration 2025-06-23 17:41:38 +05:30
tests fix(thread_manager): adjust truncation logic and improve token compression handling 2025-06-18 07:25:29 +00:00
utils Merge branch 'main' into migrate/poetry-to-uv 2025-06-23 14:38:01 +00:00
webhooks fix: RabbitMQ connection fix 2025-06-23 19:03:32 +05:30
workflows fix: RabbitMQ connection fix 2025-06-23 19:03:32 +05:30
.dockerignore migrate: switch to uv from poetry 2025-06-15 12:29:47 +00:00
.env.example feat: introduce credentials manager 2025-06-07 11:54:59 +05:30
.gitignore delete user sandboxes script 2025-05-02 15:50:33 +02:00
ARCHITECTURE.md feat: workflows frontend 2025-06-12 18:57:27 +05:30
Dockerfile chore(logging): integrate structlog for structured logging and update dependencies 2025-06-18 19:20:15 +00:00
MANIFEST.in fe reference wip 2025-03-29 23:48:57 -07:00
MIGRATION_GUIDE.md feat: workflows frontend 2025-06-12 18:57:27 +05:30
README.md migrate: switch to uv from poetry 2025-06-15 17:43:21 +00:00
api.py chore(dev): workflows feature-flagged 2025-06-23 17:29:19 +05:30
docker-compose.prod.yml Merge branch 'main' into migrate/poetry-to-uv 2025-06-23 14:38:01 +00:00
docker-compose.yml Merge branch 'main' into migrate/poetry-to-uv 2025-06-23 14:38:01 +00:00
list_mcp.py chore(dev): extended the list of MCPs 2025-05-30 15:11:12 +05:30
pyproject.toml fix(setup): new API key collections and encryption key generation 2025-06-23 15:51:29 +00:00
run_agent_background.py fix: fix initializations of workflow 2025-06-23 19:26:32 +05:30
run_workflow_background.py fix: fix initializations of workflow 2025-06-23 19:26:32 +05:30
sentry.py feat(sentry): enhance Sentry integration with user tracking and error handling improvements 2025-05-27 10:04:17 +00:00
uv.lock fix(setup): new API key collections and encryption key generation 2025-06-23 15:51:29 +00:00

README.md

Suna Backend

Running the backend

Within the backend directory, run the following command to stop and start the backend:

docker compose down && docker compose up --build

Running Individual Services

You can run individual services from the docker-compose file. This is particularly useful during development:

Running only Redis and RabbitMQ

docker compose up redis rabbitmq

Running only the API and Worker

docker compose up api worker

Development Setup

For local development, you might only need to run Redis and RabbitMQ, while working on the API locally. This is useful when:

  • You're making changes to the API code and want to test them directly
  • You want to avoid rebuilding the API container on every change
  • You're running the API service directly on your machine

To run just Redis and RabbitMQ for development:```bash docker compose up redis rabbitmq

Then you can run your API service locally with the following commands

# On one terminal
cd backend
uv run api.py

# On another terminal
cd backend
uv run dramatiq --processes 4 --threads 4 run_agent_background

Environment Configuration

When running services individually, make sure to:

  1. Check your .env file and adjust any necessary environment variables
  2. Ensure Redis connection settings match your local setup (default: localhost:6379)
  3. Ensure RabbitMQ connection settings match your local setup (default: localhost:5672)
  4. Update any service-specific environment variables if needed

Important: Redis Host Configuration

When running the API locally with Redis in Docker, you need to set the correct Redis host in your .env file:

  • For Docker-to-Docker communication (when running both services in Docker): use REDIS_HOST=redis
  • For local-to-Docker communication (when running API locally): use REDIS_HOST=localhost

Important: RabbitMQ Host Configuration

When running the API locally with Redis in Docker, you need to set the correct RabbitMQ host in your .env file:

  • For Docker-to-Docker communication (when running both services in Docker): use RABBITMQ_HOST=rabbitmq
  • For local-to-Docker communication (when running API locally): use RABBITMQ_HOST=localhost

Example .env configuration for local development:

REDIS_HOST=localhost (instead of 'redis')
REDIS_PORT=6379
REDIS_PASSWORD=

RABBITMQ_HOST=localhost (instead of 'rabbitmq')
RABBITMQ_PORT=5672

Feature Flags

The backend includes a Redis-backed feature flag system that allows you to control feature availability without code deployments.

Setup

The feature flag system uses the existing Redis service and is automatically available when Redis is running.

CLI Management

Use the CLI tool to manage feature flags:

cd backend/flags
python setup.py <command> [arguments]

Available Commands

Enable a feature flag:

python setup.py enable test_flag "Test decsription"

Disable a feature flag:

python setup.py disable test_flag

List all feature flags:

python setup.py list

API Endpoints

Feature flags are accessible via REST API:

Get all feature flags:

GET /feature-flags

Get specific feature flag:

GET /feature-flags/{flag_name}

Example response:

{
  "test_flag": {
    "enabled": true,
    "description": "Test flag",
    "updated_at": "2024-01-15T10:30:00Z"
  }
}

Backend Integration

Use feature flags in your Python code:

from flags.flags import is_enabled

# Check if a feature is enabled
if await is_enabled('test_flag'):
    # Feature-specific logic
    pass

# With fallback value
enabled = await is_enabled('new_feature', default=False)

Current Feature Flags

The system currently supports these feature flags:

  • custom_agents: Controls custom agent creation and management
  • agent_marketplace: Controls agent marketplace functionality

Error Handling

The feature flag system includes robust error handling:

  • If Redis is unavailable, flags default to False
  • API endpoints return empty objects on Redis errors
  • CLI operations show clear error messages

Caching

  • Backend operations are direct Redis calls (no caching)
  • Frontend includes 5-minute caching for performance
  • Use clearCache() in frontend to force refresh

Production Setup

For production deployments, use the following command to set resource limits

docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d