@mastra/memory 1.41.2 → 1.41.3-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.
Files changed (42) hide show
  1. package/dist/docs/SKILL.md +1 -1
  2. package/dist/docs/assets/SOURCE_MAP.json +76 -76
  3. package/dist/docs/references/docs-agents-human-in-the-loop.md +2 -2
  4. package/dist/docs/references/docs-agents-networks.md +1 -1
  5. package/dist/docs/references/docs-guides-context-engineering.md +1 -1
  6. package/dist/docs/references/docs-harness-background-tasks.md +7 -1
  7. package/dist/docs/references/docs-knowledge-overview.md +1 -1
  8. package/dist/docs/references/docs-memory-memory-processors.md +2 -2
  9. package/dist/docs/references/docs-memory-message-history.md +1 -1
  10. package/dist/docs/references/docs-memory-multi-user-threads.md +1 -1
  11. package/dist/docs/references/docs-memory-observational-memory.md +5 -5
  12. package/dist/docs/references/docs-memory-semantic-recall.md +10 -4
  13. package/dist/docs/references/docs-memory-working-memory.md +16 -16
  14. package/dist/docs/references/docs-signals-overview.md +1 -1
  15. package/dist/docs/references/integrations-channels-ring.md +6 -6
  16. package/dist/docs/references/integrations-databases-aurora-dsql.md +13 -13
  17. package/dist/docs/references/integrations-databases-dynamodb.md +8 -8
  18. package/dist/docs/references/integrations-databases-elasticsearch.md +6 -6
  19. package/dist/docs/references/integrations-databases-mongodb.md +2 -2
  20. package/dist/docs/references/integrations-databases-oracledb.md +2 -2
  21. package/dist/docs/references/integrations-databases-postgresql.md +14 -14
  22. package/dist/docs/references/integrations-databases-redis.md +7 -7
  23. package/dist/docs/references/integrations-databases-upstash.md +5 -5
  24. package/dist/docs/references/integrations-databases-valkey.md +1 -1
  25. package/dist/docs/references/reference-memory-listThreads.md +1 -1
  26. package/dist/docs/references/reference-memory-observational-memory.md +2 -2
  27. package/dist/docs/references/reference-processors-token-limiter-processor.md +1 -1
  28. package/dist/index.cjs +20 -1
  29. package/dist/index.d.ts +3 -1
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +1 -1
  32. package/dist/processors/index.cjs +1 -1
  33. package/dist/processors/index.js +1 -1
  34. package/dist/processors/observational-memory/observer-agent.d.ts +1 -1
  35. package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -1
  36. package/dist/{src-BkElV36S.js → src-CTZXQELy.js} +4 -5
  37. package/dist/{src-BkElV36S.js.map → src-CTZXQELy.js.map} +1 -1
  38. package/dist/{src-IZtKjicq.cjs → src-ibq9d-g9.cjs} +2 -3
  39. package/dist/{src-IZtKjicq.cjs.map → src-ibq9d-g9.cjs.map} +1 -1
  40. package/package.json +9 -9
  41. /package/dist/_types/{@internal_ai-sdk-v4@0.0.97 → @internal_ai-sdk-v4@0.0.98}/dist/index.d.ts +0 -0
  42. /package/dist/_types/{@internal_ai-sdk-v4@0.0.97 → @internal_ai-sdk-v4@0.0.98}/package.json +0 -0
@@ -3,7 +3,7 @@ name: mastra-memory
3
3
  description: Documentation for @mastra/memory. Use when working with @mastra/memory APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/memory"
6
- version: "1.41.2"
6
+ version: "1.41.3-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,243 +1,243 @@
1
1
  {
2
- "version": "1.41.2",
2
+ "version": "1.41.3-alpha.0",
3
3
  "package": "@mastra/memory",
4
4
  "exports": {
5
5
  "AUTO_MODEL_BY_PROVIDER": {
6
6
  "types": "dist/processors/observational-memory/auto-model.d.ts",
7
- "implementation": "dist/src-BkElV36S.js",
8
- "line": 32706
7
+ "implementation": "dist/src-CTZXQELy.js",
8
+ "line": 32705
9
9
  },
10
10
  "Extractor": {
11
11
  "types": "dist/processors/observational-memory/extractor.d.ts",
12
- "implementation": "dist/src-BkElV36S.js",
12
+ "implementation": "dist/src-CTZXQELy.js",
13
13
  "line": 24432
14
14
  },
15
15
  "ModelByInputTokens": {
16
16
  "types": "dist/processors/observational-memory/model-by-input-tokens.d.ts",
17
- "implementation": "dist/src-BkElV36S.js",
18
- "line": 32489
17
+ "implementation": "dist/src-CTZXQELy.js",
18
+ "line": 32488
19
19
  },
20
20
  "OBSERVATIONAL_MEMORY_DEFAULTS": {
21
21
  "types": "dist/processors/observational-memory/constants.d.ts",
22
- "implementation": "dist/src-BkElV36S.js",
22
+ "implementation": "dist/src-CTZXQELy.js",
23
23
  "line": 24168
24
24
  },
25
25
  "OBSERVATION_CONTEXT_INSTRUCTIONS": {
26
26
  "types": "dist/processors/observational-memory/constants.d.ts",
27
- "implementation": "dist/src-BkElV36S.js",
27
+ "implementation": "dist/src-CTZXQELy.js",
28
28
  "line": 24229
29
29
  },
30
30
  "OBSERVATION_CONTEXT_PROMPT": {
31
31
  "types": "dist/processors/observational-memory/constants.d.ts",
32
- "implementation": "dist/src-BkElV36S.js",
32
+ "implementation": "dist/src-CTZXQELy.js",
33
33
  "line": 24211
34
34
  },
35
35
  "OBSERVATION_CONTEXT_PROMPT_THREAD": {
36
36
  "types": "dist/processors/observational-memory/constants.d.ts",
37
- "implementation": "dist/src-BkElV36S.js",
37
+ "implementation": "dist/src-CTZXQELy.js",
38
38
  "line": 24216
39
39
  },
40
40
  "OBSERVATION_CONTINUATION_HINT": {
41
41
  "types": "dist/processors/observational-memory/constants.d.ts",
42
- "implementation": "dist/src-BkElV36S.js",
42
+ "implementation": "dist/src-CTZXQELy.js",
43
43
  "line": 24198
44
44
  },
45
45
  "OBSERVER_SYSTEM_PROMPT": {
46
46
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
47
- "implementation": "dist/src-BkElV36S.js",
47
+ "implementation": "dist/src-CTZXQELy.js",
48
48
  "line": 26793
49
49
  },
50
50
  "ObservationalMemory": {
51
51
  "types": "dist/processors/observational-memory/observational-memory.d.ts",
52
- "implementation": "dist/src-BkElV36S.js",
53
- "line": 37514
52
+ "implementation": "dist/src-CTZXQELy.js",
53
+ "line": 37513
54
54
  },
55
55
  "ObservationalMemoryProcessor": {
56
56
  "types": "dist/processors/observational-memory/processor.d.ts",
57
- "implementation": "dist/src-BkElV36S.js",
58
- "line": 40262
57
+ "implementation": "dist/src-CTZXQELy.js",
58
+ "line": 40261
59
59
  },
60
60
  "TokenCounter": {
61
61
  "types": "dist/processors/observational-memory/token-counter.d.ts",
62
- "implementation": "dist/src-BkElV36S.js",
63
- "line": 29311
62
+ "implementation": "dist/src-CTZXQELy.js",
63
+ "line": 29310
64
64
  },
65
65
  "WorkingMemoryExtractor": {
66
66
  "types": "dist/processors/observational-memory/working-memory-extractor.d.ts",
67
- "implementation": "dist/src-BkElV36S.js",
68
- "line": 30330
67
+ "implementation": "dist/src-CTZXQELy.js",
68
+ "line": 30329
69
69
  },
70
70
  "buildObserverPrompt": {
71
71
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
72
- "implementation": "dist/src-BkElV36S.js",
72
+ "implementation": "dist/src-CTZXQELy.js",
73
73
  "line": 27477
74
74
  },
75
75
  "buildObserverSystemPrompt": {
76
76
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
77
- "implementation": "dist/src-BkElV36S.js",
77
+ "implementation": "dist/src-CTZXQELy.js",
78
78
  "line": 26687
79
79
  },
80
80
  "combineObservationGroupRanges": {
81
81
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
82
- "implementation": "dist/src-BkElV36S.js",
83
- "line": 30809
82
+ "implementation": "dist/src-CTZXQELy.js",
83
+ "line": 30808
84
84
  },
85
85
  "deriveObservationGroupProvenance": {
86
86
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
87
- "implementation": "dist/src-BkElV36S.js",
88
- "line": 30853
87
+ "implementation": "dist/src-CTZXQELy.js",
88
+ "line": 30852
89
89
  },
90
90
  "extractCurrentTask": {
91
91
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
92
- "implementation": "dist/src-BkElV36S.js",
92
+ "implementation": "dist/src-CTZXQELy.js",
93
93
  "line": 27790
94
94
  },
95
95
  "formatMessagesForObserver": {
96
96
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
97
- "implementation": "dist/src-BkElV36S.js",
97
+ "implementation": "dist/src-CTZXQELy.js",
98
98
  "line": 27228
99
99
  },
100
100
  "getObservationContextPrompt": {
101
101
  "types": "dist/processors/observational-memory/constants.d.ts",
102
- "implementation": "dist/src-BkElV36S.js",
102
+ "implementation": "dist/src-CTZXQELy.js",
103
103
  "line": 24222
104
104
  },
105
105
  "getObservationsAsOf": {
106
106
  "types": "dist/processors/observational-memory/observation-utils.d.ts",
107
- "implementation": "dist/src-BkElV36S.js",
108
- "line": 40602
107
+ "implementation": "dist/src-CTZXQELy.js",
108
+ "line": 40601
109
109
  },
110
110
  "hasCurrentTaskSection": {
111
111
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
112
- "implementation": "dist/src-BkElV36S.js",
112
+ "implementation": "dist/src-CTZXQELy.js",
113
113
  "line": 27778
114
114
  },
115
115
  "injectAnchorIds": {
116
116
  "types": "dist/processors/observational-memory/anchor-ids.d.ts",
117
- "implementation": "dist/src-BkElV36S.js",
117
+ "implementation": "dist/src-CTZXQELy.js",
118
118
  "line": 25409
119
119
  },
120
120
  "optimizeObservationsForContext": {
121
121
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
122
- "implementation": "dist/src-BkElV36S.js",
122
+ "implementation": "dist/src-CTZXQELy.js",
123
123
  "line": 27811
124
124
  },
125
125
  "parseAnchorId": {
126
126
  "types": "dist/processors/observational-memory/anchor-ids.d.ts",
127
- "implementation": "dist/src-BkElV36S.js",
127
+ "implementation": "dist/src-CTZXQELy.js",
128
128
  "line": 25393
129
129
  },
130
130
  "parseObservationGroups": {
131
131
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
132
- "implementation": "dist/src-BkElV36S.js",
133
- "line": 30764
132
+ "implementation": "dist/src-CTZXQELy.js",
133
+ "line": 30763
134
134
  },
135
135
  "parseObserverOutput": {
136
136
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
137
- "implementation": "dist/src-BkElV36S.js",
137
+ "implementation": "dist/src-CTZXQELy.js",
138
138
  "line": 27488
139
139
  },
140
140
  "reconcileObservationGroupsFromReflection": {
141
141
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
142
- "implementation": "dist/src-BkElV36S.js",
143
- "line": 30872
142
+ "implementation": "dist/src-CTZXQELy.js",
143
+ "line": 30871
144
144
  },
145
145
  "renderObservationGroupsForReflection": {
146
146
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
147
- "implementation": "dist/src-BkElV36S.js",
148
- "line": 30838
147
+ "implementation": "dist/src-CTZXQELy.js",
148
+ "line": 30837
149
149
  },
150
150
  "resolveAutoModelId": {
151
151
  "types": "dist/processors/observational-memory/auto-model.d.ts",
152
- "implementation": "dist/src-BkElV36S.js",
153
- "line": 32726
152
+ "implementation": "dist/src-CTZXQELy.js",
153
+ "line": 32725
154
154
  },
155
155
  "stripEphemeralAnchorIds": {
156
156
  "types": "dist/processors/observational-memory/anchor-ids.d.ts",
157
- "implementation": "dist/src-BkElV36S.js",
157
+ "implementation": "dist/src-CTZXQELy.js",
158
158
  "line": 25432
159
159
  },
160
160
  "stripObservationGroups": {
161
161
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
162
- "implementation": "dist/src-BkElV36S.js",
163
- "line": 30781
162
+ "implementation": "dist/src-CTZXQELy.js",
163
+ "line": 30780
164
164
  },
165
165
  "summarizeConversation": {
166
166
  "types": "dist/processors/observational-memory/summarize.d.ts",
167
- "implementation": "dist/src-BkElV36S.js",
168
- "line": 29942
167
+ "implementation": "dist/src-CTZXQELy.js",
168
+ "line": 29941
169
169
  },
170
170
  "wrapInObservationGroup": {
171
171
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
172
- "implementation": "dist/src-BkElV36S.js",
173
- "line": 30735
172
+ "implementation": "dist/src-CTZXQELy.js",
173
+ "line": 30734
174
174
  },
175
175
  "KnowledgeSemanticIndexCoordinator": {
176
176
  "types": "dist/removed-subconscious.d.ts",
177
- "implementation": "dist/src-BkElV36S.js",
178
- "line": 30377
177
+ "implementation": "dist/src-CTZXQELy.js",
178
+ "line": 30376
179
179
  },
180
180
  "Memory": {
181
181
  "types": "dist/index.d.ts",
182
- "implementation": "dist/src-BkElV36S.js",
183
- "line": 40813
182
+ "implementation": "dist/src-CTZXQELy.js",
183
+ "line": 40812
184
184
  },
185
185
  "SUMMARIZE_THREAD_DEFAULTS": {
186
186
  "types": "dist/processors/observational-memory/summarize.d.ts",
187
- "implementation": "dist/src-BkElV36S.js",
188
- "line": 29898
187
+ "implementation": "dist/src-CTZXQELy.js",
188
+ "line": 29897
189
189
  },
190
190
  "StaleKnowledgeSemanticIndexError": {
191
191
  "types": "dist/removed-subconscious.d.ts",
192
- "implementation": "dist/src-BkElV36S.js",
193
- "line": 30383
192
+ "implementation": "dist/src-CTZXQELy.js",
193
+ "line": 30382
194
194
  },
195
195
  "Subconscious": {
196
196
  "types": "dist/removed-subconscious.d.ts",
197
- "implementation": "dist/src-BkElV36S.js",
198
- "line": 30371
197
+ "implementation": "dist/src-CTZXQELy.js",
198
+ "line": 30370
199
199
  },
200
200
  "WORKING_MEMORY_STATE_ID": {
201
201
  "types": "dist/processors/working-memory-state/processor.d.ts",
202
- "implementation": "dist/src-BkElV36S.js",
203
- "line": 32535
202
+ "implementation": "dist/src-CTZXQELy.js",
203
+ "line": 32534
204
204
  },
205
205
  "WORKING_MEMORY_STATE_PROCESSOR_ID": {
206
206
  "types": "dist/processors/working-memory-state/processor.d.ts",
207
- "implementation": "dist/src-BkElV36S.js",
208
- "line": 32536
207
+ "implementation": "dist/src-CTZXQELy.js",
208
+ "line": 32535
209
209
  },
210
210
  "WorkingMemoryStateProcessor": {
211
211
  "types": "dist/processors/working-memory-state/processor.d.ts",
212
- "implementation": "dist/src-BkElV36S.js",
213
- "line": 32537
212
+ "implementation": "dist/src-CTZXQELy.js",
213
+ "line": 32536
214
214
  },
215
215
  "deepMergeWorkingMemory": {
216
216
  "types": "dist/tools/working-memory.d.ts",
217
- "implementation": "dist/src-BkElV36S.js",
218
- "line": 30021
217
+ "implementation": "dist/src-CTZXQELy.js",
218
+ "line": 30020
219
219
  },
220
220
  "extractWorkingMemoryContent": {
221
221
  "types": "dist/index.d.ts",
222
- "implementation": "dist/src-BkElV36S.js",
223
- "line": 40667
222
+ "implementation": "dist/src-CTZXQELy.js",
223
+ "line": 40666
224
224
  },
225
225
  "extractWorkingMemoryTags": {
226
226
  "types": "dist/index.d.ts",
227
- "implementation": "dist/src-BkElV36S.js",
228
- "line": 40635
227
+ "implementation": "dist/src-CTZXQELy.js",
228
+ "line": 40634
229
229
  },
230
230
  "removeWorkingMemoryTags": {
231
231
  "types": "dist/index.d.ts",
232
- "implementation": "dist/src-BkElV36S.js",
233
- "line": 40648
232
+ "implementation": "dist/src-CTZXQELy.js",
233
+ "line": 40647
234
234
  }
235
235
  },
236
236
  "modules": {
237
237
  "processors": {
238
238
  "index": "dist/processors/index.js",
239
239
  "chunks": [
240
- "src-BkElV36S.js"
240
+ "src-CTZXQELy.js"
241
241
  ]
242
242
  }
243
243
  }
@@ -94,7 +94,7 @@ for await (const chunk of stream.fullStream) {
94
94
 
95
95
  #### Explaining a decline
96
96
 
97
- `declineToolCall()`, `declineToolCallGenerate()`, and `declineNetworkToolCall()` accept an optional `reason`. The reason is returned to the model in place of the tool result, so the model can adjust instead of retrying blindly. It's also stored on the tool call's `approval` metadata, so it's still there when the conversation is recalled.
97
+ `declineToolCall()`, `declineToolCallGenerate()`, and `declineNetworkToolCall()` accept an optional `reason`. The reason is returned to the model in place of the tool result, so the model can adjust instead of retrying the same way. It's also stored on the tool call's `approval` metadata, so it's still there when the conversation is recalled.
98
98
 
99
99
  ```typescript
100
100
  const declined = await agent.declineToolCall({
@@ -162,7 +162,7 @@ The runtime then combines that result with the tool's `requireApproval` setting.
162
162
 
163
163
  For sensitive tools, bind the approval to the exact tool name and arguments that were shown to the reviewer. If those arguments drift before execution, the tool shouldn't run under the old approval.
164
164
 
165
- The `tool-call-approval` chunk already includes `toolName`, `toolCallId`, and `args`. You can fingerprint those fields when the approval request is shown. The example below uses a JSON string as the fingerprint, but in production you should use a stable hash of the tool name and arguments:
165
+ The `tool-call-approval` chunk already includes `toolName`, `toolCallId`, and `args`. You can fingerprint those fields when the approval request is shown. The example below uses a JSON string as the fingerprint, but in production, use a stable hash of the tool name and arguments:
166
166
 
167
167
  ```typescript
168
168
  import { Agent } from '@mastra/core/agent'
@@ -159,7 +159,7 @@ for await (const chunk of resumedStream) {
159
159
 
160
160
  ### Automatic resumption
161
161
 
162
- Set `autoResumeSuspendedTools` to `true` so the network resumes suspended primitives based on the user's next message. This creates a conversational flow where users provide the required information naturally.
162
+ Set `autoResumeSuspendedTools` to `true` so the network resumes suspended primitives based on the user's next message. This creates a conversational flow where users provide the required information in conversation.
163
163
 
164
164
  ```typescript
165
165
  const stream = await routingAgent.network('Delete the old records', {
@@ -266,7 +266,7 @@ If you've used Claude Code, you may have seen compaction happen during a long se
266
266
 
267
267
  Compaction waits until a conversation reaches a token threshold. It then summarizes the transcript and replaces earlier messages. It's a blunt fallback. The compaction turn adds latency, and a single summary has to represent everything that came before. Repeated summaries can flatten chronology or lose details that later become important.
268
268
 
269
- Prefer [Observational Memory](#observational-memory) for long-running conversations. It can process history asynchronously in the background while preserving temporal context. Reflection revisits accumulated memories and naturally prunes details that no longer matter. Mastra doesn't provide compaction out of the box, though you could implement it with a custom [processor](https://mastra.ai/docs/agents/processors).
269
+ Prefer [Observational Memory](#observational-memory) for long-running conversations. It can process history asynchronously in the background while preserving temporal context. Reflection revisits accumulated memories and prunes details that no longer matter. Mastra doesn't provide compaction out of the box, though you could implement it with a custom [processor](https://mastra.ai/docs/agents/processors).
270
270
 
271
271
  ### Processors
272
272
 
@@ -16,7 +16,7 @@ Use background tasks when a tool call may take long enough that the user shouldn
16
16
  - Tool calls that hit slow external services, queues, or large data jobs.
17
17
  - Workflows triggered from a tool call that may take minutes to complete.
18
18
 
19
- For tool calls that return quickly, foreground execution using `agent.stream()` and `agent.generate()` is simpler.
19
+ For tool calls that return fast, foreground execution using `agent.stream()` and `agent.generate()` is simpler.
20
20
 
21
21
  > **Note:** Background tasks require a configured [storage](https://mastra.ai/docs/storage) backend on the Mastra instance. Tasks are persisted so they survive process restarts.
22
22
 
@@ -341,6 +341,12 @@ await mastra.backgroundTaskManager?.resume(taskId, {
341
341
 
342
342
  On the resumed run, `context.agent.suspendPayload` holds the `data` the tool suspended with. Use it to tell which request an answer belongs to without encoding that in `resumeData`.
343
343
 
344
+ ### Suspend after a durable agent's run finished
345
+
346
+ On a [durable agent](https://mastra.ai/docs/harness/durable-agents), a background tool can call `suspend()` after the agent has replied and its run has finished. The task is marked `suspended` and resumes as usual when the storage adapter supports [run fencing](https://mastra.ai/docs/harness/durable-agents), for example `InMemoryStore`, `@mastra/libsql`, or `@mastra/pg`. These adapters record each claim on the run, so Mastra can check that no other execution claimed the run in the meantime.
347
+
348
+ The task still fails with a storage adapter that lacks run fencing, because run ownership is then only a PubSub lease, and a released lease can't show whether another execution claimed and finished the run since. On an agent from `createEventedAgent()`, the task also fails when an approval for another tool call resumed the run in the same turn, because the resume's claim counts as another execution.
349
+
344
350
  ### Answer a suspended task from a client
345
351
 
346
352
  While an agent's background tool call is suspended, the assistant message that holds the call records the open request under `metadata.suspendedTools[toolCallId]`. The entry carries `toolName`, `args`, `suspendPayload`, `taskId`, `runId`, and `suspendedAt`, so a chat that reloads the thread can still show the request. The entry is removed when the task resumes or is cancelled.
@@ -8,7 +8,7 @@
8
8
 
9
9
  Knowledge gives agents a shared, organized place for information that lives outside any one conversation: policies, product docs, conventions, runbooks and what other agents have learned. Agents search, read and write it with tools. Pages you pin reach the agent's context through [signals](https://mastra.ai/docs/signals/overview) and stay current while it runs.
10
10
 
11
- > **Alpha:** Knowledge is in alpha. Its API may change between releases. Access is checked on every tool call, but the alpha doesn't guarantee isolation between scopes yet. Don't store anything in Knowledge that must never reach another customer or user. Knowledge also has no built-in importers or retention yet.
11
+ > **Alpha:** Knowledge is in alpha. Its API may change between releases. Each scope's data is kept separate, but an agent with access to more than one scope can leak content between them. Give each agent only the scopes it needs, as [Keep scopes apart](https://mastra.ai/docs/knowledge/scopes-and-access) explains. Knowledge has no built-in importers yet, but you can [write content through its API](https://mastra.ai/docs/knowledge/load-your-content), and Mastra Platform offers importers. Knowledge can't expire old pages yet.
12
12
 
13
13
  ## What Knowledge is
14
14
 
@@ -209,7 +209,7 @@ const agent = new Agent({
209
209
 
210
210
  Understanding the execution order is important when combining guardrails with memory:
211
211
 
212
- ### Input Processors
212
+ ### Input processors
213
213
 
214
214
  ```text
215
215
  [Memory Processors] → [Your inputProcessors]
@@ -220,7 +220,7 @@ Understanding the execution order is important when combining guardrails with me
220
220
 
221
221
  As a result, memory loads message history before your processors can validate or filter the input.
222
222
 
223
- ### Output Processors
223
+ ### Output processors
224
224
 
225
225
  ```text
226
226
  [Your outputProcessors] → [Memory Processors]
@@ -404,7 +404,7 @@ Message queries return `MastraDBMessage[]` format. To display messages in a fron
404
404
 
405
405
  ## Thread cloning
406
406
 
407
- Thread cloning creates a copy of an existing thread with its messages. This is useful for branching conversations or creating checkpoints before a potentially destructive operation, or alternatively testing variations of a conversation.
407
+ Thread cloning creates a copy of an existing thread with its messages. This is useful for branching conversations or creating checkpoints before a destructive operation, or alternatively testing variations of a conversation.
408
408
 
409
409
  ```typescript
410
410
  const { thread, clonedMessages } = await memory.cloneThread({
@@ -108,7 +108,7 @@ Pick the memory layer by how long the conversation needs to remember each partic
108
108
 
109
109
  `lastMessages` brings earlier messages back into context with their `<user>` attributes, so attribution survives across turns. The agent example above uses this setup.
110
110
 
111
- ### With Observational Memory
111
+ ### With observational Memory
112
112
 
113
113
  [Observational Memory](https://mastra.ai/docs/memory/observational-memory) (OM) keeps a long shared thread inside the context window by replacing older messages with observations. Enable it on the same `Memory`:
114
114
 
@@ -38,7 +38,7 @@ yarn add @mastra/memory@latest @mastra/libsql@latest
38
38
  bun add @mastra/memory@latest @mastra/libsql@latest
39
39
  ```
40
40
 
41
- OM needs storage that supports it (`@mastra/libsql`, `@mastra/pg`, `@mastra/mysql`, `@mastra/mongodb`, `@mastra/convex` or `@mastra/oracledb`), a thread for every call, and `observationalMemory: true`. This script stores memory in a local LibSQL file and calls the agent twice on one thread:
41
+ OM needs storage that supports it (`@mastra/libsql`, `@mastra/pg`, `@mastra/mysql`, `@mastra/mongodb`, `@mastra/convex`, `@mastra/oracledb` or `@mastra/mssql`), a thread for every call, and `observationalMemory: true`. This script stores memory in a local LibSQL file and calls the agent twice on one thread:
42
42
 
43
43
  ```typescript
44
44
  import { Agent } from '@mastra/core/agent'
@@ -176,9 +176,9 @@ const memory = new Memory({
176
176
  })
177
177
  ```
178
178
 
179
- Use a model with a large context window (128,000 tokens or more) that's fast enough to run in the background. Mastra has tested `google/gemini-2.5-flash`, `openai/gpt-6-luna`, `anthropic/claude-haiku-5-5` and `deepseek/deepseek-flash`.
179
+ Use a model with a large context window (128,000 tokens or more) that's fast enough to run in the background. Mastra has tested `google/gemini-2.5-flash`, `openai/gpt-6-luna`, `anthropic/claude-haiku-5.5` and `deepseek/deepseek-flash`.
180
180
 
181
- To use a different model per role, set `observation.model` and `reflection.model` instead, and leave the top-level `model` out. Setting both throws. Some models keep so much detail that their reflections can stay above the threshold; in testing, `google/gemini-2.5-flash` did this. A common split uses a detail-preserving model as the Observer and one that condenses more readily, such as `deepseek/deepseek-flash`, as the Reflector. See [different models per agent](https://mastra.ai/reference/memory/observational-memory).
181
+ To use a different model per role, set `observation.model` and `reflection.model` instead, and leave the top-level `model` out. Setting both throws. Some models keep so much detail that their reflections can stay above the threshold; in testing, `google/gemini-2.5-flash` did this. A common split uses a detail-preserving model as the Observer and one that condenses more aggressively, such as `deepseek/deepseek-flash`, as the Reflector. See [different models per agent](https://mastra.ai/reference/memory/observational-memory).
182
182
 
183
183
  ### Tune automatic selection
184
184
 
@@ -239,7 +239,7 @@ const memory = new Memory({
239
239
 
240
240
  Each tier needs a concrete model ID, not `'auto'`. Each `upTo` key is an inclusive upper bound. A call larger than the biggest key throws, so make the last tier cover the largest input you expect.
241
241
 
242
- ### Attachments and text-only Observers
242
+ ### Attachments and text-only observers
243
243
 
244
244
  By default the Observer receives images and PDFs (`observation.observeAttachments: ['image/*', 'application/pdf']`). Other attachments are left out, and their placeholders stay in the transcript. Change it when your Observer model handles more or less:
245
245
 
@@ -265,7 +265,7 @@ The same filter applies to images and files inside tool results. Attachments the
265
265
 
266
266
  ## Cost and latency
267
267
 
268
- Each observation and reflection is a model call. With the defaults, a thread costs one Observer call for roughly every 6,000 tokens of new messages, and one Reflector call each time the log reaches 40,000 tokens. In return, every main-agent call reads a context of at most a few tens of thousands of tokens instead of the whole thread. The observation prefix changes rarely, so prompt caching keeps working: users generally see 97 to 99% prompt cache hit rates with OM.
268
+ Each observation and reflection is a model call. With the defaults, a thread costs one Observer call for about every 6,000 tokens of new messages, and one Reflector call each time the log reaches 40,000 tokens. In return, every main-agent call reads a context of at most a few tens of thousands of tokens instead of the whole thread. The observation prefix stays stable, so prompt caching keeps working: users see 97 to 99% prompt cache hit rates with OM.
269
269
 
270
270
  The Observer runs ahead in the background (async buffering), so the agent doesn't stop to wait for it. These settings control the timing:
271
271
 
@@ -309,7 +309,7 @@ Every other store expects your application to supply the vectors, and keeps requ
309
309
 
310
310
  Semantic recall relies on an [embedding model](https://mastra.ai/reference/memory/memory-class) to convert messages into embeddings. Mastra supports embedding models through the model router using `provider/model` strings, or you can use any [embedding model](https://sdk.vercel.ai/docs/ai-sdk-core/embeddings) compatible with the AI SDK.
311
311
 
312
- ### Using the Model Router (Recommended)
312
+ ### Using the model router (recommended)
313
313
 
314
314
  The simplest way is to use a `provider/model` string with autocomplete support:
315
315
 
@@ -353,7 +353,7 @@ const agent = new Agent({
353
353
 
354
354
  The model router automatically handles API key detection from environment variables (`OPENAI_API_KEY`, `GOOGLE_API_KEY`, `OPENROUTER_API_KEY`). Google models also fall back to `GOOGLE_GENERATIVE_AI_API_KEY`.
355
355
 
356
- ### Using AI SDK Packages
356
+ ### Using AI SDK packages
357
357
 
358
358
  You can also use AI SDK embedding models directly:
359
359
 
@@ -432,7 +432,13 @@ Memory uses a single embedder for both storing and recalling messages, so pick o
432
432
 
433
433
  Multilingual E5 produces 1024-dimensional vectors. Your vector index must be created with matching dimensions, and E5 vectors can't be mixed with vectors from another embedder in the same index.
434
434
 
435
- FastEmbed models embed at most 512 tokens per input (roughly 2,000 to 2,500 characters of English text). Longer inputs are truncated, so text past the limit doesn't affect the embedding. Semantic recall sizes its message chunks to fit this window automatically (see [Long messages](#long-messages)). Outside of memory, the AI SDK v3 FastEmbed models return a warning when an input is truncated. The legacy v1 and v2 models don't. If you embed long documents with FastEmbed, chunk them to fit the window, for example with `maxSize: 1500` in `MDocument.chunk()`.
435
+ FastEmbed models embed at most 512 tokens per input (about 2,000 to 2,500 characters of English text). Longer inputs are truncated, so text past the limit doesn't affect the embedding. Semantic recall sizes its message chunks to fit this window automatically (see [Long messages](#long-messages)). Outside of memory, the AI SDK v3 FastEmbed models return a warning when an input is truncated. The legacy v1 and v2 models don't. If you embed long documents with FastEmbed, chunk them to fit the window, for example with `maxSize: 1500` in `MDocument.chunk()`.
436
+
437
+ FastEmbed runs on your server's CPU. Under a CPU limit, such as a container's CPU quota, each loaded model uses one thread per CPU the process may use. Without a limit, it uses one thread per physical core. Each model has its own threads, so models loaded side by side add up. To leave CPU for the rest of your server, or when the process can't see its limit (for example a Kubernetes CPU request without a limit), set the thread count per model:
438
+
439
+ ```bash
440
+ MASTRA_FASTEMBED_THREADS=2
441
+ ```
436
442
 
437
443
  ### Setting the embedding dimension
438
444
 
@@ -507,4 +513,4 @@ Keep semantic recall disabled when:
507
513
 
508
514
  ## Viewing recalled messages
509
515
 
510
- When tracing is enabled, any messages retrieved via semantic recall will appear in the agent's trace output, alongside recent message history (if configured).
516
+ When tracing is enabled, any messages retrieved via semantic recall will show up in the agent's trace output, alongside recent message history (if configured).