@mastra/memory 1.11.1-alpha.0 → 1.12.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 +32 -0
- package/README.md +1 -1
- package/dist/{chunk-2NZR2XHO.js → chunk-DDQHE4NV.js} +38 -20
- package/dist/chunk-DDQHE4NV.js.map +1 -0
- package/dist/{chunk-W2RTLXNQ.cjs → chunk-HLGFIN4J.cjs} +38 -20
- package/dist/chunk-HLGFIN4J.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +39 -39
- package/dist/docs/references/docs-memory-message-history.md +6 -4
- package/dist/docs/references/docs-memory-observational-memory.md +20 -11
- package/dist/docs/references/docs-memory-overview.md +4 -4
- package/dist/docs/references/docs-memory-semantic-recall.md +28 -19
- package/dist/docs/references/docs-memory-storage.md +4 -4
- package/dist/docs/references/reference-memory-observational-memory.md +1 -1
- package/dist/docs/references/reference-storage-dynamodb.md +1 -1
- package/dist/docs/references/reference-storage-upstash.md +1 -1
- package/dist/index.cjs +137 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +130 -15
- package/dist/index.js.map +1 -1
- package/dist/{observational-memory-JCPPBSVG.cjs → observational-memory-34W4S4I5.cjs} +26 -26
- package/dist/{observational-memory-JCPPBSVG.cjs.map → observational-memory-34W4S4I5.cjs.map} +1 -1
- package/dist/{observational-memory-SASGM6OW.js → observational-memory-B25SASRW.js} +3 -3
- package/dist/{observational-memory-SASGM6OW.js.map → observational-memory-B25SASRW.js.map} +1 -1
- package/dist/processors/index.cjs +24 -24
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts +1 -0
- package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-strategies/base.d.ts +7 -2
- package/dist/processors/observational-memory/observation-strategies/base.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-strategies/resource-scoped.d.ts +1 -0
- package/dist/processors/observational-memory/observation-strategies/resource-scoped.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-strategies/sync.d.ts +1 -0
- package/dist/processors/observational-memory/observation-strategies/sync.d.ts.map +1 -1
- package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
- package/dist/tools/om-tools.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/chunk-2NZR2XHO.js.map +0 -1
- package/dist/chunk-W2RTLXNQ.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @mastra/memory
|
|
2
2
|
|
|
3
|
+
## 1.12.0
|
|
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 reflected observation groups so their metadata stays compact and marks reflection-derived content. ([#14791](https://github.com/mastra-ai/mastra/pull/14791))
|
|
14
|
+
|
|
15
|
+
- 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))
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`180aaaf`](https://github.com/mastra-ai/mastra/commit/180aaaf4d0903d33a49bc72de2d40ca69a5bc599), [`9140989`](https://github.com/mastra-ai/mastra/commit/91409890e83f4f1d9c1b39223f1af91a6a53b549), [`d7c98cf`](https://github.com/mastra-ai/mastra/commit/d7c98cfc9d75baba9ecbf1a8835b5183d0a0aec8), [`acf5fbc`](https://github.com/mastra-ai/mastra/commit/acf5fbcb890dc7ca7167bec386ce5874dfadb997), [`24ca2ae`](https://github.com/mastra-ai/mastra/commit/24ca2ae57538ec189fabb9daee6175ad27035853), [`0762516`](https://github.com/mastra-ai/mastra/commit/07625167e029a8268ea7aaf0402416e6d8832874), [`9c57f2f`](https://github.com/mastra-ai/mastra/commit/9c57f2f7241e9f94769aa99fc86c531e8207d0f9), [`5bfc691`](https://github.com/mastra-ai/mastra/commit/5bfc69104c07ba7a9b55c2f8536422c0878b9c57), [`2de3d36`](https://github.com/mastra-ai/mastra/commit/2de3d36932b7f73ad26bc403f7da26cfe89e903e), [`d3736cb`](https://github.com/mastra-ai/mastra/commit/d3736cb9ce074d2b8e8b00218a01f790fe81a1b4), [`c627366`](https://github.com/mastra-ai/mastra/commit/c6273666f9ef4c8c617c68b7d07fe878a322f85c)]:
|
|
18
|
+
- @mastra/core@1.19.0
|
|
19
|
+
|
|
20
|
+
## 1.12.0-alpha.1
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- Added more forgiving raw message browsing in the recall tool for agent follow-up calls. ([#14873](https://github.com/mastra-ai/mastra/pull/14873))
|
|
25
|
+
|
|
26
|
+
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.
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- 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))
|
|
31
|
+
|
|
32
|
+
- Updated dependencies [[`9c57f2f`](https://github.com/mastra-ai/mastra/commit/9c57f2f7241e9f94769aa99fc86c531e8207d0f9), [`5bfc691`](https://github.com/mastra-ai/mastra/commit/5bfc69104c07ba7a9b55c2f8536422c0878b9c57)]:
|
|
33
|
+
- @mastra/core@1.19.0-alpha.2
|
|
34
|
+
|
|
3
35
|
## 1.11.1-alpha.0
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -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
|
-
/**
|
|
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
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
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-
|
|
8429
|
-
//# sourceMappingURL=chunk-
|
|
8446
|
+
//# sourceMappingURL=chunk-DDQHE4NV.js.map
|
|
8447
|
+
//# sourceMappingURL=chunk-DDQHE4NV.js.map
|