Memory
createVirtualizedMemory
Hot-window + cold retriever. Keep recent messages; retrieve old ones on demand.
import { createInMemoryMemory, createVirtualizedMemory } from '@agentskit/core'
const backing = createInMemoryMemory()
const memory = createVirtualizedMemory(backing, {
maxActive: 50,
maxRetrieved: 5,
retriever: async ({ hot, cold, maxRetrieved }) => {
// return up to maxRetrieved older messages to splice back in
return cold.slice(-maxRetrieved)
},
})createVirtualizedMemory ships in @agentskit/core, not @agentskit/memory. The first argument is the backing ChatMemory.
#Options
| Option | Default | Purpose |
|---|---|---|
maxActive | 50 | Recent messages always loaded |
retriever | β | ( { hot, cold, maxRetrieved } ) => Message[] β optional cold lookup |
maxRetrieved | 10 | Cap on retrieved cold messages |
#When to use
Long-running sessions where most context is stale but some old turns matter. Cheaper than always-on full history.