@mastra/memory 1.22.0 → 1.22.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/{chunk-KKP6DG65.js → chunk-2NSPHF6Q.js} +10 -4
  3. package/dist/chunk-2NSPHF6Q.js.map +1 -0
  4. package/dist/{chunk-KXO2ZPM3.cjs → chunk-YWAAIUB6.cjs} +10 -4
  5. package/dist/chunk-YWAAIUB6.cjs.map +1 -0
  6. package/dist/docs/SKILL.md +1 -1
  7. package/dist/docs/assets/SOURCE_MAP.json +38 -38
  8. package/dist/docs/references/docs-agents-agent-approval.md +2 -0
  9. package/dist/docs/references/docs-agents-background-tasks.md +5 -3
  10. package/dist/docs/references/docs-agents-goals.md +4 -0
  11. package/dist/docs/references/docs-agents-networks.md +2 -0
  12. package/dist/docs/references/docs-agents-supervisor-agents.md +3 -0
  13. package/dist/docs/references/docs-evals-evals-with-memory.md +2 -0
  14. package/dist/docs/references/docs-memory-memory-processors.md +4 -0
  15. package/dist/docs/references/docs-memory-message-history.md +2 -0
  16. package/dist/docs/references/docs-memory-multi-user-threads.md +2 -0
  17. package/dist/docs/references/docs-memory-observational-memory.md +6 -0
  18. package/dist/docs/references/docs-memory-overview.md +5 -1
  19. package/dist/docs/references/docs-memory-semantic-recall.md +8 -0
  20. package/dist/docs/references/docs-memory-storage.md +6 -0
  21. package/dist/docs/references/docs-memory-working-memory.md +2 -0
  22. package/dist/docs/references/reference-core-getMemory.md +2 -0
  23. package/dist/docs/references/reference-core-listMemory.md +2 -0
  24. package/dist/docs/references/reference-memory-clone-utilities.md +2 -0
  25. package/dist/docs/references/reference-memory-cloneThread.md +2 -0
  26. package/dist/docs/references/reference-memory-createThread.md +2 -0
  27. package/dist/docs/references/reference-memory-getThreadById.md +2 -0
  28. package/dist/docs/references/reference-memory-listThreads.md +2 -0
  29. package/dist/docs/references/reference-memory-memory-class.md +3 -0
  30. package/dist/docs/references/reference-memory-observational-memory.md +10 -0
  31. package/dist/docs/references/reference-processors-token-limiter-processor.md +5 -0
  32. package/dist/docs/references/reference-storage-dsql.md +2 -0
  33. package/dist/docs/references/reference-storage-dynamodb.md +2 -0
  34. package/dist/docs/references/reference-storage-libsql.md +2 -0
  35. package/dist/docs/references/reference-storage-mongodb.md +2 -0
  36. package/dist/docs/references/reference-storage-postgresql.md +2 -0
  37. package/dist/docs/references/reference-storage-redis.md +2 -0
  38. package/dist/docs/references/reference-storage-upstash.md +2 -0
  39. package/dist/docs/references/reference-vectors-libsql.md +2 -0
  40. package/dist/docs/references/reference-vectors-mongodb.md +2 -0
  41. package/dist/docs/references/reference-vectors-pg.md +2 -0
  42. package/dist/docs/references/reference-vectors-upstash.md +2 -0
  43. package/dist/index.cjs +13 -13
  44. package/dist/index.js +1 -1
  45. package/dist/{observational-memory-GSJXSJXG.cjs → observational-memory-CZ22AU3H.cjs} +28 -28
  46. package/dist/{observational-memory-GSJXSJXG.cjs.map → observational-memory-CZ22AU3H.cjs.map} +1 -1
  47. package/dist/{observational-memory-PBLNZABH.js → observational-memory-QL6BKIQX.js} +3 -3
  48. package/dist/{observational-memory-PBLNZABH.js.map → observational-memory-QL6BKIQX.js.map} +1 -1
  49. package/dist/processors/index.cjs +26 -26
  50. package/dist/processors/index.js +1 -1
  51. package/dist/processors/observational-memory/token-counter.d.ts.map +1 -1
  52. package/package.json +6 -6
  53. package/dist/chunk-KKP6DG65.js.map +0 -1
  54. package/dist/chunk-KXO2ZPM3.cjs.map +0 -1
@@ -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.22.0"
6
+ version: "1.22.1-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,129 +1,129 @@
1
1
  {
2
- "version": "1.22.0",
2
+ "version": "1.22.1-alpha.1",
3
3
  "package": "@mastra/memory",
4
4
  "exports": {
5
5
  "Extractor": {
6
6
  "types": "dist/processors/index.d.ts",
7
- "implementation": "dist/chunk-KKP6DG65.js",
7
+ "implementation": "dist/chunk-2NSPHF6Q.js",
8
8
  "line": 316
9
9
  },
10
10
  "ModelByInputTokens": {
11
11
  "types": "dist/processors/index.d.ts",
12
- "implementation": "dist/chunk-KKP6DG65.js",
12
+ "implementation": "dist/chunk-2NSPHF6Q.js",
13
13
  "line": 1354
14
14
  },
15
15
  "OBSERVER_SYSTEM_PROMPT": {
16
16
  "types": "dist/processors/index.d.ts",
17
- "implementation": "dist/chunk-KKP6DG65.js"
17
+ "implementation": "dist/chunk-2NSPHF6Q.js"
18
18
  },
19
19
  "ObservationalMemory": {
20
20
  "types": "dist/processors/index.d.ts",
21
- "implementation": "dist/chunk-KKP6DG65.js",
22
- "line": 27526
21
+ "implementation": "dist/chunk-2NSPHF6Q.js",
22
+ "line": 27532
23
23
  },
24
24
  "ObservationalMemoryProcessor": {
25
25
  "types": "dist/processors/index.d.ts",
26
- "implementation": "dist/chunk-KKP6DG65.js",
27
- "line": 30157
26
+ "implementation": "dist/chunk-2NSPHF6Q.js",
27
+ "line": 30163
28
28
  },
29
29
  "TokenCounter": {
30
30
  "types": "dist/processors/index.d.ts",
31
- "implementation": "dist/chunk-KKP6DG65.js",
31
+ "implementation": "dist/chunk-2NSPHF6Q.js",
32
32
  "line": 26857
33
33
  },
34
34
  "WorkingMemoryExtractor": {
35
35
  "types": "dist/processors/index.d.ts",
36
- "implementation": "dist/chunk-KKP6DG65.js",
36
+ "implementation": "dist/chunk-2NSPHF6Q.js",
37
37
  "line": 20684
38
38
  },
39
39
  "buildObserverPrompt": {
40
40
  "types": "dist/processors/index.d.ts",
41
- "implementation": "dist/chunk-KKP6DG65.js",
41
+ "implementation": "dist/chunk-2NSPHF6Q.js",
42
42
  "line": 4465
43
43
  },
44
44
  "buildObserverSystemPrompt": {
45
45
  "types": "dist/processors/index.d.ts",
46
- "implementation": "dist/chunk-KKP6DG65.js",
46
+ "implementation": "dist/chunk-2NSPHF6Q.js",
47
47
  "line": 3732
48
48
  },
49
49
  "combineObservationGroupRanges": {
50
50
  "types": "dist/processors/index.d.ts",
51
- "implementation": "dist/chunk-KKP6DG65.js",
51
+ "implementation": "dist/chunk-2NSPHF6Q.js",
52
52
  "line": 1446
53
53
  },
54
54
  "deriveObservationGroupProvenance": {
55
55
  "types": "dist/processors/index.d.ts",
56
- "implementation": "dist/chunk-KKP6DG65.js",
56
+ "implementation": "dist/chunk-2NSPHF6Q.js",
57
57
  "line": 1480
58
58
  },
59
59
  "extractCurrentTask": {
60
60
  "types": "dist/processors/index.d.ts",
61
- "implementation": "dist/chunk-KKP6DG65.js",
61
+ "implementation": "dist/chunk-2NSPHF6Q.js",
62
62
  "line": 4588
63
63
  },
64
64
  "formatMessagesForObserver": {
65
65
  "types": "dist/processors/index.d.ts",
66
- "implementation": "dist/chunk-KKP6DG65.js",
66
+ "implementation": "dist/chunk-2NSPHF6Q.js",
67
67
  "line": 4187
68
68
  },
69
69
  "getObservationsAsOf": {
70
70
  "types": "dist/processors/index.d.ts",
71
- "implementation": "dist/chunk-KKP6DG65.js",
72
- "line": 30379
71
+ "implementation": "dist/chunk-2NSPHF6Q.js",
72
+ "line": 30385
73
73
  },
74
74
  "hasCurrentTaskSection": {
75
75
  "types": "dist/processors/index.d.ts",
76
- "implementation": "dist/chunk-KKP6DG65.js",
76
+ "implementation": "dist/chunk-2NSPHF6Q.js",
77
77
  "line": 4576
78
78
  },
79
79
  "injectAnchorIds": {
80
80
  "types": "dist/processors/index.d.ts",
81
- "implementation": "dist/chunk-KKP6DG65.js",
81
+ "implementation": "dist/chunk-2NSPHF6Q.js",
82
82
  "line": 3287
83
83
  },
84
84
  "optimizeObservationsForContext": {
85
85
  "types": "dist/processors/index.d.ts",
86
- "implementation": "dist/chunk-KKP6DG65.js",
86
+ "implementation": "dist/chunk-2NSPHF6Q.js",
87
87
  "line": 4599
88
88
  },
89
89
  "parseAnchorId": {
90
90
  "types": "dist/processors/index.d.ts",
91
- "implementation": "dist/chunk-KKP6DG65.js",
91
+ "implementation": "dist/chunk-2NSPHF6Q.js",
92
92
  "line": 3260
93
93
  },
94
94
  "parseObservationGroups": {
95
95
  "types": "dist/processors/index.d.ts",
96
- "implementation": "dist/chunk-KKP6DG65.js",
96
+ "implementation": "dist/chunk-2NSPHF6Q.js",
97
97
  "line": 1415
98
98
  },
99
99
  "parseObserverOutput": {
100
100
  "types": "dist/processors/index.d.ts",
101
- "implementation": "dist/chunk-KKP6DG65.js",
101
+ "implementation": "dist/chunk-2NSPHF6Q.js",
102
102
  "line": 4479
103
103
  },
104
104
  "reconcileObservationGroupsFromReflection": {
105
105
  "types": "dist/processors/index.d.ts",
106
- "implementation": "dist/chunk-KKP6DG65.js",
106
+ "implementation": "dist/chunk-2NSPHF6Q.js",
107
107
  "line": 1504
108
108
  },
109
109
  "renderObservationGroupsForReflection": {
110
110
  "types": "dist/processors/index.d.ts",
111
- "implementation": "dist/chunk-KKP6DG65.js",
111
+ "implementation": "dist/chunk-2NSPHF6Q.js",
112
112
  "line": 1460
113
113
  },
114
114
  "stripEphemeralAnchorIds": {
115
115
  "types": "dist/processors/index.d.ts",
116
- "implementation": "dist/chunk-KKP6DG65.js",
116
+ "implementation": "dist/chunk-2NSPHF6Q.js",
117
117
  "line": 3317
118
118
  },
119
119
  "stripObservationGroups": {
120
120
  "types": "dist/processors/index.d.ts",
121
- "implementation": "dist/chunk-KKP6DG65.js",
121
+ "implementation": "dist/chunk-2NSPHF6Q.js",
122
122
  "line": 1437
123
123
  },
124
124
  "wrapInObservationGroup": {
125
125
  "types": "dist/processors/index.d.ts",
126
- "implementation": "dist/chunk-KKP6DG65.js",
126
+ "implementation": "dist/chunk-2NSPHF6Q.js",
127
127
  "line": 1408
128
128
  },
129
129
  "OBSERVATIONAL_MEMORY_DEFAULTS": {
@@ -144,39 +144,39 @@
144
144
  },
145
145
  "Memory": {
146
146
  "types": "dist/index.d.ts",
147
- "implementation": "dist/chunk-KKP6DG65.js",
147
+ "implementation": "dist/chunk-2NSPHF6Q.js",
148
148
  "line": 22108
149
149
  },
150
150
  "MessageHistory": {
151
151
  "types": "dist/index.d.ts",
152
- "implementation": "dist/chunk-KKP6DG65.js"
152
+ "implementation": "dist/chunk-2NSPHF6Q.js"
153
153
  },
154
154
  "SemanticRecall": {
155
155
  "types": "dist/index.d.ts",
156
- "implementation": "dist/chunk-KKP6DG65.js"
156
+ "implementation": "dist/chunk-2NSPHF6Q.js"
157
157
  },
158
158
  "WorkingMemory": {
159
159
  "types": "dist/index.d.ts",
160
- "implementation": "dist/chunk-KKP6DG65.js"
160
+ "implementation": "dist/chunk-2NSPHF6Q.js"
161
161
  },
162
162
  "deepMergeWorkingMemory": {
163
163
  "types": "dist/index.d.ts",
164
- "implementation": "dist/chunk-KKP6DG65.js",
164
+ "implementation": "dist/chunk-2NSPHF6Q.js",
165
165
  "line": 21747
166
166
  },
167
167
  "extractWorkingMemoryContent": {
168
168
  "types": "dist/index.d.ts",
169
- "implementation": "dist/chunk-KKP6DG65.js",
169
+ "implementation": "dist/chunk-2NSPHF6Q.js",
170
170
  "line": 22063
171
171
  },
172
172
  "extractWorkingMemoryTags": {
173
173
  "types": "dist/index.d.ts",
174
- "implementation": "dist/chunk-KKP6DG65.js",
174
+ "implementation": "dist/chunk-2NSPHF6Q.js",
175
175
  "line": 22031
176
176
  },
177
177
  "removeWorkingMemoryTags": {
178
178
  "types": "dist/index.d.ts",
179
- "implementation": "dist/chunk-KKP6DG65.js",
179
+ "implementation": "dist/chunk-2NSPHF6Q.js",
180
180
  "line": 22044
181
181
  },
182
182
  "WORKING_MEMORY_STATE_ID": {
@@ -197,7 +197,7 @@
197
197
  "processors": {
198
198
  "index": "dist/processors/index.js",
199
199
  "chunks": [
200
- "chunk-KKP6DG65.js",
200
+ "chunk-2NSPHF6Q.js",
201
201
  "chunk-LSJJAJAF.js"
202
202
  ]
203
203
  }
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Agent approval
2
4
 
3
5
  Agents sometimes require the same [human-in-the-loop](https://mastra.ai/docs/workflows/human-in-the-loop) oversight used in workflows when calling tools that handle sensitive operations, like deleting resources or running long processes. With agent approval you can suspend a tool call before it executes so a human can approve or decline it, or let tools suspend themselves to request additional context from the user.
@@ -1,8 +1,10 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Background tasks
2
4
 
3
5
  **Added in:** `@mastra/core@1.29.0`
4
6
 
5
- Background tasks let an agent dispatch a long-running tool call without blocking the agentic loop. The tool returns an immediate acknowledgement, the LLM continues responding, and the task runs to completion in the background. When it finishes, its result is written to memory and if you use `stream()` with the [`untilIdle`](https://mastra.ai/reference/agents/agent) option the agent is re-invoked automatically so the result is processed in the same call.
7
+ Background tasks let an agent dispatch a long-running tool call without blocking the agentic loop. The tool returns an immediate acknowledgement, the LLM continues responding, and the task runs to completion in the background. When it finishes, its result is written to memory and if you use `stream()` with the [`untilIdle`](https://mastra.ai/reference/streaming/agents/stream) option the agent is re-invoked automatically so the result is processed in the same call.
6
8
 
7
9
  ## When to use background tasks
8
10
 
@@ -166,7 +168,7 @@ const stream = await agent.stream('Research solana for me', {
166
168
  })
167
169
  ```
168
170
 
169
- > **Note:** Visit [`Agent.stream()`](https://mastra.ai/reference/agents/agent) for the full API.
171
+ > **Note:** Visit [`Agent.stream()`](https://mastra.ai/reference/streaming/agents/stream) for the full API.
170
172
 
171
173
  ### Aggregate properties
172
174
 
@@ -372,7 +374,7 @@ These read from storage rather than the pubsub stream, so they're suitable for p
372
374
 
373
375
  ## Related
374
376
 
375
- - [`Agent.stream()` reference](https://mastra.ai/reference/agents/agent)
377
+ - [`Agent.stream()` reference](https://mastra.ai/reference/streaming/agents/stream)
376
378
  - [backgroundTasks configuration reference](https://mastra.ai/reference/configuration)
377
379
  - [Durable agents](https://mastra.ai/docs/agents/durable-agents)
378
380
  - [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents)
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Goals
2
4
 
3
5
  **Added in:** `@mastra/core@1.42.0`
@@ -26,6 +28,7 @@ Goals require a configured [storage](https://mastra.ai/docs/memory/storage) back
26
28
  import { Agent } from '@mastra/core/agent'
27
29
 
28
30
  const worker = new Agent({
31
+ id: 'worker',
29
32
  name: 'worker',
30
33
  instructions: 'You complete software tasks end to end.',
31
34
  model: 'openai/gpt-5.5',
@@ -66,6 +69,7 @@ By default the step uses a built-in LLM-as-judge scorer that returns `1` when th
66
69
 
67
70
  ```typescript
68
71
  const worker = new Agent({
72
+ id: 'worker',
69
73
  name: 'worker',
70
74
  instructions: 'You complete software tasks end to end.',
71
75
  model: 'openai/gpt-5.5',
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Agent networks
2
4
 
3
5
  > **Deprecated — Use supervisor agents:** Agent networks are deprecated and will be removed in a future major release. [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents) using `agent.stream()` or `agent.generate()` are now the recommended approach. It provides the same multi-agent coordination with better control, a simpler API, and easier debugging.
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Supervisor agents
2
4
 
3
5
  **Added in:** `@mastra/core@1.8.0`
@@ -351,6 +353,7 @@ Each subagent should have a clear `description` that explains what it does, what
351
353
 
352
354
  ```typescript
353
355
  const supervisor = new Agent({
356
+ id: 'supervisor',
354
357
  instructions: `You coordinate research and writing tasks.
355
358
 
356
359
  Available resources:
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Evals with memory
2
4
 
3
5
  Agents that use memory in `thread` scope — including observational memory — require a thread ID at run time. When an eval invokes the agent without one, you'll see:
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Memory processors
2
4
 
3
5
  Memory processors transform and filter messages as they pass through an agent with memory enabled. They manage context window limits, remove unnecessary content, and optimize the information sent to the language model.
@@ -248,6 +250,7 @@ const contentBlocker = {
248
250
  }
249
251
 
250
252
  const agent = new Agent({
253
+ id: 'safe-agent',
251
254
  name: 'safe-agent',
252
255
  instructions: 'You are a helpful assistant',
253
256
  model: 'openai/gpt-5.5',
@@ -287,6 +290,7 @@ const inputValidator = {
287
290
  }
288
291
 
289
292
  const agent = new Agent({
293
+ id: 'validated-agent',
290
294
  name: 'validated-agent',
291
295
  instructions: 'You are a helpful assistant',
292
296
  model: 'openai/gpt-5.5',
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Message history
2
4
 
3
5
  Message history is the most basic and important form of memory. It gives the LLM a view of recent messages in the context window, enabling your agent to reference earlier exchanges and respond coherently.
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Multi-user threads
2
4
 
3
5
  A single Mastra thread can be shared by multiple users, each with their own name and functional role. You carry speaker identity in the message body so the agent can tell users apart while reading from a single shared thread.
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Observational Memory
2
4
 
3
5
  **Added in:** `@mastra/memory@1.1.0`
@@ -13,6 +15,7 @@ import { Memory } from '@mastra/memory'
13
15
  import { Agent } from '@mastra/core/agent'
14
16
 
15
17
  export const agent = new Agent({
18
+ id: 'my-agent',
16
19
  name: 'my-agent',
17
20
  instructions: 'You are a helpful assistant.',
18
21
  model: 'openai/gpt-5-mini',
@@ -57,6 +60,7 @@ import { Memory } from '@mastra/memory'
57
60
  import { Agent } from '@mastra/core/agent'
58
61
 
59
62
  export const agent = new Agent({
63
+ id: 'my-agent',
60
64
  name: 'my-agent',
61
65
  instructions: 'You are a helpful assistant.',
62
66
  model: 'openai/gpt-5-mini',
@@ -196,6 +200,7 @@ const memory = new Memory({
196
200
  })
197
201
 
198
202
  export const agent = new Agent({
203
+ id: 'assistant',
199
204
  name: 'assistant',
200
205
  instructions: 'You are a helpful assistant.',
201
206
  model: 'openai/gpt-5-mini',
@@ -281,6 +286,7 @@ If your Observer model is text-only or its API rejects multimodal input, set `ob
281
286
 
282
287
  ```typescript
283
288
  new Agent({
289
+ id: 'assistant',
284
290
  name: 'assistant',
285
291
  instructions: 'You are a helpful assistant.',
286
292
  model: 'openai/gpt-5-mini',
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Memory
2
4
 
3
5
  Memory enables your agent to remember user messages, agent replies, and tool results across interactions, giving it the context it needs to stay consistent, maintain conversation flow, and produce better answers over time.
@@ -174,7 +176,9 @@ Each delegation creates a fresh `threadId` and a deterministic `resourceId` for
174
176
 
175
177
  - **Thread ID**: Unique per delegation. The subagent starts with a clean message history every time it's called.
176
178
  - **Resource ID**: Derived as `{parentResourceId}-{agentName}`. Because the resource ID is stable across delegations, resource-scoped memory persists between calls. A subagent remembers facts from previous delegations by the same user.
177
- - **Memory instance**: If a subagent has no memory configured, it inherits the supervisor's `Memory` instance. If the subagent defines its own, that takes precedence.
179
+ - **Memory instance**: If a subagent has no memory configured, it inherits the supervisor's `Memory` instance, including all of its options. If the subagent defines its own, that takes precedence.
180
+
181
+ > **Note:** Title generation (`generateTitle`) is a top-level thread concern and is **not** applied to inherited subagent threads. Because each delegation creates an ephemeral thread that no one sees, running title generation for it would waste an LLM call per delegation. To generate titles for a subagent's own threads, give that subagent its own memory configuration.
178
182
 
179
183
  The supervisor forwards its conversation context to the subagent so it has enough background to complete the task. Only the delegation prompt and the subagent's response are saved — the full parent conversation isn't stored. You can control which messages reach the subagent with the [`messageFilter`](https://mastra.ai/docs/agents/supervisor-agents) callback.
180
184
 
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Semantic recall
2
4
 
3
5
  If you ask your friend what they did last weekend, they will search in their memory for events associated with "last weekend" and then tell you what they did. That's sort of like how semantic recall works in Mastra.
@@ -130,6 +132,7 @@ The following options control semantic recall behavior:
130
132
 
131
133
  ```typescript
132
134
  const agent = new Agent({
135
+ id: 'agent',
133
136
  memory: new Memory({
134
137
  options: {
135
138
  semanticRecall: {
@@ -151,6 +154,7 @@ The `filter` option restricts semantic recall results to messages with matching
151
154
 
152
155
  ```typescript
153
156
  const agent = new Agent({
157
+ id: 'agent',
154
158
  memory: new Memory({
155
159
  options: {
156
160
  semanticRecall: {
@@ -217,6 +221,7 @@ import { Agent } from '@mastra/core/agent'
217
221
  import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
218
222
 
219
223
  const agent = new Agent({
224
+ id: 'agent',
220
225
  memory: new Memory({
221
226
  embedder: new ModelRouterEmbeddingModel('openai/text-embedding-3-small'),
222
227
  options: {
@@ -238,6 +243,7 @@ import { Memory } from '@mastra/memory'
238
243
  import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
239
244
 
240
245
  const agent = new Agent({
246
+ id: 'agent',
241
247
  memory: new Memory({
242
248
  embedder: new ModelRouterEmbeddingModel({
243
249
  providerId: 'openrouter',
@@ -259,6 +265,7 @@ import { Agent } from '@mastra/core/agent'
259
265
  import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
260
266
 
261
267
  const agent = new Agent({
268
+ id: 'agent',
262
269
  memory: new Memory({
263
270
  embedder: new ModelRouterEmbeddingModel('openai/text-embedding-3-small'),
264
271
  }),
@@ -301,6 +308,7 @@ import { Agent } from '@mastra/core/agent'
301
308
  import { fastembed } from '@mastra/fastembed'
302
309
 
303
310
  const agent = new Agent({
311
+ id: 'agent',
304
312
  memory: new Memory({
305
313
  embedder: fastembed,
306
314
  }),
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Storage
2
4
 
3
5
  For agents to remember previous interactions, Mastra needs a storage adapter. Use one of the [supported providers](#supported-providers) and pass it to your Mastra instance.
@@ -100,6 +102,10 @@ export const mastra = new Mastra({
100
102
 
101
103
  This is useful when different types of data have different performance or operational requirements, such as low-latency storage for memory, durable storage for workflows, and high-throughput storage for observability.
102
104
 
105
+ #### Retention
106
+
107
+ Storage grows without bound by default. To cap growth, declare per-table `maxAge` policies in the `retention` config and call `storage.prune()` from your own scheduler to delete old rows. Anything you don't configure is kept forever. See [Storage retention](https://mastra.ai/reference/storage/retention) for `prune()` and the full config shape.
108
+
103
109
  ### Agent-level storage
104
110
 
105
111
  Agent-level storage overrides storage configured at the instance level. Add storage to a specific agent when you need to keep data separate or use different providers per agent.
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Working Memory
2
4
 
3
5
  While [message history](https://mastra.ai/docs/memory/message-history) and [semantic recall](https://mastra.ai/docs/memory/semantic-recall) help agents remember conversations, working memory allows them to maintain persistent information about users across interactions.
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Mastra.getMemory()
2
4
 
3
5
  The `.getMemory()` method retrieves a memory instance from the Mastra registry by its key. Memory instances are registered in the Mastra constructor and can be referenced by stored agents.
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Mastra.listMemory()
2
4
 
3
5
  The `.listMemory()` method returns all memory instances registered with the Mastra instance.
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Cloned thread utilities
2
4
 
3
5
  The Memory class provides utility methods for working with cloned threads. These methods help you check clone status, retrieve clone metadata, navigate clone relationships, and track clone history.
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Memory.cloneThread()
2
4
 
3
5
  The `.cloneThread()` method creates a copy of an existing conversation thread, including all its messages. This enables creating divergent conversation paths from a specific point in a conversation. When semantic recall is enabled, the method also creates vector embeddings for the cloned messages.
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Memory.createThread()
2
4
 
3
5
  The `.createThread()` method creates a new conversation thread in the memory system. Each thread represents a distinct conversation or context and can contain multiple messages.
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Memory.getThreadById()
2
4
 
3
5
  The `.getThreadById()` method retrieves a specific thread by its ID.
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Memory.listThreads()
2
4
 
3
5
  The `listThreads()` method retrieves threads with pagination support and optional filtering by `resourceId`, `metadata`, or both.
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Memory class
2
4
 
3
5
  The `Memory` class provides a robust system for managing conversation history and thread-based message storage in Mastra. It enables persistent storage of conversations, semantic search capabilities, and efficient message retrieval. You must configure a storage provider for conversation history, and if you enable semantic recall you will also need to provide a vector store and embedder.
@@ -9,6 +11,7 @@ import { Memory } from '@mastra/memory'
9
11
  import { Agent } from '@mastra/core/agent'
10
12
 
11
13
  export const agent = new Agent({
14
+ id: 'test-agent',
12
15
  name: 'test-agent',
13
16
  instructions: 'You are an agent with memory.',
14
17
  model: 'openai/gpt-5.5',
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # Observational Memory
2
4
 
3
5
  **Added in:** `@mastra/memory@1.1.0`
@@ -11,6 +13,7 @@ import { Memory } from '@mastra/memory'
11
13
  import { Agent } from '@mastra/core/agent'
12
14
 
13
15
  export const agent = new Agent({
16
+ id: 'my-agent',
14
17
  name: 'my-agent',
15
18
  instructions: 'You are a helpful assistant.',
16
19
  model: 'openai/gpt-5-mini',
@@ -203,6 +206,7 @@ import { Memory } from '@mastra/memory'
203
206
  import { Agent } from '@mastra/core/agent'
204
207
 
205
208
  export const agent = new Agent({
209
+ id: 'my-agent',
206
210
  name: 'my-agent',
207
211
  instructions: 'You are a helpful assistant.',
208
212
  model: 'openai/gpt-5-mini',
@@ -232,6 +236,7 @@ import { Memory } from '@mastra/memory'
232
236
  import { Agent } from '@mastra/core/agent'
233
237
 
234
238
  export const agent = new Agent({
239
+ id: 'my-agent',
235
240
  name: 'my-agent',
236
241
  instructions: 'You are a helpful assistant.',
237
242
  model: 'openai/gpt-5-mini',
@@ -261,6 +266,7 @@ import { Memory } from '@mastra/memory'
261
266
  import { Agent } from '@mastra/core/agent'
262
267
 
263
268
  export const agent = new Agent({
269
+ id: 'my-agent',
264
270
  name: 'my-agent',
265
271
  instructions: 'You are a helpful assistant.',
266
272
  model: 'openai/gpt-5.5',
@@ -281,6 +287,7 @@ import { Memory } from '@mastra/memory'
281
287
  import { Agent } from '@mastra/core/agent'
282
288
 
283
289
  export const agent = new Agent({
290
+ id: 'my-agent',
284
291
  name: 'my-agent',
285
292
  instructions: 'You are a helpful assistant.',
286
293
  model: 'openai/gpt-5.5',
@@ -308,6 +315,7 @@ import { Memory } from '@mastra/memory'
308
315
  import { Agent } from '@mastra/core/agent'
309
316
 
310
317
  export const agent = new Agent({
318
+ id: 'health-assistant',
311
319
  name: 'health-assistant',
312
320
  instructions: 'You are a health and wellness assistant.',
313
321
  model: 'openai/gpt-5.5',
@@ -351,6 +359,7 @@ import { Memory } from '@mastra/memory'
351
359
  import { Agent } from '@mastra/core/agent'
352
360
 
353
361
  export const agent = new Agent({
362
+ id: 'my-agent',
354
363
  name: 'my-agent',
355
364
  instructions: 'You are a helpful assistant.',
356
365
  model: 'openai/gpt-5-mini',
@@ -666,6 +675,7 @@ const om = new ObservationalMemory({
666
675
  })
667
676
 
668
677
  export const agent = new Agent({
678
+ id: 'my-agent',
669
679
  name: 'my-agent',
670
680
  instructions: 'You are a helpful assistant.',
671
681
  model: 'openai/gpt-5-mini',
@@ -1,3 +1,5 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
1
3
  # TokenLimiterProcessor
2
4
 
3
5
  The `TokenLimiterProcessor` limits the number of tokens in messages. It can be used as an input, per-step input, and output processor:
@@ -79,6 +81,7 @@ import { Memory } from '@mastra/memory'
79
81
  import { TokenLimiterProcessor } from '@mastra/core/processors'
80
82
 
81
83
  export const agent = new Agent({
84
+ id: 'context-limited-agent',
82
85
  name: 'context-limited-agent',
83
86
  instructions: 'You are a helpful assistant',
84
87
  model: 'openai/gpt-5.5',
@@ -100,6 +103,7 @@ import { Agent } from '@mastra/core/agent'
100
103
  import { TokenLimiterProcessor } from '@mastra/core/processors'
101
104
 
102
105
  export const agent = new Agent({
106
+ id: 'multi-step-agent',
103
107
  name: 'multi-step-agent',
104
108
  instructions: 'You are a helpful research assistant with access to tools',
105
109
  model: 'openai/gpt-5.5',
@@ -123,6 +127,7 @@ import { Agent } from '@mastra/core/agent'
123
127
  import { TokenLimiterProcessor } from '@mastra/core/processors'
124
128
 
125
129
  export const agent = new Agent({
130
+ id: 'response-limited-agent',
126
131
  name: 'response-limited-agent',
127
132
  instructions: 'You are a helpful assistant',
128
133
  model: 'openai/gpt-5.5',