Paladin Feature Flags

Paladin uses Cargo feature flags to enable fine-grained control over compiled dependencies and functionality. This allows you to build minimal, focused binaries for specific use cases while reducing compile times and binary sizes.

Table of Contents

Overview

Philosophy

Feature flags in Paladin follow these principles:

  1. Core Framework Always Available - Paladin agents, Battalion orchestration, Garrison memory, Arsenal tools, and Herald formatters are always compiled
  2. Provider Choice - Choose which LLM providers to support (OpenAI, Anthropic, DeepSeek)
  3. Subsystem Opt-In - Enable only the subsystems you need (web servers, content processing, notifications)
  4. Infrastructure Selection - Pick storage/queue adapters (Redis, S3/MinIO, Qdrant)
  5. Testing Flexibility - Enable integration tests only when needed

Default vs. Full

ConfigurationFeatures EnabledUse Case
Defaultllm-openai onlyProduction orchestration with OpenAI
FullAll optional featuresDevelopment, testing, full functionality
No DefaultCore framework onlyLibrary usage, custom integrations

Available Feature Flags

LLM Provider Flags

FlagDependenciesModules GatedDescription
llm-openaiNone (uses reqwest)infrastructure::adapters::llm::openai_adapterOpenAI GPT models (GPT-3.5, GPT-4, GPT-4-turbo, GPT-4o)
llm-anthropicNone (uses reqwest)infrastructure::adapters::llm::anthropic_adapterAnthropic Claude models (Claude 3 Opus, Sonnet, Haiku)
llm-deepseekNone (uses reqwest)infrastructure::adapters::llm::deepseek_adapterDeepSeek models (DeepSeek-V3, DeepSeek-Chat)
llm-allllm-openai, llm-anthropic, llm-deepseekAll LLM adaptersAll supported LLM providers

Subsystem Flags

FlagDependenciesModules GatedDescription
visionNoneVision-related types, prompt buildersEnable vision capabilities for multimodal LLM interactions
content-processingpdf-extract, scraper, tiktoken-rs, rssContent extraction, tokenizationPDF parsing, web scraping, RSS feeds, token counting
web-serveractix-web, axumREST API controllers, server setupHTTP/REST API servers for user management and content delivery
notificationslettre, handlebarsEmail adapter, templatingEmail notifications with template rendering

Storage & Queue Flags

FlagDependenciesModules GatedDescription
redis-queueredisinfrastructure::adapters::queue::redisRedis-based async queue adapter
s3-storagerust-s3infrastructure::adapters::file_storage::minioS3/MinIO file storage adapter
openai-embeddingsNoneEmbedding generation utilitiesOpenAI embedding model support
qdrantqdrant-clientQdrant vector database adapterVector database for semantic search

CLI Flags

FlagDependenciesModules GatedDescription
cliclap, dialoguer, indicatif, console, serde_yamlapplication::cliCommand-line tooling for the paladin-cli binary

Build the paladin-cli binary with:

cargo build --bin paladin-cli --features cli

Testing Flags

FlagDependenciesModules GatedDescription
integration-testsNoneIntegration test modulesEnable integration tests (Docker services required)
live-api-testsNoneLive API test modulesTests requiring real API keys (OpenAI, Anthropic, DeepSeek)

Convenience Flags

FlagEnablesDescription
fullllm-all, content-processing, web-server, notifications, vision, redis-queue, s3-storage, openai-embeddings, qdrant, cliAll optional features for development/testing

Default Configuration

Current Default (as of v0.1.0):

[dependencies]
paladin = "0.1"

This enables only:

  • llm-openai - OpenAI LLM provider
  • ✅ Core framework (always available)

Previous Default (before v0.1.0):

# Old default - no longer applies
default = ["redis-queue", "s3-storage", "openai-embeddings"]

See MIGRATION.md for migration guidance.

Usage Examples

Minimal Build (Core Only)

No external LLM providers, storage, or queues:

[dependencies]
paladin = { version = "0.1", default-features = false }

Use case: Custom LLM integrations, library embedding, edge deployments

Single Provider Builds

OpenAI Only (default):

[dependencies]
paladin = "0.1"
# Or explicitly:
paladin = { version = "0.1", features = ["llm-openai"] }

Anthropic Only:

[dependencies]
paladin = { version = "0.1", default-features = false, features = ["llm-anthropic"] }

DeepSeek Only:

[dependencies]
paladin = { version = "0.1", default-features = false, features = ["llm-deepseek"] }

Multi-Provider Builds

All LLM Providers:

[dependencies]
paladin = { version = "0.1", default-features = false, features = ["llm-all"] }

OpenAI + Anthropic:

[dependencies]
paladin = { version = "0.1", default-features = false, features = ["llm-openai", "llm-anthropic"] }

Orchestration Platform Build

Agents + web API + Redis queue + S3 storage:

[dependencies]
paladin = { version = "0.1", features = ["web-server", "redis-queue", "s3-storage"] }

Content Processing Build

Content ingestion + processing + all providers:

[dependencies]
paladin = { version = "0.1", features = ["llm-all", "content-processing", "qdrant", "s3-storage"] }

Full Development Build

All features enabled:

[dependencies]
paladin = { version = "0.1", features = ["full"] }

Or use the CLI:

cargo build --features full
cargo test --features full

Production API Server

Web server + notifications + OpenAI + storage:

[dependencies]
paladin = { version = "0.1", features = ["web-server", "notifications", "redis-queue", "s3-storage"] }

Build Comparison

Binary Size Comparison

ConfigurationFeaturesDependenciesApprox. Binary Size*Compile Time*
Core OnlyNone~50 crates8-12 MB30-45s
Defaultllm-openai~55 crates10-14 MB40-60s
FullAll~120 crates25-35 MB3-5 min

*Approximate values for release builds on x86_64 Linux. Actual values vary by system.

Compile Time Optimization

Fast iteration (core only):

cargo build --no-default-features
cargo test --lib --no-default-features

Full testing (all features):

cargo test --features full

Feature Dependencies

Dependency Tree

full
├── llm-all
│   ├── llm-openai
│   ├── llm-anthropic
│   └── llm-deepseek
├── content-processing
│   ├── pdf-extract
│   ├── scraper
│   ├── tiktoken-rs
│   └── rss
├── web-server
│   ├── actix-web
│   └── axum
├── notifications
│   ├── lettre
│   └── handlebars
├── vision
├── redis-queue
│   └── redis
├── s3-storage
│   └── rust-s3
├── openai-embeddings
└── qdrant
    └── qdrant-client

Conditional Compilation Examples

In Your Code:

#![allow(unused)]
fn main() {
// Always available (core framework)
use paladin::core::platform::container::paladin::Paladin;
use paladin::application::services::paladin::paladin_builder::PaladinBuilder;

// Conditionally compiled
#[cfg(feature = "llm-openai")]
use paladin::infrastructure::adapters::llm::openai_adapter::OpenAIAdapter;

#[cfg(feature = "redis-queue")]
use paladin::infrastructure::adapters::queue::redis::RedisQueueAdapter;

#[cfg(feature = "web-server")]
use paladin::infrastructure::web::server::start_web_server;
}

Best Practices

1. Start Minimal, Add as Needed

Begin with default features, add others only when required:

# Start here
[dependencies]
paladin = "0.1"

# Add features as needed
paladin = { version = "0.1", features = ["redis-queue"] }

2. Use full for Development Only

Enable all features during development, but specify exact features for production:

[dependencies]
# Production - explicit features
paladin = { version = "0.1", features = ["llm-anthropic", "s3-storage"] }

[dev-dependencies]
# Development - all features
paladin = { version = "0.1", features = ["full"] }

3. Document Feature Requirements

If your application requires specific features, document them:

#![allow(unused)]
fn main() {
//! # Example Application
//!
//! **Required Features:**
//! ```toml
//! paladin = { version = "0.1", features = ["llm-openai", "redis-queue", "s3-storage"] }
//! ```
}

4. Test with Multiple Feature Combinations

Use CI to test critical combinations:

# .github/workflows/ci.yml
strategy:
  matrix:
    features:
      - "--no-default-features"
      - ""  # default
      - "--features full"

See .github/workflows/feature-flags.yml for Paladin's complete feature matrix testing.

5. Feature-Gate Examples

Add feature requirements to example documentation:

#![allow(unused)]
fn main() {
//! # Redis Queue Example
//!
//! **Required Cargo Features:**
//! ```toml
//! paladin = { version = "0.1", features = ["redis-queue"] }
//! ```
//!
//! Run with: `cargo run --example redis_queue --features redis-queue`
}

Migration Guide

If you're upgrading from a version before the feature flag reorganization, see MIGRATION.md for detailed migration instructions.

CI/CD Integration

GitHub Actions

name: CI
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        features:
          - ""                              # default
          - "--no-default-features"         # core only
          - "--features full"               # all features
          - "--features llm-anthropic"      # specific provider
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
      - name: Test
        run: cargo test ${{ matrix.features }}

Docker Multi-Stage Builds

# Builder with only needed features
FROM rust:1.75 as builder
WORKDIR /app
COPY . .
RUN cargo build --release --features "llm-openai,redis-queue,s3-storage"

# Runtime image
FROM debian:bookworm-slim
COPY --from=builder /app/target/release/paladin /usr/local/bin/
CMD ["paladin"]

Support

For issues or questions about feature flags: