@mastra/memory 1.13.1 → 1.13.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @mastra/memory
2
2
 
3
+ ## 1.13.2-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed observational memory buffering so sealed assistant chunks stay split instead of being merged back into one persisted message during long tool runs. ([#14995](https://github.com/mastra-ai/mastra/pull/14995))
8
+
9
+ - Updated dependencies [[`ed425d7`](https://github.com/mastra-ai/mastra/commit/ed425d78e7c66cbda8209fee910856f98c6c6b82), [`ba6f7e9`](https://github.com/mastra-ai/mastra/commit/ba6f7e9086d8281393f2acae60fda61de3bff1f9), [`7eb2596`](https://github.com/mastra-ai/mastra/commit/7eb25960d607e07468c9a10c5437abd2deaf1e9a)]:
10
+ - @mastra/core@1.23.0-alpha.0
11
+
3
12
  ## 1.13.1
4
13
 
5
14
  ### Patch Changes
@@ -2030,6 +2030,26 @@ var ObservationStep = class {
2030
2030
  if (statusSnapshot.shouldBuffer && !hasIncompleteToolCalls) {
2031
2031
  const allMessages = messageList.get.all.db();
2032
2032
  const unobservedMessages = om.getUnobservedMessages(allMessages, statusSnapshot.record);
2033
+ const candidates = om.getUnobservedMessages(unobservedMessages, statusSnapshot.record, {
2034
+ excludeBuffered: true
2035
+ });
2036
+ if (candidates.length > 0) {
2037
+ om.sealMessagesForBuffering(candidates);
2038
+ try {
2039
+ await this.turn.hooks?.onBufferChunkSealed?.();
2040
+ } catch (error) {
2041
+ omDebug(
2042
+ `[OM:buffer] onBufferChunkSealed hook failed: ${error instanceof Error ? error.message : String(error)}`
2043
+ );
2044
+ }
2045
+ if (this.turn.memory) {
2046
+ await this.turn.memory.persistMessages(candidates);
2047
+ }
2048
+ messageList.removeByIds(candidates.map((msg) => msg.id));
2049
+ for (const msg of candidates) {
2050
+ messageList.add(msg, "memory");
2051
+ }
2052
+ }
2033
2053
  void om.buffer({
2034
2054
  threadId,
2035
2055
  resourceId,
@@ -2038,23 +2058,7 @@ var ObservationStep = class {
2038
2058
  record: statusSnapshot.record,
2039
2059
  writer: this.turn.writer,
2040
2060
  requestContext: this.turn.requestContext,
2041
- observabilityContext: this.turn.observabilityContext,
2042
- beforeBuffer: async (candidates) => {
2043
- if (candidates.length === 0) {
2044
- return;
2045
- }
2046
- om.sealMessagesForBuffering(candidates);
2047
- try {
2048
- await this.turn.hooks?.onBufferChunkSealed?.();
2049
- } catch (error) {
2050
- omDebug(
2051
- `[OM:buffer] onBufferChunkSealed hook failed: ${error instanceof Error ? error.message : String(error)}`
2052
- );
2053
- }
2054
- if (this.turn.memory) {
2055
- await this.turn.memory.persistMessages(candidates);
2056
- }
2057
- }
2061
+ observabilityContext: this.turn.observabilityContext
2058
2062
  }).catch((err) => {
2059
2063
  omDebug(`[OM:buffer] fire-and-forget buffer failed: ${err?.message}`);
2060
2064
  });
@@ -8591,5 +8595,5 @@ exports.stripEphemeralAnchorIds = stripEphemeralAnchorIds;
8591
8595
  exports.stripObservationGroups = stripObservationGroups;
8592
8596
  exports.truncateStringByTokens = truncateStringByTokens;
8593
8597
  exports.wrapInObservationGroup = wrapInObservationGroup;
8594
- //# sourceMappingURL=chunk-HNVSYZRA.cjs.map
8595
- //# sourceMappingURL=chunk-HNVSYZRA.cjs.map
8598
+ //# sourceMappingURL=chunk-4FMHSWZD.cjs.map
8599
+ //# sourceMappingURL=chunk-4FMHSWZD.cjs.map