fix(deps): update dependency @mastra/memory to v1#51
Merged
Conversation
638926d to
f15d083
Compare
440e95f to
ede2d61
Compare
b3a84bb to
662b1cb
Compare
0c253ed to
07a62cf
Compare
07a62cf to
8ce6b06
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
^0.14.0→^1.0.0Release Notes
mastra-ai/mastra (@mastra/memory)
v1.5.2Compare Source
Patch Changes
Fixed observational memory buffering to preserve more context and activate at the right time. (#13476)
blockAfterbehavior: values below 100 are treated as multipliers (e.g.1.2= 1.2× threshold), values ≥ 100 as absolute token counts.Updated dependencies [
df170fd,ae55343,c290cec,f03e794,aa4a5ae,de3f584,d3fb010,702ee1c,f495051,e622f1d,8d14a59,861f111,00f43e8,1b6f651,96a1702,cb9f921,114e7c1,1b6f651,72df4a8]:v1.5.1Compare Source
Patch Changes
Fixed memory leak in Observational Memory (#13425)
Fixed several memory management issues that could cause OOM crashes in long-running processes with Observational Memory enabled:
cleanupStaticMaps.Fixed PostgreSQL deadlock when parallel agents with different threadIds share the same resourceId while using Observational Memory. Thread scope now requires a valid threadId and throws a clear error if one is missing. Also fixed the database lock ordering in synchronous observation to prevent lock inversions. (#13436)
Updated dependencies [
24284ff,f5097cc,71e237f,13a291e,397af5a,d4701f7,2b40831,6184727,0c338b8,6f6385b,14aba61,dd9dd1c]:v1.5.0Compare Source
Minor Changes
Improved conversational continuity when the message window shrinks during Observational Memory activation. The agent now preserves its suggested next response and current task across activation, so it maintains context instead of losing track of the conversation. (#13354)
Also improved the Observer to capture user messages more faithfully, reduce repetitive observations, and treat the most recent user message as the highest-priority signal.
Patch Changes
Improved Observational Memory priority handling. User messages and task completions are now always treated as high priority, ensuring the observer captures the most relevant context during conversations. (#13329)
Improved Observational Memory activation to preserve more usable context after activation. Previously, activation could leave the agent with too much or too little context depending on how chunks aligned with the retention target. (#13305)
blockAfter, activation now aggressively reduces context to unblock the conversationbufferActivationnow accepts absolute token values (>= 1000) in addition to ratios (0–1), giving more precise control over when activation triggersObservations no longer inflate token counts from degenerate LLM output. Runaway or repetitive observer/reflector output is automatically detected and retried, preventing excessive context usage after activation. (#13354)
Updated dependencies [
0d9efb4,7184d87,5caa13d,940163f,47892c8,45bb78b,70eef84,d84e52d,24b80af,608e156,2b2e157,59d30b5,453693b,78d1c80,c204b63,742a417]:v1.4.0Compare Source
Minor Changes
Update peer dependencies to match core package version bump (1.5.0) (#13245)
Update peer dependencies to match core package version bump (1.4.1) (#13151)
Update peer dependencies to match core package version bump (1.4.1) (#13245)
Add
instructionproperty to observational memory configs (#13240)Adds optional
instructionfield toObservationConfigandReflectionConfigthat allows users to extend the built-in observer/reflector system prompts with custom guidance.Example:
Patch Changes
dependencies updates: (#13167)
lru-cache@^11.2.6↗︎ (from^11.2.2, independencies)Added generic Harness class to @mastra/core for orchestrating agents with modes, state management, built-in tools (ask_user, submit_plan), subagent support, Observational Memory integration, model discovery, and permission-aware tool approval. The Harness provides a reusable foundation for building agent-powered applications with features like thread management, heartbeat monitoring, and event-driven architecture. (#13245)
sliceTokenEstimate * 0.75), making automatic trimming less aggressivetokensBufferedmarker now reports the actual slice size rather than total observation tokens, giving accurate size monitoringThese changes reduce failed reflections and make reported metrics match what is actually being processed.
Fixed a bug where the OM context window would jump to extremely high token counts (e.g. 16k → 114k) after observation activation. Two issues were causing this: (#13070)
data-om-activationmarker parts (which contain the full observation text, up to 150k+ characters) were being counted as message tokens when loaded from the database. These parts are never sent to the LLM and are now skipped during token counting.persistMarkerToMessageandpersistMarkerToStoragenow deduplicate bytype + cycleIdbefore adding a marker.Fixed thread title not being generated for pre-created threads. When threads were created before starting a conversation (e.g., for URL routing or storing metadata), the title stayed as a placeholder because the title generation condition checked whether the thread existed rather than whether it had a title. Threads created without an explicit title now get an empty title instead of a placeholder, and title generation fires whenever a thread has no title. Resolves #13145. (#13151)
Migrated MastraCode from the prototype harness to the generic CoreHarness from @mastra/core. The createMastraCode function is now fully configurable with optional parameters for modes, subagents, storage, tools, and more. Removed the deprecated prototype harness implementation. (#13245)
Fixed sub-agent memory context pollution that caused 'Exhausted all fallback models' errors when using Observational Memory with sub-agents. The parent agent's memory context is now preserved across sub-agent tool execution. (#13051)
Updated dependencies [
252580a,f8e819f,5c75261,e27d832,e37ef84,6fdd3d4,10cf521,efdb682,0dee7a0,04c2c8e,02dc07a,bb7262b,1415bcd,cf1c6e7,5ffadfe,1e1339c,d03df73,79b8f45,9bbf08e,0a25952,ffa5468,3264a04,6fdd3d4,088d9ba,74fbebd,aea6217,b6a855e,ae408ea,17e942e,2015cf9,7ef454e,2be1d99,2708fa1,ba74aef,ba74aef,ec53e89,9b5a8cb,607e66b,a215d06,6909c74,192438f]:v1.3.0Compare Source
Minor Changes
@mastra/opencode: Add opencode plugin for Observational Memory integration (#12925)
Added standalone
observe()API that accepts external messages directly, so integrations can trigger observation without duplicating messages into Mastra's storage.New exports:
ObserveHooks— lifecycle callbacks (onObservationStart,onObservationEnd,onReflectionStart,onReflectionEnd) for hooking into observation/reflection cyclesOBSERVATION_CONTEXT_PROMPT— preamble that introduces the observations blockOBSERVATION_CONTEXT_INSTRUCTIONS— rules for interpreting observations (placed after the<observations>block)OBSERVATION_CONTINUATION_HINT— behavioral guidance that prevents models from awkwardly acknowledging the memory systemgetOrCreateRecord()— now public, allows eager record initialization before the first observation cycleBreaking:
observe()now takes an object param instead of positional args. Update calls fromobserve(threadId, resourceId)toobserve({ threadId, resourceId }).Patch Changes
Fixed observational memory writing non-integer token counts to PostgreSQL, which caused
invalid input syntax for type integererrors. Token counts are now correctly rounded to integers before all database writes. (#12976)Fixed cloneThread not copying working memory to the cloned thread. Thread-scoped working memory is now properly carried over when cloning, and resource-scoped working memory is copied when the clone uses a different resourceId. (#12833)
Updated dependencies [
7ef618f,b373564,927c2af,b896b41,6415277,0831bbb,63f7eda,a5b67a3,877b02c,7567222,af71458,eb36bd8,3cbf121]:v1.2.0Compare Source
Minor Changes
Async buffering for observational memory is now enabled by default. Observations are pre-computed in the background as conversations grow — when the context window fills up, buffered observations activate instantly with no blocking LLM call. This keeps agents responsive during long conversations. (#12939)
Default settings:
observation.bufferTokens: 0.2— buffer every 20% ofmessageTokens(~6k tokens with the default 30k threshold)observation.bufferActivation: 0.8— on activation, retain 20% of the message windowreflection.bufferActivation: 0.5— start background reflection at 50% of the observation thresholdDisabling async buffering:
Set
observation.bufferTokens: falseto disable async buffering for both observations and reflections:Model is now required when passing an observational memory config object. Use
observationalMemory: truefor the default (google/gemini-2.5-flash), or set a model explicitly:shareTokenBudgetrequiresbufferTokens: false(temporary limitation). If you useshareTokenBudget: true, you must explicitly disable async buffering:New streaming event:
data-om-statusreplacesdata-om-progresswith a structured status object containing active window usage, buffered observation/reflection state, and projected activation impact.Buffering markers: New
data-om-buffering-start,data-om-buffering-end, anddata-om-buffering-failedstreaming events for UI feedback during background operations.Patch Changes
Fixed observational memory progress bars resetting to zero after agent responses finish. (#12934)
Fixed working memory tools being injected when no thread or resource context is provided. Made working memory tool execute scope-aware: thread-scoped requires threadId, resource-scoped requires resourceId (previously both were always required regardless of scope). (#12831)
Updated dependencies [
717ffab,b31c922,e4b6dab,5719fa8,83cda45,11804ad,aa95f95,90f7894,f5501ae,44573af,00e3861,8109aee,7bfbc52,1445994,61f44a2,37145d2,fdad759,e4569c5,7309a85,99424f6,44eb452,6c40593,8c1135d,dd39e54,b6fad9a,4129c07,5b930ab,4be93d0,047635c,8c90ff4,ed232d1,3891795,4f955b2,55a4c90]:v1.1.0Compare Source
Minor Changes
Added Observational Memory — a new memory system that keeps your agent's context window small while preserving long-term memory across conversations. (#12599)
Why: Long conversations cause context rot and waste tokens. Observational Memory compresses conversation history into observations (5–40x compression) and periodically condenses those into reflections. Your agent stays fast and focused, even after thousands of messages.
Usage:
What's new:
observationalMemory: trueenables the three-tier memory system (recent messages → observations → reflections)observe()API for triggering observation outside the normal agent loopAgent.findProcessor()method for looking up processors by IDprocessorStatesfor persisting processor state across loop iterationsProcessorStreamWriterfor custom stream events from processorsExpose token usage from embedding operations (#12556)
saveMessagesnow returnsusage: { tokens: number }with aggregated token count from all embeddingsrecallnow returnsusage: { tokens: number }from the vector search query embeddingMastraMemoryto include optionalusagein return typesThis allows users to track embedding token usage when using the Memory class.
Patch Changes
e6fc281,97be6c8,2770921,b1695db,5fe1fe0,4133d48,abae238,5dd01cc,13e0a2a,f6673b8,cd6be8a,9eb4e8e,c987384,cb8cc12,aa37c84,62f5d50,47eba72]:v1.0.1Compare Source
Patch Changes
Force alpha version bump for @mastra/evals, @mastra/loggers, @mastra/observability, and @mastra/memory (#12505)
Extended readOnly memory option to also apply to working memory. When readOnly: true, working memory data is provided as context but the updateWorkingMemory tool is not available. (#12471)
Example:
Updated dependencies [
90fc0e5,1cf5d2e,b99ceac,deea43e,833ae96,943772b,b5c711b,3efbe5a,1e49e7a,751eaab,69d8156,60d9d89,5c544c8,771ad96,2b0936b,3b04f30,97e26de,ac9ec66,10523f4,cb72d20,42856b1,66f33ff,ab3c190,d4f06c8,0350626,bc9fa00,f46a478,90fc0e5,f05a3a5,a291da9,c5d71da,07042f9,0423442]:v1.0.0Compare Source
Major Changes
Refactor workflow and tool types to remove Zod-specific constraints (#11814)
Removed Zod-specific type constraints across all workflow implementations and tool types, replacing them with generic types. This ensures type consistency across default, evented, and inngest workflows while preparing for Zod v4 migration.
Workflow Changes:
z.ZodObject<any>andz.ZodType<any>constraints from all workflow generic typesTInputandTStatedirectly instead ofz.infer<TInput>andz.infer<TState>TInput extends unknownpatternTStepsgeneric to properly useTEngineTypeinstead ofanyTool Changes:
ToolExecutionContextand related interfacesTSuspendSchema extends ZodLikeSchematoTSuspendandTResumeType Utilities:
This change maintains backward compatibility while improving type consistency and preparing for Zod v4 support across all affected packages.
Remove
getMessagesPaginated()and addperPage: falsesupport (#9670)Removes deprecated
getMessagesPaginated()method. ThelistMessages()API and score handlers now supportperPage: falseto fetch all records without pagination limits.Storage changes:
StoragePagination.perPagetype changed fromnumbertonumber | falseperPage: false:listMessages()listScoresBySpan(),listScoresByRunId(),listScoresByExecutionId()"false"string (e.g.,?perPage=false)Memory changes:
memory.query()parameter type changed fromStorageGetMessagesArgtoStorageListMessagesInputpage,perPage,include,filter,vectorSearchString) instead ofselectByobjectStricter validation:
listMessages()requires non-empty, non-whitespacethreadId(throws error instead of returning empty results)Migration:
Removed
storage.getMessages()(#9695)The
getMessages()method has been removed from all storage implementations. UselistMessages()instead, which provides pagination support.Migration:
Message ordering default
listMessages()defaults to ASC (oldest first) ordering bycreatedAt, matching the previousgetMessages()behavior.To use DESC ordering (newest first):
Renamed
client.getThreadMessages()→client.listThreadMessages()Migration:
The response format remains the same.
Removed
StorageGetMessagesArgtypeUse
StorageListMessagesInputinstead:Bump minimum required Node.js version to 22.13.0 (#9706)
Replace
getThreadsByResourceIdPaginatedwithlistThreadsByResourceIdacross memory handlers. Update client SDK to uselistThreads()withoffset/limitparameters instead of deprecatedgetMemoryThreads(). Consolidate/api/memory/threadsroutes to single paginated endpoint. (#9508)This simplifies the Memory API by removing the confusing rememberMessages method and renaming query to recall for better clarity. (#9701)
The rememberMessages method name implied it might persist data when it was actually just retrieving messages, same as query. Having two methods that did essentially the same thing was unnecessary.
Before:
After:
All usages have been updated across the codebase including tests. The agent now calls recall directly with the appropriate parameters.
Rename RuntimeContext to RequestContext (#9511)
Remove
getThreadsByResourceIdandgetThreadsByResourceIdPaginatedmethods from storage interfaces in favor oflistThreadsByResourceId. The new method usesoffset/limitpagination and a nestedorderByobject structure ({ field, direction }). (#9536)Remove various deprecated APIs from agent class. (#9257)
agent.llm→agent.getLLM()agent.tools→agent.getTools()agent.instructions→agent.getInstructions()agent.speak()→agent.voice.speak()agent.getSpeakers()→agent.voice.getSpeakers()agent.listen→agent.voice.listen()agent.fetchMemory→(await agent.getMemory()).query()agent.toStep→ Add agent directly to the step, workflows handle the transformationPagination APIs now use
page/perPageinstead ofoffset/limit(#9592)All storage and memory pagination APIs have been updated to use
page(0-indexed) andperPageinstead ofoffsetandlimit, aligning with standard REST API patterns.Affected APIs:
Memory.listThreadsByResourceId()Memory.listMessages()Storage.listWorkflowRuns()Migration:
Additional improvements:
pagevalues in all storage implementationsperPagevalidation to handle edge cases (negative values,0,false)Changing getAgents -> listAgents, getTools -> listTools, getWorkflows -> listWorkflows (#9495)
Mark as stable (
83d5942)Optimize default memory settings for semantic recall based on longmemeval data (#9046)
Enforcing id required on Processor primitive (#9591)
Renamed
MastraMessageV2toMastraDBMessage(#9255)Made the return format of all methods that return db messages consistent. It's always
{ messages: MastraDBMessage[] }now, and messages can be converted after that using@mastra/ai-sdk/ui'stoAISdkV4/5Messages()functionMinor Changes
Update peer dependencies to match core package version bump (0.22.3) (#9486)
Memory system now uses processors. Memory processors (
MessageHistory,SemanticRecall,WorkingMemory) are now exported from@mastra/memory/processorsand automatically added to the agent pipeline based on your memory config. Core processors (ToolCallFilter,TokenLimiter) remain in@mastra/core/processors. (#9254)Memory scope defaults changed from 'thread' to 'resource' (#8983)
Both
workingMemory.scopeandsemanticRecall.scopenow default to'resource'instead of'thread'. This means:Migration: To maintain the previous thread-scoped behavior, explicitly set
scope: 'thread':Also fixed issues where playground semantic recall search could show missing or incorrect results in certain cases.
Update peer dependencies to match core package version bump (1.0.0) (#9495)
Update peer dependencies to match core package version bump (0.22.0) (#8983)
Added new
listThreadsmethod for flexible thread filtering across all storage adapters. (#11832)New Features
resourceId,metadata, or both (with AND logic for metadata key-value pairs)Example Usage
Security Improvements
Schema-based working memory now uses merge semantics instead of replace semantics. (#10659)
Before: Each working memory update replaced the entire memory, causing data loss across conversation turns.
After: For schema-based working memory:
nullto delete itTemplate-based (Markdown) working memory retains the existing replace semantics.
This fixes issue #7775 where users building profile-like schemas would lose information from previous turns.
Patch Changes
dependencies updates: (#10133)
js-tiktoken@^1.0.21↗︎ (from^1.0.20, independencies)Add embedded documentation support for Mastra packages (#11472)
Mastra packages now include embedded documentation in the published npm package under
dist/docs/. This enables coding agents and AI assistants to understand and use the framework by reading documentation directly fromnode_modules.Each package includes:
Documentation is driven by the
packagesfrontmatter field in MDX files, which maps docs to their corresponding packages. CI validation ensures all docs include this field.Fixed ReDoS vulnerability in working memory tag parsing. (#11248)
Replaced regex-based parsing with indexOf-based string parsing to prevent denial of service attacks from malicious input. The vulnerable regex
/<working_memory>([^]*?)<\/working_memory>/ghad O(n²) complexity on pathological inputs - the new implementation maintains O(n) linear time.Embed AI types to fix peerdeps mismatches (
9650cce)Consolidate memory integration tests and fix working memory filtering in MessageHistory processor (#11367)
Moved
extractWorkingMemoryTags,removeWorkingMemoryTags, andextractWorkingMemoryContentutilities from@mastra/memoryto@mastra/core/memoryso they can be used by theMessageHistoryprocessor.Updated
MessageHistory.filterMessagesForPersistence()to properly filter outupdateWorkingMemorytool invocations and strip working memory tags from text content, fixing an issue where working memory tool call arguments were polluting saved message history for v5+ models.Also consolidated integration tests for agent-memory, working-memory, and pg-storage into shared test functions that can run against multiple model versions (v4, v5, v6).
Add new deleteVectors, updateVector by filter (#10408)
Update peer dependencies to match core package version bump (1.0.0) ([#9237](https://redirect.github.c
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.