@mastra/memory 1.39.1-alpha.1 → 1.39.1-alpha.3
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/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +56 -56
- package/dist/docs/references/docs-agents-human-in-the-loop.md +9 -0
- package/dist/docs/references/docs-harness-background-tasks.md +4 -0
- package/dist/docs/references/docs-harness-goals.md +2 -0
- package/dist/docs/references/docs-memory-message-history.md +3 -0
- package/dist/docs/references/docs-memory-observational-memory.md +10 -0
- package/dist/docs/references/docs-memory-overview.md +6 -0
- package/dist/docs/references/docs-memory-semantic-recall.md +5 -1
- package/dist/docs/references/docs-subagents.md +7 -1
- package/dist/docs/references/integrations-databases-aurora-dsql.md +2 -2
- package/dist/docs/references/integrations-databases-dynamodb.md +4 -4
- package/dist/docs/references/integrations-databases-postgresql.md +4 -4
- package/dist/docs/references/reference-memory-memory-class.md +2 -2
- package/dist/docs/references/reference-memory-observational-memory.md +10 -10
- package/dist/docs/references/reference-memory-summarizeConversation.md +1 -1
- package/dist/docs/references/reference-memory-summarizeThread.md +1 -1
- package/dist/docs/references/reference-vectors-mongodb.md +6 -6
- package/dist/docs/references/reference-vectors-pg.md +1 -1
- package/dist/docs/references/reference-vectors-upstash.md +8 -4
- package/dist/hooks.cjs +1 -2
- package/dist/hooks.js +1 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/processors/index.cjs +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/buffering-coordinator.d.ts +1 -1
- package/dist/processors/observational-memory/buffering-coordinator.d.ts.map +1 -1
- package/dist/processors/observational-memory/commit-queue.d.ts +5 -1
- package/dist/processors/observational-memory/commit-queue.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-strategies/base.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-strategies/resource-scoped.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-strategies/sync.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-turn/step.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-turn/turn.d.ts +2 -0
- package/dist/processors/observational-memory/observation-turn/turn.d.ts.map +1 -1
- package/dist/processors/observational-memory/observational-memory.d.ts +7 -2
- package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
- package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -1
- package/dist/processors/observational-memory/observer-runner.d.ts.map +1 -1
- package/dist/processors/observational-memory/processor.d.ts.map +1 -1
- package/dist/processors/observational-memory/reflector-runner.d.ts +2 -2
- package/dist/processors/observational-memory/reflector-runner.d.ts.map +1 -1
- package/dist/processors/observational-memory/retry.d.ts +11 -0
- package/dist/processors/observational-memory/retry.d.ts.map +1 -1
- package/dist/processors/observational-memory/thresholds.d.ts.map +1 -1
- package/dist/processors/observational-memory/token-counter.d.ts.map +1 -1
- package/dist/processors/observational-memory/tool-result-helpers.d.ts +6 -0
- package/dist/processors/observational-memory/tool-result-helpers.d.ts.map +1 -1
- package/dist/processors/observational-memory/wait-with-abort.d.ts +3 -0
- package/dist/processors/observational-memory/wait-with-abort.d.ts.map +1 -0
- package/dist/{src-BjH9gT88.cjs → src-IwP0x4uF.cjs} +1184 -726
- package/dist/src-IwP0x4uF.cjs.map +1 -0
- package/dist/{src-BUWL69LT.js → src-kIpEG6XZ.js} +1185 -727
- package/dist/src-kIpEG6XZ.js.map +1 -0
- package/package.json +12 -13
- package/dist/processors/observational-memory/context-overflow.d.ts +0 -2
- package/dist/processors/observational-memory/context-overflow.d.ts.map +0 -1
- package/dist/src-BUWL69LT.js.map +0 -1
- package/dist/src-BjH9gT88.cjs.map +0 -1
package/dist/docs/SKILL.md
CHANGED
|
@@ -1,229 +1,229 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.39.1-alpha.
|
|
2
|
+
"version": "1.39.1-alpha.3",
|
|
3
3
|
"package": "@mastra/memory",
|
|
4
4
|
"exports": {
|
|
5
5
|
"d": {
|
|
6
6
|
"types": "dist/processors/index.d.ts",
|
|
7
|
-
"implementation": "dist/src-
|
|
7
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
8
8
|
},
|
|
9
9
|
"et": {
|
|
10
10
|
"types": "dist/processors/index.d.ts",
|
|
11
|
-
"implementation": "dist/src-
|
|
11
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
12
12
|
},
|
|
13
13
|
"K": {
|
|
14
14
|
"types": "dist/processors/index.d.ts",
|
|
15
|
-
"implementation": "dist/src-
|
|
15
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
16
16
|
},
|
|
17
17
|
"Y": {
|
|
18
18
|
"types": "dist/processors/index.d.ts",
|
|
19
|
-
"implementation": "dist/src-
|
|
19
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
20
20
|
},
|
|
21
21
|
"z": {
|
|
22
22
|
"types": "dist/processors/index.d.ts",
|
|
23
|
-
"implementation": "dist/src-
|
|
23
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
24
24
|
},
|
|
25
25
|
"B": {
|
|
26
26
|
"types": "dist/processors/index.d.ts",
|
|
27
|
-
"implementation": "dist/src-
|
|
27
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
28
28
|
},
|
|
29
29
|
"V": {
|
|
30
30
|
"types": "dist/processors/index.d.ts",
|
|
31
|
-
"implementation": "dist/src-
|
|
31
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
32
32
|
},
|
|
33
33
|
"H": {
|
|
34
34
|
"types": "dist/processors/index.d.ts",
|
|
35
|
-
"implementation": "dist/src-
|
|
35
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
36
36
|
},
|
|
37
37
|
"U": {
|
|
38
38
|
"types": "dist/processors/index.d.ts",
|
|
39
|
-
"implementation": "dist/src-
|
|
39
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
40
40
|
},
|
|
41
41
|
"O": {
|
|
42
42
|
"types": "dist/processors/index.d.ts",
|
|
43
|
-
"implementation": "dist/src-
|
|
43
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
44
44
|
},
|
|
45
45
|
"u": {
|
|
46
46
|
"types": "dist/processors/index.d.ts",
|
|
47
|
-
"implementation": "dist/src-
|
|
47
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
48
48
|
},
|
|
49
49
|
"l": {
|
|
50
50
|
"types": "dist/processors/index.d.ts",
|
|
51
|
-
"implementation": "dist/src-
|
|
51
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
52
52
|
},
|
|
53
53
|
"X": {
|
|
54
54
|
"types": "dist/processors/index.d.ts",
|
|
55
|
-
"implementation": "dist/src-
|
|
55
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
56
56
|
},
|
|
57
57
|
"q": {
|
|
58
58
|
"types": "dist/processors/index.d.ts",
|
|
59
|
-
"implementation": "dist/src-
|
|
59
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
60
60
|
},
|
|
61
61
|
"G": {
|
|
62
62
|
"types": "dist/processors/index.d.ts",
|
|
63
|
-
"implementation": "dist/src-
|
|
63
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
64
64
|
},
|
|
65
65
|
"J": {
|
|
66
66
|
"types": "dist/processors/index.d.ts",
|
|
67
|
-
"implementation": "dist/src-
|
|
67
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
68
68
|
},
|
|
69
69
|
"D": {
|
|
70
70
|
"types": "dist/processors/index.d.ts",
|
|
71
|
-
"implementation": "dist/src-
|
|
71
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
72
72
|
},
|
|
73
73
|
"C": {
|
|
74
74
|
"types": "dist/processors/index.d.ts",
|
|
75
|
-
"implementation": "dist/src-
|
|
75
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
76
76
|
},
|
|
77
77
|
"k": {
|
|
78
78
|
"types": "dist/processors/index.d.ts",
|
|
79
|
-
"implementation": "dist/src-
|
|
79
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
80
80
|
},
|
|
81
81
|
"A": {
|
|
82
82
|
"types": "dist/processors/index.d.ts",
|
|
83
|
-
"implementation": "dist/src-
|
|
83
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
84
84
|
},
|
|
85
85
|
"Z": {
|
|
86
86
|
"types": "dist/processors/index.d.ts",
|
|
87
|
-
"implementation": "dist/src-
|
|
87
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
88
88
|
},
|
|
89
89
|
"g": {
|
|
90
90
|
"types": "dist/processors/index.d.ts",
|
|
91
|
-
"implementation": "dist/src-
|
|
91
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
92
92
|
},
|
|
93
93
|
"_": {
|
|
94
94
|
"types": "dist/processors/index.d.ts",
|
|
95
|
-
"implementation": "dist/src-
|
|
95
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
96
96
|
},
|
|
97
97
|
"j": {
|
|
98
98
|
"types": "dist/processors/index.d.ts",
|
|
99
|
-
"implementation": "dist/src-
|
|
99
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
100
100
|
},
|
|
101
101
|
"M": {
|
|
102
102
|
"types": "dist/processors/index.d.ts",
|
|
103
|
-
"implementation": "dist/src-
|
|
103
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
104
104
|
},
|
|
105
105
|
"W": {
|
|
106
106
|
"types": "dist/processors/index.d.ts",
|
|
107
|
-
"implementation": "dist/src-
|
|
107
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
108
108
|
},
|
|
109
109
|
"c": {
|
|
110
110
|
"types": "dist/processors/index.d.ts",
|
|
111
|
-
"implementation": "dist/src-
|
|
111
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
112
112
|
},
|
|
113
113
|
"N": {
|
|
114
114
|
"types": "dist/processors/index.d.ts",
|
|
115
|
-
"implementation": "dist/src-
|
|
115
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
116
116
|
},
|
|
117
117
|
"I": {
|
|
118
118
|
"types": "dist/processors/index.d.ts",
|
|
119
|
-
"implementation": "dist/src-
|
|
119
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
120
120
|
},
|
|
121
121
|
"P": {
|
|
122
122
|
"types": "dist/processors/index.d.ts",
|
|
123
|
-
"implementation": "dist/src-
|
|
123
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
124
124
|
},
|
|
125
125
|
"L": {
|
|
126
126
|
"types": "dist/processors/index.d.ts",
|
|
127
|
-
"implementation": "dist/src-
|
|
127
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
128
128
|
},
|
|
129
129
|
"v": {
|
|
130
130
|
"types": "dist/processors/index.d.ts",
|
|
131
|
-
"implementation": "dist/src-
|
|
131
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
132
132
|
},
|
|
133
133
|
"F": {
|
|
134
134
|
"types": "dist/processors/index.d.ts",
|
|
135
|
-
"implementation": "dist/src-
|
|
135
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
136
136
|
},
|
|
137
137
|
"Q": {
|
|
138
138
|
"types": "dist/processors/index.d.ts",
|
|
139
|
-
"implementation": "dist/src-
|
|
139
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
140
140
|
},
|
|
141
141
|
"y": {
|
|
142
142
|
"types": "dist/processors/index.d.ts",
|
|
143
|
-
"implementation": "dist/src-
|
|
143
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
144
144
|
},
|
|
145
145
|
"b": {
|
|
146
146
|
"types": "dist/processors/index.d.ts",
|
|
147
|
-
"implementation": "dist/src-
|
|
147
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
148
148
|
},
|
|
149
149
|
"$": {
|
|
150
150
|
"types": "dist/processors/index.d.ts",
|
|
151
|
-
"implementation": "dist/src-
|
|
151
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
152
152
|
},
|
|
153
153
|
"f": {
|
|
154
154
|
"types": "dist/processors/index.d.ts",
|
|
155
|
-
"implementation": "dist/src-
|
|
155
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
156
156
|
},
|
|
157
157
|
"R": {
|
|
158
158
|
"types": "dist/processors/index.d.ts",
|
|
159
|
-
"implementation": "dist/src-
|
|
159
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
160
160
|
},
|
|
161
161
|
"x": {
|
|
162
162
|
"types": "dist/processors/index.d.ts",
|
|
163
|
-
"implementation": "dist/src-
|
|
163
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
164
164
|
},
|
|
165
165
|
"E": {
|
|
166
166
|
"types": "dist/processors/index.d.ts",
|
|
167
|
-
"implementation": "dist/src-
|
|
167
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
168
168
|
},
|
|
169
169
|
"S": {
|
|
170
170
|
"types": "dist/processors/index.d.ts",
|
|
171
|
-
"implementation": "dist/src-
|
|
171
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
172
172
|
},
|
|
173
173
|
"t": {
|
|
174
174
|
"types": "dist/index.d.ts",
|
|
175
|
-
"implementation": "dist/src-
|
|
175
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
176
176
|
},
|
|
177
177
|
"n": {
|
|
178
178
|
"types": "dist/index.d.ts",
|
|
179
|
-
"implementation": "dist/src-
|
|
179
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
180
180
|
},
|
|
181
181
|
"T": {
|
|
182
182
|
"types": "dist/index.d.ts",
|
|
183
|
-
"implementation": "dist/src-
|
|
183
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
184
184
|
},
|
|
185
185
|
"r": {
|
|
186
186
|
"types": "dist/index.d.ts",
|
|
187
|
-
"implementation": "dist/src-
|
|
187
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
188
188
|
},
|
|
189
189
|
"p": {
|
|
190
190
|
"types": "dist/index.d.ts",
|
|
191
|
-
"implementation": "dist/src-
|
|
191
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
192
192
|
},
|
|
193
193
|
"m": {
|
|
194
194
|
"types": "dist/index.d.ts",
|
|
195
|
-
"implementation": "dist/src-
|
|
195
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
196
196
|
},
|
|
197
197
|
"i": {
|
|
198
198
|
"types": "dist/index.d.ts",
|
|
199
|
-
"implementation": "dist/src-
|
|
199
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
200
200
|
},
|
|
201
201
|
"h": {
|
|
202
202
|
"types": "dist/index.d.ts",
|
|
203
|
-
"implementation": "dist/src-
|
|
203
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
204
204
|
},
|
|
205
205
|
"w": {
|
|
206
206
|
"types": "dist/index.d.ts",
|
|
207
|
-
"implementation": "dist/src-
|
|
207
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
208
208
|
},
|
|
209
209
|
"a": {
|
|
210
210
|
"types": "dist/index.d.ts",
|
|
211
|
-
"implementation": "dist/src-
|
|
211
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
212
212
|
},
|
|
213
213
|
"o": {
|
|
214
214
|
"types": "dist/index.d.ts",
|
|
215
|
-
"implementation": "dist/src-
|
|
215
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
216
216
|
},
|
|
217
217
|
"s": {
|
|
218
218
|
"types": "dist/index.d.ts",
|
|
219
|
-
"implementation": "dist/src-
|
|
219
|
+
"implementation": "dist/src-kIpEG6XZ.js"
|
|
220
220
|
}
|
|
221
221
|
},
|
|
222
222
|
"modules": {
|
|
223
223
|
"processors": {
|
|
224
224
|
"index": "dist/processors/index.js",
|
|
225
225
|
"chunks": [
|
|
226
|
-
"src-
|
|
226
|
+
"src-kIpEG6XZ.js"
|
|
227
227
|
]
|
|
228
228
|
}
|
|
229
229
|
}
|
|
@@ -311,6 +311,9 @@ Instead of pausing every tool call at the agent level, you can mark individual t
|
|
|
311
311
|
Set `requireApproval: true` on a tool definition. The tool pauses before execution regardless of whether `requireToolApproval` is set on the agent:
|
|
312
312
|
|
|
313
313
|
```typescript
|
|
314
|
+
import { createTool } from '@mastra/core/tools'
|
|
315
|
+
import { z } from 'zod'
|
|
316
|
+
|
|
314
317
|
export const testTool = createTool({
|
|
315
318
|
id: 'test-tool',
|
|
316
319
|
description: 'Fetches weather for a location',
|
|
@@ -359,6 +362,9 @@ const handleApproval = async () => {
|
|
|
359
362
|
With this approach, neither the agent nor the tool uses `requireApproval`. Instead, the tool's `execute` function calls `suspend()` to pause at a specific point and return context or confirmation prompts to the user. This is useful when approval depends on runtime conditions rather than being unconditional.
|
|
360
363
|
|
|
361
364
|
```typescript
|
|
365
|
+
import { createTool } from '@mastra/core/tools'
|
|
366
|
+
import { z } from 'zod'
|
|
367
|
+
|
|
362
368
|
export const testToolB = createTool({
|
|
363
369
|
id: 'test-tool-b',
|
|
364
370
|
description: 'Fetches weather for a location',
|
|
@@ -662,6 +668,9 @@ for await (const chunk of stream.fullStream) {
|
|
|
662
668
|
Tools can also use [`suspend()`](#approval-using-suspend) to pause execution and return context to the user. This approach works through the supervisor delegation chain the same way `requireApproval` does: the suspension surfaces at the supervisor level:
|
|
663
669
|
|
|
664
670
|
```typescript
|
|
671
|
+
import { createTool } from '@mastra/core/tools'
|
|
672
|
+
import { z } from 'zod'
|
|
673
|
+
|
|
665
674
|
const conditionalTool = createTool({
|
|
666
675
|
id: 'conditional-operation',
|
|
667
676
|
description: 'Performs an operation that may require confirmation',
|
|
@@ -224,6 +224,8 @@ If a subagent isn't listed under the supervisor's `backgroundTasks.tools` but ha
|
|
|
224
224
|
The background config used for the inherited dispatch (for example `waitTimeoutMs`) is derived from the subagent's own `backgroundTasks` config.
|
|
225
225
|
|
|
226
226
|
```typescript
|
|
227
|
+
import { Agent } from '@mastra/core/agent'
|
|
228
|
+
|
|
227
229
|
const researchAgent = new Agent({
|
|
228
230
|
id: 'research-agent',
|
|
229
231
|
description: 'Gathers factual information.',
|
|
@@ -311,6 +313,8 @@ Each layer can register terminal-state callbacks. They don't replace one another
|
|
|
311
313
|
- Manager-level `onTaskComplete` / `onTaskFailed`: scoped globally.
|
|
312
314
|
|
|
313
315
|
```typescript
|
|
316
|
+
import { Mastra } from '@mastra/core'
|
|
317
|
+
|
|
314
318
|
export const mastra = new Mastra({
|
|
315
319
|
storage,
|
|
316
320
|
backgroundTasks: {
|
|
@@ -87,6 +87,8 @@ Pass `goal.scorer` to replace the pipeline with your own [scorer](https://mastra
|
|
|
87
87
|
Configure the default scorer with `judge`, `maxRuns`, and `prompt`:
|
|
88
88
|
|
|
89
89
|
```typescript
|
|
90
|
+
import { Agent } from '@mastra/core/agent'
|
|
91
|
+
|
|
90
92
|
const worker = new Agent({
|
|
91
93
|
id: 'worker',
|
|
92
94
|
name: 'worker',
|
|
@@ -138,6 +138,9 @@ If you assemble the request input yourself and need it processed exactly as sent
|
|
|
138
138
|
Message count is a poor proxy for context size: a tool result can be a few tokens or thousands. Use `messageHistory` to keep recent history within a token budget instead:
|
|
139
139
|
|
|
140
140
|
```typescript
|
|
141
|
+
import { Agent } from '@mastra/core/agent'
|
|
142
|
+
import { Memory } from '@mastra/memory'
|
|
143
|
+
|
|
141
144
|
export const agent = new Agent({
|
|
142
145
|
id: 'test-agent',
|
|
143
146
|
memory: new Memory({
|
|
@@ -149,6 +149,8 @@ OM can activate buffered observations before the token threshold is reached. Thi
|
|
|
149
149
|
Top-level early activation settings apply to observations by default:
|
|
150
150
|
|
|
151
151
|
```typescript
|
|
152
|
+
import { Memory } from '@mastra/memory'
|
|
153
|
+
|
|
152
154
|
const memory = new Memory({
|
|
153
155
|
options: {
|
|
154
156
|
observationalMemory: {
|
|
@@ -163,6 +165,8 @@ const memory = new Memory({
|
|
|
163
165
|
Use nested `observation` and `reflection` settings for per-phase control. Reflection early activation is opt-in, so top-level settings affect only observations.
|
|
164
166
|
|
|
165
167
|
```typescript
|
|
168
|
+
import { Memory } from '@mastra/memory'
|
|
169
|
+
|
|
166
170
|
const memory = new Memory({
|
|
167
171
|
options: {
|
|
168
172
|
observationalMemory: {
|
|
@@ -187,6 +191,8 @@ In this example, the top-level idle setting is disabled for observations, while
|
|
|
187
191
|
Set `observation.bufferOnIdle` to `true` to run background observation buffering when an agent turn ends and the agent becomes idle. This is useful for apps that want short turns to be observed without waiting for the next turn or the `messageTokens` threshold.
|
|
188
192
|
|
|
189
193
|
```typescript
|
|
194
|
+
import { Memory } from '@mastra/memory'
|
|
195
|
+
|
|
190
196
|
const memory = new Memory({
|
|
191
197
|
options: {
|
|
192
198
|
observationalMemory: {
|
|
@@ -209,6 +215,8 @@ Observer and Reflector model calls are retried on transient provider errors. By
|
|
|
209
215
|
- `failurePolicy`: what happens once retries are exhausted, either `'abort'` (default) or `'continue'`.
|
|
210
216
|
|
|
211
217
|
```typescript
|
|
218
|
+
import { Memory } from '@mastra/memory'
|
|
219
|
+
|
|
212
220
|
const memory = new Memory({
|
|
213
221
|
options: {
|
|
214
222
|
observationalMemory: {
|
|
@@ -391,6 +399,8 @@ This setting adds `WorkingMemoryExtractor`, defaults `workingMemory.agentManaged
|
|
|
391
399
|
Use `onExtracted` to normalize or react to custom extracted values before they're persisted:
|
|
392
400
|
|
|
393
401
|
```typescript
|
|
402
|
+
import { z } from 'zod'
|
|
403
|
+
|
|
394
404
|
new Extractor({
|
|
395
405
|
name: 'Project status',
|
|
396
406
|
instructions: 'Extract the current project status.',
|
|
@@ -164,6 +164,9 @@ const response = await memoryAgent.generate('Remember my favorite color is blue.
|
|
|
164
164
|
Scopes can also come from the agent and from the request context. Mastra combines all three sources:
|
|
165
165
|
|
|
166
166
|
```typescript
|
|
167
|
+
import { Agent } from '@mastra/core/agent'
|
|
168
|
+
import { Memory } from '@mastra/memory'
|
|
169
|
+
|
|
167
170
|
export const memoryAgent = new Agent({
|
|
168
171
|
id: 'memory-agent',
|
|
169
172
|
name: 'Memory Agent',
|
|
@@ -271,6 +274,9 @@ Open [Studio](https://mastra.ai/docs/studio/overview) and select the **Observabi
|
|
|
271
274
|
Use [`RequestContext`](https://mastra.ai/docs/server/request-context) to access request-specific values. This lets you conditionally select different memory or storage configurations based on the context of the request.
|
|
272
275
|
|
|
273
276
|
```typescript
|
|
277
|
+
import { Agent } from '@mastra/core/agent'
|
|
278
|
+
import { Memory } from '@mastra/memory'
|
|
279
|
+
|
|
274
280
|
export type UserTier = {
|
|
275
281
|
'user-tier': 'enterprise' | 'pro'
|
|
276
282
|
}
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
# Semantic recall
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Semantic recall is a built-in form of Retrieval-Augmented Generation (RAG) for agent memory. When a user sends a message, Mastra searches earlier messages for ones with a similar meaning and adds the most relevant ones to the agent's context.
|
|
8
|
+
|
|
9
|
+
Matching on meaning matters because people often remember the idea behind something, not the exact words they used. A user might ask "What did we decide about the refund?" after originally writing "Let's give them their money back." A keyword search misses that connection, but semantic recall finds it.
|
|
10
|
+
|
|
11
|
+
Use semantic recall when your agent needs details from earlier in a long conversation, or from a user's other conversations, that are no longer in [recent message history](https://mastra.ai/docs/memory/message-history).
|
|
8
12
|
|
|
9
13
|
> **📹 Watch:** Watch [Mastra semantic recall](https://www.youtube.com/watch?v=UVZtK8cK8xQ\&pp=ygUVbWFzdHJhIHdvcmtpbmcgbWVtb3J5) to see how agents retrieve relevant messages from past conversations.
|
|
10
14
|
|
|
@@ -72,9 +72,11 @@ Called before the parent agent delegates to a subagent. Return an object to cont
|
|
|
72
72
|
- `proceed: true`: Allow the delegation (default behavior)
|
|
73
73
|
- `proceed: false`: Reject the delegation with a `rejectionReason`
|
|
74
74
|
- `modifiedPrompt`: Rewrite the prompt sent to the subagent
|
|
75
|
-
- `modifiedMaxSteps`:
|
|
75
|
+
- `modifiedMaxSteps`: Set the subagent's iteration budget. This overrides the cap on the model-supplied `maxSteps`, so it can raise the budget as well as lower it
|
|
76
76
|
- `threadMetadata`: Attach metadata (for example a `tenantId`) to the subagent's thread when it's created, so you can filter threads with `memory.listThreads({ filter: { metadata } })`
|
|
77
77
|
|
|
78
|
+
> **Note:** When the supervisor model passes `maxSteps` to a delegation, Mastra caps it at the subagent's `defaultOptions.maxSteps`. The model can lower the subagent's budget that way, but not raise it. `modifiedMaxSteps` is applied after that cap and replaces the capped value, so it can raise the budget above the subagent's default. Use it to stop a supervisor model from cutting a subagent short.
|
|
79
|
+
|
|
78
80
|
```typescript
|
|
79
81
|
const stream = await parentAgent.stream('Research AI trends', {
|
|
80
82
|
maxSteps: 10,
|
|
@@ -221,6 +223,8 @@ const stream = await parentAgent.stream('Research AI trends', {
|
|
|
221
223
|
Either way, every hook failure is recorded on the run's request context under `__mastra_delegationHookErrors` as a list of `{ hook, primitiveId, toolCallId, runId, name, message }` entries, so you can detect a hook failure programmatically:
|
|
222
224
|
|
|
223
225
|
```typescript
|
|
226
|
+
import { RequestContext } from '@mastra/core/request-context'
|
|
227
|
+
|
|
224
228
|
const requestContext = new RequestContext()
|
|
225
229
|
|
|
226
230
|
await parentAgent.generate('Research AI trends', { maxSteps: 10, requestContext })
|
|
@@ -495,6 +499,8 @@ Subagent invocations are dispatched as tool calls, so they can run as [backgroun
|
|
|
495
499
|
Enable the [backgroundTasks manager](https://mastra.ai/reference/configuration) on the Mastra instance, then opt subagents in on the parent agent:
|
|
496
500
|
|
|
497
501
|
```typescript
|
|
502
|
+
import { Agent } from '@mastra/core/agent'
|
|
503
|
+
|
|
498
504
|
const parentAgent = new Agent({
|
|
499
505
|
id: 'parent-agent',
|
|
500
506
|
instructions: 'Coordinate research and writing using the available agents.',
|
|
@@ -309,7 +309,7 @@ Aurora DSQL storage provides index management capabilities to optimize query per
|
|
|
309
309
|
Aurora DSQL storage automatically creates composite indexes during initialization for common query patterns:
|
|
310
310
|
|
|
311
311
|
- `mastra_threads_resourceid_createdat_idx`: (resourceId, createdAt)
|
|
312
|
-
- `mastra_messages_thread_id_createdat_idx`: (
|
|
312
|
+
- `mastra_messages_thread_id_createdat_idx`: (thread_id, createdAt)
|
|
313
313
|
- `mastra_ai_spans_traceid_startedat_idx`: (traceId, startedAt)
|
|
314
314
|
- `mastra_ai_spans_parentspanid_startedat_idx`: (parentSpanId, startedAt)
|
|
315
315
|
- `mastra_ai_spans_name_idx`: (name)
|
|
@@ -342,7 +342,7 @@ Aurora DSQL doesn't allow `ASC`/`DESC` in `CREATE INDEX ASYNC`. If you include t
|
|
|
342
342
|
|
|
343
343
|
**name** (`string`): Unique name for the index
|
|
344
344
|
|
|
345
|
-
**table** (`string`): Table name (e.g., '
|
|
345
|
+
**table** (`string`): Table name (e.g., 'mastra_threads')
|
|
346
346
|
|
|
347
347
|
**columns** (`string[]`): Array of column names. ASC/DESC modifiers are automatically stripped for Aurora DSQL compatibility.
|
|
348
348
|
|
|
@@ -50,7 +50,7 @@ bun add @mastra/dynamodb@latest
|
|
|
50
50
|
|
|
51
51
|
Before using this package, you **must** create a DynamoDB table with a specific structure, including primary keys and Global Secondary Indexes (GSIs). This adapter expects the DynamoDB table and its GSIs to be provisioned externally.
|
|
52
52
|
|
|
53
|
-
Detailed instructions for setting up the table using AWS CloudFormation or AWS CDK are available in [
|
|
53
|
+
Detailed instructions for setting up the table using AWS CloudFormation or AWS CDK are available in [TABLE_SETUP.md](https://github.com/mastra-ai/mastra/blob/main/stores/dynamodb/TABLE_SETUP.md). Please ensure your table is configured according to those instructions before proceeding.
|
|
54
54
|
|
|
55
55
|
## Usage
|
|
56
56
|
|
|
@@ -122,7 +122,7 @@ For local development, you can use [DynamoDB Local](https://docs.aws.amazon.com/
|
|
|
122
122
|
|
|
123
123
|
**config.credentials** (`object`): AWS credentials object with accessKeyId and secretAccessKey. If not provided, the AWS SDK will attempt to source credentials from environment variables, IAM roles (e.g., for EC2/Lambda), or the shared AWS credentials file.
|
|
124
124
|
|
|
125
|
-
**config.ttl** (`object`): TTL (Time To Live) configuration for automatic data expiration. Configure per entity type: thread, message, trace, eval,
|
|
125
|
+
**config.ttl** (`object`): TTL (Time To Live) configuration for automatic data expiration. Configure per entity type: thread, message, trace, eval, workflow_snapshot, resource, score. Each entity config includes: enabled (boolean), attributeName (string, default: 'ttl'), defaultTtlSeconds (number).
|
|
126
126
|
|
|
127
127
|
## TTL (time to live) configuration
|
|
128
128
|
|
|
@@ -254,7 +254,7 @@ The IAM role or user executing the code needs appropriate permissions to interac
|
|
|
254
254
|
|
|
255
255
|
Before diving into the architectural details, keep these key points in mind when working with the DynamoDB storage adapter:
|
|
256
256
|
|
|
257
|
-
- **External Table Provisioning:** This adapter _requires_ you to create and configure the DynamoDB table and its Global Secondary Indexes (GSIs) yourself, prior to using the adapter. Follow the guide in [
|
|
257
|
+
- **External Table Provisioning:** This adapter _requires_ you to create and configure the DynamoDB table and its Global Secondary Indexes (GSIs) yourself, prior to using the adapter. Follow the guide in [TABLE_SETUP.md](https://github.com/mastra-ai/mastra/blob/main/stores/dynamodb/TABLE_SETUP.md).
|
|
258
258
|
- **Single-Table Design:** All Mastra data (threads, messages, etc.) is stored in one DynamoDB table. This is a deliberate design choice optimized for DynamoDB, differing from relational database approaches.
|
|
259
259
|
- **Understanding GSIs:** Familiarity with how the GSIs are structured (as per `TABLE_SETUP.md`) is important for understanding data retrieval and potential query patterns.
|
|
260
260
|
- **ElectroDB:** The adapter uses ElectroDB to manage interactions with DynamoDB, providing a layer of abstraction and type safety over raw DynamoDB operations.
|
|
@@ -266,7 +266,7 @@ This storage adapter utilizes a **single-table design pattern** with [ElectroDB]
|
|
|
266
266
|
Key aspects of this approach:
|
|
267
267
|
|
|
268
268
|
- **DynamoDB Native:** The single-table design is optimized for DynamoDB's key-value and query capabilities, often leading to better performance and capacity compared to mimicking relational models.
|
|
269
|
-
- **External Table Management:** Unlike some adapters that might offer helper functions to create tables via code, this adapter **expects the DynamoDB table and its associated Global Secondary Indexes (GSIs) to be provisioned externally** before use. Please refer to [
|
|
269
|
+
- **External Table Management:** Unlike some adapters that might offer helper functions to create tables via code, this adapter **expects the DynamoDB table and its associated Global Secondary Indexes (GSIs) to be provisioned externally** before use. Please refer to [TABLE_SETUP.md](https://github.com/mastra-ai/mastra/blob/main/stores/dynamodb/TABLE_SETUP.md) for detailed instructions using tools like AWS CloudFormation or CDK. The adapter focuses solely on interacting with the pre-existing table structure.
|
|
270
270
|
- **Consistency via Interface:** While the underlying storage model differs, this adapter adheres to the same `MastraStorage` interface as other adapters, ensuring it can be used interchangeably within the Mastra `Memory` component.
|
|
271
271
|
|
|
272
272
|
### Mastra Data in the Single Table
|
|
@@ -429,14 +429,14 @@ PostgreSQL storage provides index management to optimize query performance.
|
|
|
429
429
|
PostgreSQL storage creates composite indexes during initialization for common query patterns:
|
|
430
430
|
|
|
431
431
|
- `mastra_threads_resourceid_createdat_idx`: (resourceId, createdAt DESC)
|
|
432
|
-
- `mastra_messages_thread_id_createdat_idx`: (
|
|
432
|
+
- `mastra_messages_thread_id_createdat_idx`: (thread_id, createdAt DESC)
|
|
433
433
|
- `mastra_ai_spans_traceid_startedat_idx`: (traceId, startedAt DESC)
|
|
434
434
|
- `mastra_ai_spans_parentspanid_startedat_idx`: (parentSpanId, startedAt DESC)
|
|
435
435
|
- `mastra_ai_spans_name_startedat_idx`: (name, startedAt DESC)
|
|
436
436
|
- `mastra_ai_spans_scope_startedat_idx`: (scope, startedAt DESC)
|
|
437
437
|
- `mastra_scores_trace_id_span_id_created_at_idx`: (traceId, spanId, createdAt DESC)
|
|
438
|
-
- `mastra_workflow_snapshot_name_createdat_idx`: (
|
|
439
|
-
- `mastra_workflow_snapshot_name_status_createdat_idx`: (
|
|
438
|
+
- `mastra_workflow_snapshot_name_createdat_idx`: (workflow_name, createdAt DESC)
|
|
439
|
+
- `mastra_workflow_snapshot_name_status_createdat_idx`: (workflow_name, snapshot->>'status', createdAt DESC), created only when the `snapshot` column is `jsonb`
|
|
440
440
|
|
|
441
441
|
These indexes improve performance for filtered queries with sorting, including `dateRange` filters on message queries and Studio's workflow runs-list.
|
|
442
442
|
|
|
@@ -485,7 +485,7 @@ For advanced index types, you can specify additional options:
|
|
|
485
485
|
|
|
486
486
|
**name** (`string`): Unique name for the index
|
|
487
487
|
|
|
488
|
-
**table** (`string`): Table name (e.g., '
|
|
488
|
+
**table** (`string`): Table name (e.g., 'mastra_threads')
|
|
489
489
|
|
|
490
490
|
**columns** (`string[]`): Array of column names with optional sort order (e.g., \['id', 'createdAt DESC'])
|
|
491
491
|
|
|
@@ -37,11 +37,11 @@ export const agent = new Agent({
|
|
|
37
37
|
|
|
38
38
|
**embedder** (`EmbeddingModel<string> | EmbeddingModelV2<string>`): Embedder instance for vector embeddings. Required when semantic recall is enabled.
|
|
39
39
|
|
|
40
|
-
**embeddingDimension** (`number`): Output dimension of the embedder, as a positive integer. When set, Memory uses it to name the semantic recall index instead of embedding a probe string on first use. It must match the vectors the embedder returns: a mismatch throws a
|
|
40
|
+
**embeddingDimension** (`number`): Output dimension of the embedder, as a positive integer. When set, Memory uses it to name the semantic recall index instead of embedding a probe string on first use. It must match the vectors the embedder returns: a mismatch throws a MASTRA_MEMORY_EMBEDDING_DIMENSION_MISMATCH error before any index is created. See Setting the embedding dimension.
|
|
41
41
|
|
|
42
42
|
**options** (`MemoryConfig`): Memory configuration options.
|
|
43
43
|
|
|
44
|
-
**options.lastMessages** (`number | false`): Number of most recent messages to include in context. Set to false to disable the message history feature entirely (messages are not loaded into context or saved). Use Number.
|
|
44
|
+
**options.lastMessages** (`number | false`): Number of most recent messages to include in context. Set to false to disable the message history feature entirely (messages are not loaded into context or saved). Use Number.MAX_SAFE_INTEGER to retrieve all messages with no limit. To load messages without saving new ones, use the readOnly option. The window slides forward on every request, so once a thread exceeds the limit, each turn invalidates the provider prompt cache. For long-running conversations, use Observational Memory instead.
|
|
45
45
|
|
|
46
46
|
**options.messageHistory** (`{ maxTokens: number; atMaxRemoveTokens?: number }`): Token budget for the complete prompt, including remembered history, system instructions, context, and the current turn. When the prompt exceeds maxTokens, the oldest remembered messages are dropped until the prompt is at most maxTokens - atMaxRemoveTokens (defaults to 25% of maxTokens). Protected content is never removed. Linked tool calls and results are removed together. During agent runs, trimmed history is excluded from later turns via a persisted per-thread boundary, but the messages themselves stay in storage. When set without an explicit lastMessages, the default 10-message cap is not applied. Set maxTokens to 0 to disable message history. Prefer this over lastMessages, since message count is a poor proxy for context size.
|
|
47
47
|
|