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
- 60 of LongMemEval-S's 500 questions (10 per question type, seeded sample, abstention questions left out), so 30 per half. Intervals are wide and say so.
- Small open models, not the ones in Mastra's published results: a 384-dimension local embedder (bge-small-en-v1.5 through
@mastra/fastembed) and Llama models on Cloudflare Workers AI. The numbers here are not comparable with Mastra's own LongMemEval figures and are not a statement about them. - Retrieval is Mastra's. The answer prompt is this harness's own (recalled messages in time order, grouped by session with dates), not Mastra's agent loop, and each recalled message is cut at 1,600 characters in the prompt.
- The embedder reads at most 512 tokens per chunk, so long messages are embedded on their beginning only. Smaller chunks (
maxChunkChars) were not tested. - The judge is Llama 3.3 70B with grading rules modelled on LongMemEval's; the paper used GPT-4o. I did not measure agreement with human grading.
- Only semantic recall. Working memory, observational memory and recent-message history were not part of this.
- One run per cell at temperature 0; one sample of questions; one context budget.
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.