MemoryManager
@daydreamsai/core / MemoryManager
Interface: MemoryManager<TContext>
Defined in: packages/core/src/memory/types.ts:245
Memory manager for handling memory pressure
Type Parameters
TContext
TContext extends AnyContext = AnyContext
Properties
compress()?
optionalcompress: (ctx,entries,agent) =>string|Promise<string>
Defined in: packages/core/src/memory/types.ts:262
Called to compress/summarize old entries into a compact representation
Parameters
ctx
AgentContext<TContext>
entries
AnyRef[]
agent
Returns
string | Promise<string>
maxSize?
optionalmaxSize:number
Defined in: packages/core/src/memory/types.ts:269
Maximum number of entries before triggering memory management
onMemoryPressure()?
optionalonMemoryPressure: (ctx,workingMemory,agent) =>WorkingMemory|Promise<WorkingMemory>
Defined in: packages/core/src/memory/types.ts:247
Called when memory needs pruning due to size constraints
Parameters
ctx
AgentContext<TContext>
workingMemory
agent
Returns
WorkingMemory | Promise<WorkingMemory>
preserve?
optionalpreserve:object
Defined in: packages/core/src/memory/types.ts:275
Whether to preserve certain types of entries during pruning
actionNames?
optionalactionNames:string[]
Always keep action calls with these names
custom()?
optionalcustom: (entry,ctx) =>boolean
Custom preservation logic
Parameters
entry
ctx
AgentContext<TContext>
Returns
boolean
recentInputs?
optionalrecentInputs:number
Always keep the last N inputs
recentOutputs?
optionalrecentOutputs:number
Always keep the last N outputs
shouldPrune()?
optionalshouldPrune: (ctx,workingMemory,newEntry,agent) =>boolean|Promise<boolean>
Defined in: packages/core/src/memory/types.ts:254
Called before adding new entries to determine if pruning is needed
Parameters
ctx
AgentContext<TContext>
workingMemory
newEntry
agent
Returns
boolean | Promise<boolean>
strategy?
optionalstrategy:"fifo"|"lru"|"smart"|"custom"
Defined in: packages/core/src/memory/types.ts:272
Memory management strategy