pub struct MemoryConfig {
pub backend: MemoryBackendType,
pub path: Option<String>,
pub url: Option<String>,
pub grpc_url: Option<String>,
pub collection: Option<String>,
pub dimensions: Option<usize>,
pub api_key: Option<String>,
pub embedding_model: Option<String>,
pub use_server_embeddings: Option<bool>,
pub prefix: Option<String>,
pub max_entries: Option<usize>,
pub ttl_seconds: Option<i64>,
}Expand description
Configuration for memory backends.
This struct can be used at the mesh level (shared by all agents) or at the agent level (per-agent configuration).
§Examples
§InMemory (default)
[memory]
backend = "inmemory"
max_entries = 500
ttl_seconds = 3600§SQLite (persistent)
[memory]
backend = "sqlite"
path = "./data/knowledge.db"§Redis (distributed)
[memory]
backend = "redis"
url = "redis://localhost:6379"
prefix = "myapp"
ttl_seconds = 7200§Qdrant (vector database)
[memory]
backend = "qdrant"
grpc_url = "http://localhost:6334"
collection = "agent_memory"
dimensions = 384
embedding_model = "ollama::mxbai-embed-large"§ChromaDB (vector database)
[memory]
backend = "chromadb"
url = "http://localhost:8000"
collection = "agent_memory"
use_server_embeddings = true§Pinecone (cloud vector database)
[memory]
backend = "pinecone"
api_key = "${PINECONE_API_KEY}"
collection = "agent-memory"
dimensions = 1536Fields§
§backend: MemoryBackendTypeBackend type: “inmemory”, “sqlite”, “redis”, “qdrant”, “chromadb”, or “pinecone”
path: Option<String>Path for SQLite database file. Use “:memory:” for in-memory SQLite. Only used when backend = “sqlite”.
url: Option<String>Connection URL for Redis or ChromaDB. Example: “redis://localhost:6379” or “http://localhost:8000” Used when backend = “redis” or “chromadb”.
grpc_url: Option<String>GRPC URL for Qdrant. Example: “http://localhost:6334” Only used when backend = “qdrant”.
collection: Option<String>Collection/index name for vector databases. Used by Qdrant, ChromaDB, and Pinecone.
dimensions: Option<usize>Vector dimensions for embeddings. Required for Qdrant and Pinecone when creating new collections.
api_key: Option<String>API key for cloud services (Pinecone, etc.). Can use environment variable syntax: “${PINECONE_API_KEY}”
embedding_model: Option<String>Embedding model identifier (e.g., “ollama::mxbai-embed-large”). Used for generating embeddings if not using server-side embeddings.
use_server_embeddings: Option<bool>Whether to use the vector DB’s server-side embedding feature. ChromaDB supports this with configured embedding functions.
prefix: Option<String>Key prefix for Redis namespace isolation. Only used when backend = “redis”.
max_entries: Option<usize>Maximum number of entries for InMemory backend. When exceeded, oldest entries are evicted. Only used when backend = “inmemory”.
ttl_seconds: Option<i64>Default TTL (time-to-live) in seconds for entries. Entries will be automatically removed after this time. Supported by all backends.
Implementations§
Source§impl MemoryConfig
impl MemoryConfig
Sourcepub fn qdrant(
grpc_url: impl Into<String>,
collection: impl Into<String>,
dimensions: usize,
) -> Self
pub fn qdrant( grpc_url: impl Into<String>, collection: impl Into<String>, dimensions: usize, ) -> Self
Create a Qdrant backend configuration.
§Arguments
grpc_url- Qdrant gRPC URL (e.g., “http://localhost:6334”)collection- Collection namedimensions- Vector dimensions
Sourcepub fn chromadb(url: impl Into<String>, collection: impl Into<String>) -> Self
pub fn chromadb(url: impl Into<String>, collection: impl Into<String>) -> Self
Create a ChromaDB backend configuration.
§Arguments
url- ChromaDB URL (e.g., “http://localhost:8000”)collection- Collection name
Sourcepub fn pinecone(
api_key: impl Into<String>,
collection: impl Into<String>,
dimensions: usize,
) -> Self
pub fn pinecone( api_key: impl Into<String>, collection: impl Into<String>, dimensions: usize, ) -> Self
Create a Pinecone backend configuration.
§Arguments
api_key- Pinecone API keycollection- Index namedimensions- Vector dimensions
Sourcepub fn with_max_entries(self, max: usize) -> Self
pub fn with_max_entries(self, max: usize) -> Self
Set max entries limit.
Sourcepub fn with_ttl_seconds(self, seconds: i64) -> Self
pub fn with_ttl_seconds(self, seconds: i64) -> Self
Set default TTL in seconds.
Sourcepub fn with_prefix(self, prefix: impl Into<String>) -> Self
pub fn with_prefix(self, prefix: impl Into<String>) -> Self
Set Redis key prefix.
Sourcepub fn with_collection(self, collection: impl Into<String>) -> Self
pub fn with_collection(self, collection: impl Into<String>) -> Self
Set collection/index name.
Sourcepub fn with_dimensions(self, dimensions: usize) -> Self
pub fn with_dimensions(self, dimensions: usize) -> Self
Set vector dimensions.
Sourcepub fn with_embedding_model(self, model: impl Into<String>) -> Self
pub fn with_embedding_model(self, model: impl Into<String>) -> Self
Set embedding model.
Sourcepub fn with_server_embeddings(self, enabled: bool) -> Self
pub fn with_server_embeddings(self, enabled: bool) -> Self
Enable or disable server-side embeddings.
Sourcepub fn with_api_key(self, api_key: impl Into<String>) -> Self
pub fn with_api_key(self, api_key: impl Into<String>) -> Self
Set API key for cloud services.
Trait Implementations§
Source§impl Clone for MemoryConfig
impl Clone for MemoryConfig
Source§fn clone(&self) -> MemoryConfig
fn clone(&self) -> MemoryConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MemoryConfig
impl Debug for MemoryConfig
Source§impl Default for MemoryConfig
impl Default for MemoryConfig
Source§fn default() -> MemoryConfig
fn default() -> MemoryConfig
Source§impl<'de> Deserialize<'de> for MemoryConfig
impl<'de> Deserialize<'de> for MemoryConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for MemoryConfig
impl RefUnwindSafe for MemoryConfig
impl Send for MemoryConfig
impl Sync for MemoryConfig
impl Unpin for MemoryConfig
impl UnwindSafe for MemoryConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more