@mastra/memory 1.17.4-alpha.0 → 1.17.5-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.
@@ -4814,6 +4814,13 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
4814
4814
  `[OM:reflect] blockAfter exceeded (${observationTokens} >= ${this.reflectionConfig.blockAfter}), falling through to sync reflection`
4815
4815
  );
4816
4816
  } else {
4817
+ const activationPoint = reflectThreshold * this.reflectionConfig.bufferActivation;
4818
+ if (observationTokens < activationPoint) {
4819
+ omDebug(
4820
+ `[OM:reflect] skipping async reflection \u2014 observationTokens (${observationTokens}) below activation point (${activationPoint}), triggered by ${activationTriggeredBy}`
4821
+ );
4822
+ return;
4823
+ }
4817
4824
  omDebug(
4818
4825
  `[OM:reflect] async activation failed, no blockAfter or below it (obsTokens=${observationTokens}, blockAfter=${this.reflectionConfig.blockAfter}) \u2014 starting background reflection`
4819
4826
  );
@@ -9170,6 +9177,15 @@ var ObservationalMemoryProcessor = class {
9170
9177
  if (readOnly) {
9171
9178
  return messageList;
9172
9179
  }
9180
+ const activeTurn = state.__omTurn ?? this.turn;
9181
+ if (activeTurn && activeTurn.messageList !== messageList) {
9182
+ await activeTurn.end().catch(() => {
9183
+ });
9184
+ if (this.turn === activeTurn) {
9185
+ this.turn = void 0;
9186
+ }
9187
+ state.__omTurn = void 0;
9188
+ }
9173
9189
  if (!this.turn || !state.__omTurn) {
9174
9190
  if (this.turn && !state.__omTurn) {
9175
9191
  await this.turn.end().catch(() => {
@@ -9334,5 +9350,5 @@ function getObservationsAsOf(activeObservations, asOf) {
9334
9350
  }
9335
9351
 
9336
9352
  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 };
9337
- //# sourceMappingURL=chunk-XLJGXHP5.js.map
9338
- //# sourceMappingURL=chunk-XLJGXHP5.js.map
9353
+ //# sourceMappingURL=chunk-Z5GWA7LB.js.map
9354
+ //# sourceMappingURL=chunk-Z5GWA7LB.js.map