@ai-sdk-x/memory
Add persistent, scoped memory to your agents. This package provides primitives for storing and retrieving context information that agents can use across interactions.
Installation
bash
npm add @ai-sdk-x/memoryUsage
createMemory accepts a set of CRUD adapters so you can plug in any database via Drizzle ORM or a custom adapter.
Example: SQLite
See the SQLite example on GitHub.
Example: MySQL
See the MySQL example on GitHub.
Example: PostgreSQL
See the PostgreSQL example on GitHub.
Scopes
Scopes allow you to partition memory per user, session, or any logical grouping:
typescript
const userMemory = memory("user-42"); // single scope
const sessionMemory = memory(["user-42", "session-9f3a"]); // multi-scope