Memory Configuration
Overview
The memory object allows you to configure conversation memory and personalization features for the application. This configuration controls how the system remembers and personalizes conversations, including token limits, message context windows, and agent-based memory processing.
Example
disabled
| Key | Type | Description | Example |
|---|---|---|---|
| disabled | Boolean | Disables memory functionality when set to true. When disabled, the system will not store or use conversation memory. | disabled: false |
Default: false
validKeys
| Key | Type | Description | Example |
|---|---|---|---|
| validKeys | Array of Strings | Specifies which keys are valid for memory storage. This helps control what types of information can be stored in memory. | validKeys: ["user_name", "preferences", "context"] |
Default: No restriction (all keys are valid)
tokenLimit
| Key | Type | Description | Example |
|---|---|---|---|
| tokenLimit | Number | Sets the maximum number of tokens that can be used for memory storage and processing. | tokenLimit: 2000 |
Default: No limit
charLimit
| Key | Type | Description | Example |
|---|---|---|---|
| charLimit | Number | Sets the maximum number of characters allowed for individual memory entries. This prevents oversized memory payloads that could impact performance or exceed API limits. | charLimit: 10000 |
Default: 10000
personalize
| Key | Type | Description | Example |
|---|---|---|---|
| personalize | Boolean | When set to true, gives users the ability to opt in or out of using memory features. Users can toggle memory on/off in their chat interface. When false, memory features are completely disabled. | personalize: true |
Default: true
messageWindowSize
| Key | Type | Description | Example |
|---|---|---|---|
| messageWindowSize | Number | Specifies the number of recent messages to include in the memory context window. | messageWindowSize: 5 |
Default: 5
agent
| Key | Type | Description | Example |
|---|---|---|---|
| agent | Object | Union | Configures the agent responsible for memory processing. Can be either a reference to an existing agent by ID or a complete agent configuration. | agent: { provider: "openAI", model: "gpt-4" } |
The agent field supports two different configuration formats:
Agent by ID
When you have a pre-configured agent, you can reference it by its ID:
Custom Agent Configuration
For more control, you can define a complete agent configuration:
Agent Configuration Fields
When using custom agent configuration, the following fields are available:
provider (required)
| Key | Type | Description | Example |
|---|---|---|---|
| provider | String | Specifies the AI provider for the memory agent. Can be a built-in provider (e.g., "openAI", "anthropic", "google") or a custom endpoint name. | provider: "openAI" |
model (required)
| Key | Type | Description | Example |
|---|---|---|---|
| model | String | Specifies the model to use for memory processing. | model: "gpt-4" |
instructions (optional)
| Key | Type | Description | Example |
|---|---|---|---|
| instructions | String | Custom instructions that replace the default instructions for when to set and/or delete memory. Should mainly be used when using validKeys that require specific information handling. | instructions: "Only store user preferences and facts when explicitly mentioned." |
model_parameters (optional)
| Key | Type | Description | Example |
|---|---|---|---|
| model_parameters | Object | Additional parameters to pass to the model for fine-tuning its behavior. | model_parameters: { temperature: 0.7 } |
Complete Configuration Example
Here's a comprehensive example showing all memory configuration options:
Using Custom Endpoints
The memory feature supports custom endpoints. When using a custom endpoint, the provider field should match the custom endpoint's name exactly. Custom headers with environment variables and user placeholders are properly resolved.
- See Custom Endpoint Headers for all available placeholders
Notes
- Memory functionality enhances conversation continuity and personalization
- When
personalizeis true, users get a toggle in their chat interface to control memory usage - Token limits help control memory usage and processing costs
- Valid keys provide granular control over what information can be stored
- Custom
instructionsreplace default memory handling instructions and should be used withvalidKeys - Agent configuration allows customization of memory processing behavior
- When disabled, all memory features are turned off regardless of other settings
- The message window size affects how much recent context is considered for memory updates
How is this guide?