Configure a Default Memory Provider
Set up a default persistent memory provider for your agents
ControlFlow’s memory feature allows agents to store and retrieve information across multiple workflows. Memory modules are backed by a vector database, configured using a MemoryProvider
.
Setting up a default provider simplifies the process of creating memory objects throughout your application. Once configured, you can create memory objects without specifying a provider each time.
While ControlFlow does not include any vector database dependencies by default, the default provider is set to "chroma-db"
. This means that if you install the chromadb
package, your memory modules will work without any additional configuration.
Install dependencies
To use a provider, you must first install its dependencies. Please refer to the Memory doc to see all supported providers and their required dependencies.
For example, to use the default Chroma provider, you need to install chromadb
:
pip install chromadb
Configure a default provider
There are two ways to set up a default provider: using a string setting for common defaults, or instantiating a custom provider. Here, we’ll use a persistent Chroma database as our example.
String configurations
For simple provider setups, you can modify ControlFlow’s default settings using a string value. The default value is "chroma-db"
, which will create a persistent Chroma database. To change it:
For a list of available string configurations, see the Memory pattern guide.
Custom provider configuration
For more advanced setups, instantiate a provider with custom settings and assign it to the ControlFlow default. Note this must be done at runtime.
import controlflow as cf
from controlflow.memory.providers.chroma import ChromaMemory
import chromadb
# Set the default provider
cf.defaults.memory_provider = ChromaMemory(
client=chromadb.PersistentClient(path="/custom/path"),
)