@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.
@@ -2023,6 +2023,26 @@ var ObservationStep = class {
2023
2023
  if (statusSnapshot.shouldBuffer && !hasIncompleteToolCalls) {
2024
2024
  const allMessages = messageList.get.all.db();
2025
2025
  const unobservedMessages = om.getUnobservedMessages(allMessages, statusSnapshot.record);
2026
+ const candidates = om.getUnobservedMessages(unobservedMessages, statusSnapshot.record, {
2027
+ excludeBuffered: true
2028
+ });
2029
+ if (candidates.length > 0) {
2030
+ om.sealMessagesForBuffering(candidates);
2031
+ try {
2032
+ await this.turn.hooks?.onBufferChunkSealed?.();
2033
+ } catch (error) {
2034
+ omDebug(
2035
+ `[OM:buffer] onBufferChunkSealed hook failed: ${error instanceof Error ? error.message : String(error)}`
2036
+ );
2037
+ }
2038
+ if (this.turn.memory) {
2039
+ await this.turn.memory.persistMessages(candidates);
2040
+ }
2041
+ messageList.removeByIds(candidates.map((msg) => msg.id));
2042
+ for (const msg of candidates) {
2043
+ messageList.add(msg, "memory");
2044
+ }
2045
+ }
2026
2046
  void om.buffer({
2027
2047
  threadId,
2028
2048
  resourceId,
@@ -2031,23 +2051,7 @@ var ObservationStep = class {
2031
2051
  record: statusSnapshot.record,
2032
2052
  writer: this.turn.writer,
2033
2053
  requestContext: this.turn.requestContext,
2034
- observabilityContext: this.turn.observabilityContext,
2035
- beforeBuffer: async (candidates) => {
2036
- if (candidates.length === 0) {
2037
- return;
2038
- }
2039
- om.sealMessagesForBuffering(candidates);
2040
- try {
2041
- await this.turn.hooks?.onBufferChunkSealed?.();
2042
- } catch (error) {
2043
- omDebug(
2044
- `[OM:buffer] onBufferChunkSealed hook failed: ${error instanceof Error ? error.message : String(error)}`
2045
- );
2046
- }
2047
- if (this.turn.memory) {
2048
- await this.turn.memory.persistMessages(candidates);
2049
- }
2050
- }
2054
+ observabilityContext: this.turn.observabilityContext
2051
2055
  }).catch((err) => {
2052
2056
  omDebug(`[OM:buffer] fire-and-forget buffer failed: ${err?.message}`);
2053
2057
  });
@@ -8559,5 +8563,5 @@ function getObservationsAsOf(activeObservations, asOf) {
8559
8563
  }
8560
8564
 
8561
8565
  export { ModelByInputTokens, OBSERVER_SYSTEM_PROMPT, ObservationalMemory, ObservationalMemoryProcessor, TokenCounter, buildObserverPrompt, buildObserverSystemPrompt, combineObservationGroupRanges, deriveObservationGroupProvenance, extractCurrentTask, formatMessagesForObserver, formatToolResultForObserver, getObservationsAsOf, hasCurrentTaskSection, injectAnchorIds, optimizeObservationsForContext, parseAnchorId, parseObservationGroups, parseObserverOutput, reconcileObservationGroupsFromReflection, renderObservationGroupsForReflection, resolveToolResultValue, stripEphemeralAnchorIds, stripObservationGroups, truncateStringByTokens, wrapInObservationGroup };
8562
- //# sourceMappingURL=chunk-SWCWXIDJ.js.map
8563
- //# sourceMappingURL=chunk-SWCWXIDJ.js.map
8566
+ //# sourceMappingURL=chunk-C7PARRAD.js.map
8567
+ //# sourceMappingURL=chunk-C7PARRAD.js.map