@mastra/memory 1.11.1-alpha.0 → 1.12.0-alpha.1

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +1 -1
  3. package/dist/{chunk-2NZR2XHO.js → chunk-DDQHE4NV.js} +38 -20
  4. package/dist/chunk-DDQHE4NV.js.map +1 -0
  5. package/dist/{chunk-W2RTLXNQ.cjs → chunk-HLGFIN4J.cjs} +38 -20
  6. package/dist/chunk-HLGFIN4J.cjs.map +1 -0
  7. package/dist/docs/SKILL.md +1 -1
  8. package/dist/docs/assets/SOURCE_MAP.json +39 -39
  9. package/dist/docs/references/docs-memory-message-history.md +6 -4
  10. package/dist/docs/references/docs-memory-observational-memory.md +20 -11
  11. package/dist/docs/references/docs-memory-overview.md +4 -4
  12. package/dist/docs/references/docs-memory-semantic-recall.md +28 -19
  13. package/dist/docs/references/docs-memory-storage.md +4 -4
  14. package/dist/docs/references/reference-memory-observational-memory.md +1 -1
  15. package/dist/docs/references/reference-storage-dynamodb.md +1 -1
  16. package/dist/docs/references/reference-storage-upstash.md +1 -1
  17. package/dist/index.cjs +137 -22
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.js +130 -15
  20. package/dist/index.js.map +1 -1
  21. package/dist/{observational-memory-JCPPBSVG.cjs → observational-memory-34W4S4I5.cjs} +26 -26
  22. package/dist/{observational-memory-JCPPBSVG.cjs.map → observational-memory-34W4S4I5.cjs.map} +1 -1
  23. package/dist/{observational-memory-SASGM6OW.js → observational-memory-B25SASRW.js} +3 -3
  24. package/dist/{observational-memory-SASGM6OW.js.map → observational-memory-B25SASRW.js.map} +1 -1
  25. package/dist/processors/index.cjs +24 -24
  26. package/dist/processors/index.js +1 -1
  27. package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts +1 -0
  28. package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts.map +1 -1
  29. package/dist/processors/observational-memory/observation-strategies/base.d.ts +7 -2
  30. package/dist/processors/observational-memory/observation-strategies/base.d.ts.map +1 -1
  31. package/dist/processors/observational-memory/observation-strategies/resource-scoped.d.ts +1 -0
  32. package/dist/processors/observational-memory/observation-strategies/resource-scoped.d.ts.map +1 -1
  33. package/dist/processors/observational-memory/observation-strategies/sync.d.ts +1 -0
  34. package/dist/processors/observational-memory/observation-strategies/sync.d.ts.map +1 -1
  35. package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
  36. package/dist/tools/om-tools.d.ts.map +1 -1
  37. package/package.json +2 -2
  38. package/dist/chunk-2NZR2XHO.js.map +0 -1
  39. package/dist/chunk-W2RTLXNQ.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @mastra/memory
2
2
 
3
+ ## 1.12.0-alpha.1
4
+
5
+ ### Minor Changes
6
+
7
+ - Added more forgiving raw message browsing in the recall tool for agent follow-up calls. ([#14873](https://github.com/mastra-ai/mastra/pull/14873))
8
+
9
+ When an agent requests a `partIndex` greater than the highest visible part in a message, recall now returns the first visible part from the next visible message instead of failing. This makes it easier for agents using `recall` to keep browsing raw messages even when they guess the wrong part index.
10
+
11
+ ### Patch Changes
12
+
13
+ - Fixed synchronous observation error handling in Observational Memory. `observe()` now throws when synchronous (thread/resource-scoped) observation fails, instead of continuing silently with stale observations. Async buffered observation failures remain non-fatal. ([#14843](https://github.com/mastra-ai/mastra/pull/14843))
14
+
15
+ - Updated dependencies [[`9c57f2f`](https://github.com/mastra-ai/mastra/commit/9c57f2f7241e9f94769aa99fc86c531e8207d0f9), [`5bfc691`](https://github.com/mastra-ai/mastra/commit/5bfc69104c07ba7a9b55c2f8536422c0878b9c57)]:
16
+ - @mastra/core@1.19.0-alpha.2
17
+
3
18
  ## 1.11.1-alpha.0
4
19
 
5
20
  ### Patch Changes
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # Mastra Memory
2
2
 
3
- Memory management for Mastra agents. Visit [the docs](https://mastra.ai/docs/agents/agent-memory) for more information.
3
+ Memory management for Mastra agents. Visit [the docs](https://mastra.ai/docs/memory/overview) for more information.
@@ -943,7 +943,11 @@ var ObservationStrategy = class _ObservationStrategy {
943
943
  retrieval;
944
944
  /** Select the right strategy based on scope and mode. Wired up by index.ts. */
945
945
  static create;
946
- /** Run the full observation lifecycle. */
946
+ /**
947
+ * Run the full observation lifecycle.
948
+ * @returns `true` if a full observation cycle completed; `false` if skipped (stale lock) or async-buffer failure was swallowed.
949
+ * @throws On sync/resource-scoped observer failure after failed markers (same as pre–Option-A contract).
950
+ */
947
951
  async run() {
948
952
  const { record, threadId, abortSignal, writer, reflectionHooks, requestContext } = this.opts;
949
953
  const cycleId = this.generateCycleId();
@@ -951,7 +955,7 @@ var ObservationStrategy = class _ObservationStrategy {
951
955
  if (this.needsLock) {
952
956
  const fresh = await this.storage.getObservationalMemory(record.threadId, record.resourceId);
953
957
  if (fresh?.lastObservedAt && record.lastObservedAt && fresh.lastObservedAt > record.lastObservedAt) {
954
- return;
958
+ return false;
955
959
  }
956
960
  }
957
961
  const { messages, existingObservations } = await this.prepare();
@@ -972,23 +976,29 @@ var ObservationStrategy = class _ObservationStrategy {
972
976
  observabilityContext: this.opts.observabilityContext
973
977
  });
974
978
  }
979
+ return true;
975
980
  } catch (error) {
976
981
  await this.emitFailedMarkers(cycleId, error);
977
- const failedMarkerForStorage = {
978
- type: "data-om-observation-failed",
979
- data: {
980
- cycleId,
981
- operationType: "observation",
982
- startedAt: (/* @__PURE__ */ new Date()).toISOString(),
983
- error: error instanceof Error ? error.message : String(error),
984
- recordId: record.id,
985
- threadId
986
- }
987
- };
988
- await this.persistMarkerToStorage(failedMarkerForStorage, threadId, this.opts.resourceId).catch(() => {
989
- });
990
- if (abortSignal?.aborted) throw error;
982
+ if (!this.rethrowOnFailure) {
983
+ const failedMarkerForStorage = {
984
+ type: "data-om-observation-failed",
985
+ data: {
986
+ cycleId,
987
+ operationType: "observation",
988
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
989
+ error: error instanceof Error ? error.message : String(error),
990
+ recordId: record.id,
991
+ threadId
992
+ }
993
+ };
994
+ await this.persistMarkerToStorage(failedMarkerForStorage, threadId, this.opts.resourceId).catch(() => {
995
+ });
996
+ if (abortSignal?.aborted) throw error;
997
+ omError("[OM] Observation failed", error);
998
+ return false;
999
+ }
991
1000
  omError("[OM] Observation failed", error);
1001
+ throw error;
992
1002
  }
993
1003
  }
994
1004
  // ── Shared helpers ──────────────────────────────────────────
@@ -1209,6 +1219,9 @@ var SyncObservationStrategy = class extends ObservationStrategy {
1209
1219
  get needsReflection() {
1210
1220
  return true;
1211
1221
  }
1222
+ get rethrowOnFailure() {
1223
+ return true;
1224
+ }
1212
1225
  async prepare() {
1213
1226
  const { record, threadId, messages } = this.opts;
1214
1227
  this.deps.emitDebugEvent({
@@ -1402,6 +1415,9 @@ var AsyncBufferObservationStrategy = class extends ObservationStrategy {
1402
1415
  get needsReflection() {
1403
1416
  return false;
1404
1417
  }
1418
+ get rethrowOnFailure() {
1419
+ return false;
1420
+ }
1405
1421
  generateCycleId() {
1406
1422
  return this.cycleId;
1407
1423
  }
@@ -1538,6 +1554,9 @@ var ResourceScopedObservationStrategy = class extends ObservationStrategy {
1538
1554
  get needsReflection() {
1539
1555
  return true;
1540
1556
  }
1557
+ get rethrowOnFailure() {
1558
+ return true;
1559
+ }
1541
1560
  async prepare() {
1542
1561
  const { record, threadId: currentThreadId, messages: currentThreadMessages } = this.opts;
1543
1562
  const { threads: allThreads } = await this.storage.listThreads({ filter: { resourceId: this.resourceId } });
@@ -7806,7 +7825,7 @@ ${grouped}` : grouped;
7806
7825
  }
7807
7826
  hooks?.onObservationStart?.();
7808
7827
  try {
7809
- await ObservationStrategy.create(this, {
7828
+ observed = await ObservationStrategy.create(this, {
7810
7829
  record: freshRecord,
7811
7830
  threadId,
7812
7831
  resourceId,
@@ -7816,7 +7835,6 @@ ${grouped}` : grouped;
7816
7835
  writer: opts.writer,
7817
7836
  observabilityContext: opts.observabilityContext
7818
7837
  }).run();
7819
- observed = true;
7820
7838
  } finally {
7821
7839
  hooks?.onObservationEnd?.();
7822
7840
  }
@@ -8425,5 +8443,5 @@ function getObservationsAsOf(activeObservations, asOf) {
8425
8443
  }
8426
8444
 
8427
8445
  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 };
8428
- //# sourceMappingURL=chunk-2NZR2XHO.js.map
8429
- //# sourceMappingURL=chunk-2NZR2XHO.js.map
8446
+ //# sourceMappingURL=chunk-DDQHE4NV.js.map
8447
+ //# sourceMappingURL=chunk-DDQHE4NV.js.map