Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Feature Flags

MoFA uses feature flags to control which functionality is included in your build.

Core Features

FeatureDefaultDescription
default✓Basic agent functionality
openai✓OpenAI provider support
anthropicAnthropic provider support
uniffiCross-language bindings
pythonNative Python bindings (PyO3)

Persistence Features

FeatureDescription
persistenceEnable persistence layer
persistence-postgresPostgreSQL backend
persistence-mysqlMySQL backend
persistence-sqliteSQLite backend

Runtime Features

FeatureDescription
doraDora-rs distributed runtime
rhaiRhai scripting engine
wasmWASM plugin support

Using Feature Flags

In Cargo.toml

[dependencies]
# Default features
mofa-sdk = "0.1"

# Specific features only
mofa-sdk = { version = "0.1", default-features = false, features = ["openai"] }

# Multiple features
mofa-sdk = { version = "0.1", features = ["openai", "anthropic", "persistence-postgres"] }

# All features
mofa-sdk = { version = "0.1", features = ["full"] }

Feature Combinations

# Minimal setup (no LLM)
mofa-sdk = { version = "0.1", default-features = false }

# With OpenAI and SQLite persistence
mofa-sdk = { version = "0.1", features = ["openai", "persistence-sqlite"] }

# Production setup with PostgreSQL
mofa-sdk = { version = "0.1", features = [
    "openai",
    "anthropic",
    "persistence-postgres",
    "rhai",
] }

Crate-Specific Features

mofa-kernel

No optional features - always minimal core.

mofa-foundation

FeatureDescription
openaiOpenAI LLM provider
anthropicAnthropic LLM provider
persistencePersistence abstractions

mofa-runtime

FeatureDescription
doraDora-rs integration
monitoringBuilt-in monitoring

mofa-ffi

FeatureDescription
uniffiGenerate bindings via UniFFI
pythonNative Python bindings via PyO3

Build Size Impact

ConfigurationBinary SizeCompile Time
Minimal (no LLM)~5 MBFast
Default~10 MBMedium
Full features~20 MBSlow

Conditional Compilation

#![allow(unused)]
fn main() {
#[cfg(feature = "openai")]
pub fn openai_from_env() -> Result<OpenAIProvider, LLMError> {
    // OpenAI implementation
}

#[cfg(feature = "persistence-postgres")]
pub async fn connect_postgres(url: &str) -> Result<PostgresStore, Error> {
    // PostgreSQL implementation
}

#[cfg(not(feature = "openai"))]
compile_error!("OpenAI feature must be enabled to use openai_from_env");
}

See Also