Mastra

Rekall memory plus durable session state for Mastra, delivered as a memory Processor. The @rekall/mastra package recalls relevant memories into the prompt and captures the assistant's output back into Rekall.

Overview

mem.processor() conforms to Mastra's current Processor interface (processInput / processOutputResult) and does two things: recall-injection (pull relevant Rekall memories into the prompt) and capture (write the assistant's final answer back to Rekall). The processor methods never throw, so memory can never break a run.

Installation

Terminal
npm install @rekall/mastra

Usage

Register the same processor as both an input and output processor on your agent:

agent.ts
import { Agent } from '@mastra/core/agent';
import { RekallMemory } from '@rekall/mastra';
const mem = new RekallMemory({
apiUrl: 'https://api.rekall.app', // or http://localhost:9876 in dev
apiKey: process.env.REKALL_API_KEY, // rk_… key, or accessToken: 'rat_…'
});
const agent = new Agent({
name: 'assistant',
model,
inputProcessors: [mem.processor()], // recall → inject as a system message
outputProcessors: [mem.processor()], // capture assistant output into memory
});

What This Is (and Isn't)

mem.processor() is an input/output Processor — it is intentionally not a Mastra Memory provider. It does not implement Mastra's first-class Memory abstraction, so it does not participate in Mastra's thread / resource scoping or working-memory.

Rekall owns its session state

Rekall keeps its own durable session state via saveSession / loadSession, which you key however you like (e.g. by thread id). That state is owned by Rekall, not surfaced through Mastra's Memory APIs.

How It Maps

Processor methodRekall
processInputrecall against the latest user message → inject hits as a system message
processOutputResultcapture the assistant's final text → POST /api/v2/memories

The class also exposes remember / recall / contextFor for direct use. It is duck-typed against Mastra (optional peer dependency, no version coupling).

Session State

Persist durable thread/working state with saveSession and rehydrate it with loadSession, backed by Rekall's execution-memory /external store:

session.ts
await mem.saveSession('thread-1', state); // durable thread/working state
const prior = await mem.loadSession('thread-1');

Authentication

Pass apiKey (rk_…) or accessToken (rat_…), sent as a Bearer token. For local dev against a header-auth server, pass headers: { 'x-user-id': '…' }.

Next Steps

Rekall
rekall