Memory
Memory gives an agent persistent conversation threads, semantic recall of past messages, and working memory — all behind a pluggable storage layer.
Setting up memory
memory.ts
import { Memory } from '@redtuma/memory'
import { LibSQLStore } from '@redtuma/store-libsql'
const memory = new Memory({
storage: new LibSQLStore({ url: 'file:./redtuma.db' }),
options: {
lastMessages: 20, // recent history window
semanticRecall: { topK: 5 }, // retrieve relevant past messages
workingMemory: { enabled: true }, // persistent per-user notes
},
})
const agent = new Agent({
id: 'assistant',
instructions: '...',
model: 'anthropic/claude-opus-4-8',
memory,
})Threads & resources
Scope a conversation with a thread (one conversation) and a resource (the user or entity it belongs to). Pass them per call:
await agent.generate('Remember my name is Sam.', {
memory: { thread: 'thread-1', resource: 'user-42' },
})
// later, in the same thread, the agent recalls context
await agent.generate('What is my name?', {
memory: { thread: 'thread-1', resource: 'user-42' },
})Stores
All stores implement the same Store interface, so you can swap them freely:
InMemoryStore— built into@redtuma/core, great for tests and quick starts@redtuma/store-libsql— local SQLite file or Turso@redtuma/store-pg— Postgres@redtuma/store-do— Cloudflare Durable Object (see Cloudflare)
Same contract everywhere
Every store passes the same behavioral conformance suite, so memory behaves identically whether it's SQLite on your laptop or a Durable Object at the edge.