Personal project by Ulf Fäldt Reifenberg · December 2026 · unofficial, not affiliated with Mastra

Tuning Mastra's semantic recall on LongMemEval

Mastra's memory can pull earlier messages back into the prompt by similarity. Two settings decide what comes back: how many matches (topK) and how many neighbouring messages come with each (messageRange). This page measures both on a public memory benchmark, picks a setting on half of the questions, and checks it on the other half.

Loading…

What was run

The sweep: did all the evidence come back?

Each cell: share of questions where every evidence turn was among the recalled messages, and below it the average size of the recalled context in tokens (characters / 4). No model is involved in this table; it is Mastra's memory.recall() scored against LongMemEval's evidence labels.

Mastra defaultchosen on the tune halfstruck through = over the context budget

Tune on half, check on the other half

The rule was fixed before the held-out half was scored: among settings whose average context on the tune half fits the budget, take the one with the most questions fully covered; ties go to the smaller context. Differences are in percentage points with 95% paired bootstrap intervals over questions (10,000 resamples).

Does better recall give better answers?

The recalled messages go to a model with the question; a second model grades the answer against LongMemEval's reference answer. Counts with 95% bootstrap intervals over questions. "Evidence missing" and "evidence present" split the wrong answers by what the trace shows: was every evidence turn in the prompt or not.

Question explorer

Pick a question to see its evidence turns and what each setting recalled and answered.

Limits

Built for an application to Mastra's AI Engineer role, with coding agents doing the implementation. Dataset: LongMemEval (Wu et al., MIT licence), cleaned S split. Memory: @mastra/memory, @mastra/libsql, @mastra/fastembed, used as published on npm; nothing here describes Mastra's internals beyond what the public packages do when called.