@mastra/memory 1.3.0 → 1.4.0-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.
- package/CHANGELOG.md +54 -0
- package/dist/{chunk-F5P5HTMC.js → chunk-D4AWAGLM.js} +270 -203
- package/dist/chunk-D4AWAGLM.js.map +1 -0
- package/dist/{chunk-LXATBJ2L.cjs → chunk-QRKB5I2S.cjs} +270 -203
- package/dist/chunk-QRKB5I2S.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +25 -25
- package/dist/docs/references/reference-memory-observational-memory.md +36 -0
- package/dist/index.cjs +7 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/{observational-memory-3DA7KJIH.js → observational-memory-53AFLLSH.js} +3 -3
- package/dist/{observational-memory-3DA7KJIH.js.map → observational-memory-53AFLLSH.js.map} +1 -1
- package/dist/{observational-memory-SA5RITIG.cjs → observational-memory-UCOMAMSF.cjs} +17 -17
- package/dist/{observational-memory-SA5RITIG.cjs.map → observational-memory-UCOMAMSF.cjs.map} +1 -1
- package/dist/processors/index.cjs +15 -15
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/observational-memory.d.ts +6 -1
- package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
- package/dist/processors/observational-memory/observer-agent.d.ts +2 -2
- package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -1
- package/dist/processors/observational-memory/reflector-agent.d.ts +5 -3
- package/dist/processors/observational-memory/reflector-agent.d.ts.map +1 -1
- package/dist/processors/observational-memory/token-counter.d.ts.map +1 -1
- package/dist/processors/observational-memory/types.d.ts +10 -0
- package/dist/processors/observational-memory/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/chunk-F5P5HTMC.js.map +0 -1
- package/dist/chunk-LXATBJ2L.cjs.map +0 -1
package/dist/docs/SKILL.md
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.4.0-alpha.0",
|
|
3
3
|
"package": "@mastra/memory",
|
|
4
4
|
"exports": {
|
|
5
5
|
"OBSERVATIONAL_MEMORY_DEFAULTS": {
|
|
6
6
|
"types": "dist/processors/index.d.ts",
|
|
7
|
-
"implementation": "dist/chunk-
|
|
7
|
+
"implementation": "dist/chunk-D4AWAGLM.js"
|
|
8
8
|
},
|
|
9
9
|
"OBSERVATION_CONTEXT_INSTRUCTIONS": {
|
|
10
10
|
"types": "dist/processors/index.d.ts",
|
|
11
|
-
"implementation": "dist/chunk-
|
|
11
|
+
"implementation": "dist/chunk-D4AWAGLM.js"
|
|
12
12
|
},
|
|
13
13
|
"OBSERVATION_CONTEXT_PROMPT": {
|
|
14
14
|
"types": "dist/processors/index.d.ts",
|
|
15
|
-
"implementation": "dist/chunk-
|
|
15
|
+
"implementation": "dist/chunk-D4AWAGLM.js"
|
|
16
16
|
},
|
|
17
17
|
"OBSERVATION_CONTINUATION_HINT": {
|
|
18
18
|
"types": "dist/processors/index.d.ts",
|
|
19
|
-
"implementation": "dist/chunk-
|
|
19
|
+
"implementation": "dist/chunk-D4AWAGLM.js"
|
|
20
20
|
},
|
|
21
21
|
"OBSERVER_SYSTEM_PROMPT": {
|
|
22
22
|
"types": "dist/processors/index.d.ts",
|
|
23
|
-
"implementation": "dist/chunk-
|
|
23
|
+
"implementation": "dist/chunk-D4AWAGLM.js"
|
|
24
24
|
},
|
|
25
25
|
"ObservationalMemory": {
|
|
26
26
|
"types": "dist/processors/index.d.ts",
|
|
27
|
-
"implementation": "dist/chunk-
|
|
28
|
-
"line":
|
|
27
|
+
"implementation": "dist/chunk-D4AWAGLM.js",
|
|
28
|
+
"line": 1273
|
|
29
29
|
},
|
|
30
30
|
"TokenCounter": {
|
|
31
31
|
"types": "dist/processors/index.d.ts",
|
|
32
|
-
"implementation": "dist/chunk-
|
|
33
|
-
"line":
|
|
32
|
+
"implementation": "dist/chunk-D4AWAGLM.js",
|
|
33
|
+
"line": 936
|
|
34
34
|
},
|
|
35
35
|
"buildObserverPrompt": {
|
|
36
36
|
"types": "dist/processors/index.d.ts",
|
|
37
|
-
"implementation": "dist/chunk-
|
|
38
|
-
"line":
|
|
37
|
+
"implementation": "dist/chunk-D4AWAGLM.js",
|
|
38
|
+
"line": 606
|
|
39
39
|
},
|
|
40
40
|
"buildObserverSystemPrompt": {
|
|
41
41
|
"types": "dist/processors/index.d.ts",
|
|
42
|
-
"implementation": "dist/chunk-
|
|
43
|
-
"line":
|
|
42
|
+
"implementation": "dist/chunk-D4AWAGLM.js",
|
|
43
|
+
"line": 357
|
|
44
44
|
},
|
|
45
45
|
"extractCurrentTask": {
|
|
46
46
|
"types": "dist/processors/index.d.ts",
|
|
47
|
-
"implementation": "dist/chunk-
|
|
48
|
-
"line":
|
|
47
|
+
"implementation": "dist/chunk-D4AWAGLM.js",
|
|
48
|
+
"line": 692
|
|
49
49
|
},
|
|
50
50
|
"formatMessagesForObserver": {
|
|
51
51
|
"types": "dist/processors/index.d.ts",
|
|
52
|
-
"implementation": "dist/chunk-
|
|
53
|
-
"line":
|
|
52
|
+
"implementation": "dist/chunk-D4AWAGLM.js",
|
|
53
|
+
"line": 452
|
|
54
54
|
},
|
|
55
55
|
"hasCurrentTaskSection": {
|
|
56
56
|
"types": "dist/processors/index.d.ts",
|
|
57
|
-
"implementation": "dist/chunk-
|
|
58
|
-
"line":
|
|
57
|
+
"implementation": "dist/chunk-D4AWAGLM.js",
|
|
58
|
+
"line": 680
|
|
59
59
|
},
|
|
60
60
|
"optimizeObservationsForContext": {
|
|
61
61
|
"types": "dist/processors/index.d.ts",
|
|
62
|
-
"implementation": "dist/chunk-
|
|
63
|
-
"line":
|
|
62
|
+
"implementation": "dist/chunk-D4AWAGLM.js",
|
|
63
|
+
"line": 703
|
|
64
64
|
},
|
|
65
65
|
"parseObserverOutput": {
|
|
66
66
|
"types": "dist/processors/index.d.ts",
|
|
67
|
-
"implementation": "dist/chunk-
|
|
68
|
-
"line":
|
|
67
|
+
"implementation": "dist/chunk-D4AWAGLM.js",
|
|
68
|
+
"line": 637
|
|
69
69
|
},
|
|
70
70
|
"extractWorkingMemoryContent": {
|
|
71
71
|
"types": "dist/index.d.ts",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"processors": {
|
|
97
97
|
"index": "dist/processors/index.js",
|
|
98
98
|
"chunks": [
|
|
99
|
-
"chunk-
|
|
99
|
+
"chunk-D4AWAGLM.js"
|
|
100
100
|
]
|
|
101
101
|
}
|
|
102
102
|
}
|
|
@@ -42,6 +42,8 @@ The `observationalMemory` option accepts `true`, a configuration object, or `fal
|
|
|
42
42
|
|
|
43
43
|
**model?:** (`string | LanguageModel | DynamicModel | ModelWithRetries[]`): Model for the Observer agent. Cannot be set if a top-level \`model\` is also provided. If neither this nor the top-level \`model\` is set, falls back to \`reflection.model\`.
|
|
44
44
|
|
|
45
|
+
**instruction?:** (`string`): Custom instruction appended to the Observer's system prompt. Use this to customize what the Observer focuses on, such as domain-specific preferences or priorities.
|
|
46
|
+
|
|
45
47
|
**messageTokens?:** (`number`): Token count of unobserved messages that triggers observation. When unobserved message tokens exceed this threshold, the Observer agent is called. (Default: `30000`)
|
|
46
48
|
|
|
47
49
|
**maxTokensPerBatch?:** (`number`): Maximum tokens per batch when observing multiple threads in resource scope. Threads are chunked into batches of this size and processed in parallel. Lower values mean more parallelism but more API calls. (Default: `10000`)
|
|
@@ -58,6 +60,8 @@ The `observationalMemory` option accepts `true`, a configuration object, or `fal
|
|
|
58
60
|
|
|
59
61
|
**model?:** (`string | LanguageModel | DynamicModel | ModelWithRetries[]`): Model for the Reflector agent. Cannot be set if a top-level \`model\` is also provided. If neither this nor the top-level \`model\` is set, falls back to \`observation.model\`.
|
|
60
62
|
|
|
63
|
+
**instruction?:** (`string`): Custom instruction appended to the Reflector's system prompt. Use this to customize how the Reflector consolidates observations, such as prioritizing certain types of information.
|
|
64
|
+
|
|
61
65
|
**observationTokens?:** (`number`): Token count of observations that triggers reflection. When observation tokens exceed this threshold, the Reflector agent is called to condense them. (Default: `40000`)
|
|
62
66
|
|
|
63
67
|
**modelSettings?:** (`ObservationalMemoryModelSettings`): Model settings for the Reflector agent. (Default: `{ temperature: 0, maxOutputTokens: 100_000 }`)
|
|
@@ -175,6 +179,38 @@ export const agent = new Agent({
|
|
|
175
179
|
});
|
|
176
180
|
```
|
|
177
181
|
|
|
182
|
+
### Custom instructions
|
|
183
|
+
|
|
184
|
+
Customize what the Observer and Reflector focus on by providing custom instructions:
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
import { Memory } from "@mastra/memory";
|
|
188
|
+
import { Agent } from "@mastra/core/agent";
|
|
189
|
+
|
|
190
|
+
export const agent = new Agent({
|
|
191
|
+
name: "health-assistant",
|
|
192
|
+
instructions: "You are a health and wellness assistant.",
|
|
193
|
+
model: "openai/gpt-5-mini",
|
|
194
|
+
memory: new Memory({
|
|
195
|
+
options: {
|
|
196
|
+
observationalMemory: {
|
|
197
|
+
model: "google/gemini-2.5-flash",
|
|
198
|
+
observation: {
|
|
199
|
+
// Focus observations on health-related preferences and goals
|
|
200
|
+
instruction:
|
|
201
|
+
"Prioritize capturing user health goals, dietary restrictions, exercise preferences, and medical considerations. Avoid capturing general chit-chat.",
|
|
202
|
+
},
|
|
203
|
+
reflection: {
|
|
204
|
+
// Guide reflection to consolidate health patterns
|
|
205
|
+
instruction:
|
|
206
|
+
"When consolidating, group related health information together. Preserve specific metrics, dates, and medical details.",
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
}),
|
|
211
|
+
});
|
|
212
|
+
```
|
|
213
|
+
|
|
178
214
|
### Async buffering
|
|
179
215
|
|
|
180
216
|
Async buffering is **enabled by default**. It pre-computes observations in the background as the conversation grows — when the `messageTokens` threshold is reached, buffered observations activate instantly with no blocking LLM call.
|
package/dist/index.cjs
CHANGED
|
@@ -15229,7 +15229,7 @@ var Memory = class extends memory.MastraMemory {
|
|
|
15229
15229
|
}
|
|
15230
15230
|
await memoryStore.updateThread({
|
|
15231
15231
|
id: threadId,
|
|
15232
|
-
title: thread.title || "
|
|
15232
|
+
title: thread.title || "",
|
|
15233
15233
|
metadata: {
|
|
15234
15234
|
...thread.metadata,
|
|
15235
15235
|
workingMemory
|
|
@@ -15309,7 +15309,7 @@ ${workingMemory}`;
|
|
|
15309
15309
|
}
|
|
15310
15310
|
await memoryStore.updateThread({
|
|
15311
15311
|
id: threadId,
|
|
15312
|
-
title: thread.title || "
|
|
15312
|
+
title: thread.title || "",
|
|
15313
15313
|
metadata: {
|
|
15314
15314
|
...thread.metadata,
|
|
15315
15315
|
workingMemory
|
|
@@ -16146,7 +16146,7 @@ Notes:
|
|
|
16146
16146
|
"Observational memory async buffering is enabled by default but the installed version of @mastra/core does not support it. Either upgrade @mastra/core, @mastra/memory, and your storage adapter (@mastra/libsql, @mastra/pg, or @mastra/mongodb) to the latest version, or explicitly disable async buffering by setting `observation: { bufferTokens: false }` in your observationalMemory config."
|
|
16147
16147
|
);
|
|
16148
16148
|
}
|
|
16149
|
-
const { ObservationalMemory } = await import('./observational-memory-
|
|
16149
|
+
const { ObservationalMemory } = await import('./observational-memory-UCOMAMSF.cjs');
|
|
16150
16150
|
return new ObservationalMemory({
|
|
16151
16151
|
storage: memoryStore,
|
|
16152
16152
|
scope: omConfig.scope,
|
|
@@ -16160,7 +16160,8 @@ Notes:
|
|
|
16160
16160
|
providerOptions: omConfig.observation.providerOptions,
|
|
16161
16161
|
bufferTokens: omConfig.observation.bufferTokens,
|
|
16162
16162
|
bufferActivation: omConfig.observation.bufferActivation,
|
|
16163
|
-
blockAfter: omConfig.observation.blockAfter
|
|
16163
|
+
blockAfter: omConfig.observation.blockAfter,
|
|
16164
|
+
instruction: omConfig.observation.instruction
|
|
16164
16165
|
} : void 0,
|
|
16165
16166
|
reflection: omConfig.reflection ? {
|
|
16166
16167
|
model: omConfig.reflection.model,
|
|
@@ -16168,7 +16169,8 @@ Notes:
|
|
|
16168
16169
|
modelSettings: omConfig.reflection.modelSettings,
|
|
16169
16170
|
providerOptions: omConfig.reflection.providerOptions,
|
|
16170
16171
|
bufferActivation: omConfig.reflection.bufferActivation,
|
|
16171
|
-
blockAfter: omConfig.reflection.blockAfter
|
|
16172
|
+
blockAfter: omConfig.reflection.blockAfter,
|
|
16173
|
+
instruction: omConfig.reflection.instruction
|
|
16172
16174
|
} : void 0
|
|
16173
16175
|
});
|
|
16174
16176
|
}
|