AI SDK Tools
AI SDK Tools

Give your AI agents persistent memory.

Working memory and conversation history that persists between messages. Simple provider interface with built-in support for development and production environments. No more "what did we just discuss?"

npm install @ai-sdk-tools/memory
import { Agent } from '@ai-sdk-tools/agents'
import { DrizzleProvider } from '@ai-sdk-tools/memory'

const agent = new Agent({
  name: 'Assistant',
  model: openai('gpt-4'),
  instructions: 'You are a helpful assistant.',
  memory: {
    provider: new DrizzleProvider(db),
    workingMemory: { 
      enabled: true, 
      scope: 'user' 
    },
    history: { 
      enabled: true, 
      limit: 10 
    },
    chats: {
      enabled: true,
      generateTitle: true
    }
  }
})

Working Memory

Agents maintain a scratchpad that they can read and update. Store user preferences, learned facts, and context between conversations.

Conversation History

Automatically load past messages for context. Agents access the full conversation without manual management.

Chat Persistence

Track chat sessions with auto-generated titles, message counts, and timestamps. No more "New Chat 1, 2, 3..."

Flexible Providers

Built-in support for InMemory (dev), Drizzle ORM (SQL), and Upstash (Redis). Swap providers in one line of code.

Database Agnostic

Works with PostgreSQL, MySQL, SQLite, and Redis. Use your existing database infrastructure.

TypeScript First

Full type safety with a simple 4-method provider interface. Implement your own backend in minutes.

Development to Production

InMemory

Development
import { InMemoryProvider } from '@ai-sdk-tools/memory'

const memory = new InMemoryProvider()

// Zero configuration
// Perfect for local dev

Works instantly with no setup. Data resets on restart.

Drizzle

Production SQL
import { DrizzleProvider } from '@ai-sdk-tools/memory'

const memory = new DrizzleProvider(db, {
  workingMemoryTable,
  messagesTable
})

// PostgreSQL, MySQL, SQLite

Production-ready persistence with any SQL database.

Upstash

Serverless
import { UpstashProvider } from '@ai-sdk-tools/memory'
import { Redis } from '@upstash/redis'

const memory = new UpstashProvider(
  Redis.fromEnv()
)

// Edge-ready Redis

Perfect for edge and serverless environments.

Use Cases

Financial Assistants

Remember user preferences, currency settings, favorite reports

"Show me last month's expenses like before" - agents remember your preferred format, currency, and categories without asking again.

Support Bots

Track customer context across multiple support sessions

Agents recall past issues, product configurations, and customer preferences to provide personalized support continuity.

Personal Assistants

Learn user habits, communication style, and priorities

Agents adapt to your preferences over time, remembering how you like information presented and what matters most to you.

Development Tools

Remember project context, coding patterns, and team conventions

Agents maintain awareness of your codebase structure, preferences, and team standards across coding sessions.

git: (main)$ npm i @ai-sdk-tools/memory

Persistent memory for AI agents. Simple provider interface.