MemoryConfig

Struct MemoryConfig 

Source
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 = 1536

Fields§

§backend: MemoryBackendType

Backend 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

Source

pub fn new() -> Self

Create a new default memory config (InMemory backend).

Source

pub fn in_memory() -> Self

Create an InMemory backend configuration.

Source

pub fn sqlite(path: impl Into<String>) -> Self

Create a SQLite backend configuration.

Source

pub fn redis(url: impl Into<String>) -> Self

Create a Redis backend configuration.

Source

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 name
  • dimensions - Vector dimensions
Source

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
Source

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 key
  • collection - Index name
  • dimensions - Vector dimensions
Source

pub fn with_max_entries(self, max: usize) -> Self

Set max entries limit.

Source

pub fn with_ttl_seconds(self, seconds: i64) -> Self

Set default TTL in seconds.

Source

pub fn with_prefix(self, prefix: impl Into<String>) -> Self

Set Redis key prefix.

Source

pub fn with_collection(self, collection: impl Into<String>) -> Self

Set collection/index name.

Source

pub fn with_dimensions(self, dimensions: usize) -> Self

Set vector dimensions.

Source

pub fn with_embedding_model(self, model: impl Into<String>) -> Self

Set embedding model.

Source

pub fn with_server_embeddings(self, enabled: bool) -> Self

Enable or disable server-side embeddings.

Source

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

Source§

fn clone(&self) -> MemoryConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoryConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MemoryConfig

Source§

fn default() -> MemoryConfig

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for MemoryConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for MemoryConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,