@mastra/memory 1.15.0-alpha.2 → 1.15.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.
@@ -4131,13 +4131,29 @@ var ReflectorRunner = class {
4131
4131
  model
4132
4132
  });
4133
4133
  }
4134
- getObservationMarkerConfig() {
4134
+ getObservationMarkerConfig(record) {
4135
4135
  return {
4136
4136
  messageTokens: getMaxThreshold(this.observationConfig.messageTokens),
4137
- observationTokens: getMaxThreshold(this.reflectionConfig.observationTokens),
4137
+ observationTokens: getMaxThreshold(
4138
+ record ? this.getEffectiveReflectionTokens(record) : this.reflectionConfig.observationTokens
4139
+ ),
4138
4140
  scope: this.scope
4139
4141
  };
4140
4142
  }
4143
+ /**
4144
+ * Resolve the effective reflection observationTokens for a record.
4145
+ * Only explicit per-record overrides (stored under `_overrides`) win;
4146
+ * the initial config snapshot is ignored so instance-level changes
4147
+ * still take effect for existing records.
4148
+ */
4149
+ getEffectiveReflectionTokens(record) {
4150
+ const overrides = record.config?._overrides;
4151
+ const recordTokens = overrides?.reflection?.observationTokens;
4152
+ if (recordTokens) {
4153
+ return recordTokens;
4154
+ }
4155
+ return this.reflectionConfig.observationTokens;
4156
+ }
4141
4157
  /**
4142
4158
  * Call the Reflector agent with escalating compression levels.
4143
4159
  */
@@ -4326,7 +4342,7 @@ var ReflectorRunner = class {
4326
4342
  const freshRecord = await this.storage.getObservationalMemory(record.threadId, record.resourceId);
4327
4343
  const currentRecord = freshRecord ?? record;
4328
4344
  const observationTokens = currentRecord.observationTokenCount ?? 0;
4329
- const reflectThreshold = getMaxThreshold(this.reflectionConfig.observationTokens);
4345
+ const reflectThreshold = getMaxThreshold(this.getEffectiveReflectionTokens(currentRecord));
4330
4346
  const bufferActivation = this.reflectionConfig.bufferActivation ?? 0.5;
4331
4347
  const startedAt = (/* @__PURE__ */ new Date()).toISOString();
4332
4348
  const cycleId = `reflect-buf-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
@@ -4355,7 +4371,7 @@ var ReflectorRunner = class {
4355
4371
  recordId: record.id,
4356
4372
  threadId: record.threadId ?? "",
4357
4373
  threadIds: record.threadId ? [record.threadId] : [],
4358
- config: this.getObservationMarkerConfig()
4374
+ config: this.getObservationMarkerConfig(currentRecord)
4359
4375
  });
4360
4376
  void writer.custom(startMarker).catch(() => {
4361
4377
  });
@@ -4467,7 +4483,7 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
4467
4483
  threadId: freshRecord.threadId ?? "",
4468
4484
  generationCount: afterRecord?.generationCount ?? freshRecord.generationCount ?? 0,
4469
4485
  observations: afterRecord?.activeObservations,
4470
- config: this.getObservationMarkerConfig()
4486
+ config: this.getObservationMarkerConfig(freshRecord)
4471
4487
  });
4472
4488
  void writer.custom(activationMarker).catch(() => {
4473
4489
  });
@@ -4498,7 +4514,7 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
4498
4514
  observabilityContext
4499
4515
  } = opts;
4500
4516
  const lockKey = this.buffering.getLockKey(record.threadId, record.resourceId);
4501
- const reflectThreshold = getMaxThreshold(this.reflectionConfig.observationTokens);
4517
+ const reflectThreshold = getMaxThreshold(this.getEffectiveReflectionTokens(record));
4502
4518
  if (this.buffering.isAsyncReflectionEnabled() && observationTokens < reflectThreshold) {
4503
4519
  const shouldTrigger = (() => {
4504
4520
  if (!this.buffering.isAsyncReflectionEnabled()) return false;
@@ -4577,7 +4593,7 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
4577
4593
  recordId: record.id,
4578
4594
  threadId,
4579
4595
  threadIds: [threadId],
4580
- config: this.getObservationMarkerConfig()
4596
+ config: this.getObservationMarkerConfig(record)
4581
4597
  });
4582
4598
  await writer.custom(startMarker).catch(() => {
4583
4599
  });
@@ -8850,5 +8866,5 @@ exports.stripEphemeralAnchorIds = stripEphemeralAnchorIds;
8850
8866
  exports.stripObservationGroups = stripObservationGroups;
8851
8867
  exports.truncateStringByTokens = truncateStringByTokens;
8852
8868
  exports.wrapInObservationGroup = wrapInObservationGroup;
8853
- //# sourceMappingURL=chunk-LAYKIEDY.cjs.map
8854
- //# sourceMappingURL=chunk-LAYKIEDY.cjs.map
8869
+ //# sourceMappingURL=chunk-WNLRMAHY.cjs.map
8870
+ //# sourceMappingURL=chunk-WNLRMAHY.cjs.map