@mastra/memory 1.22.2-alpha.0 → 1.22.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 (31) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/{chunk-TB6SV7QK.js → chunk-5PG7DW2T.js} +4 -4
  3. package/dist/{chunk-TB6SV7QK.js.map → chunk-5PG7DW2T.js.map} +1 -1
  4. package/dist/{chunk-3JX4RMDN.cjs → chunk-G6PR4XBO.cjs} +4 -4
  5. package/dist/{chunk-3JX4RMDN.cjs.map → chunk-G6PR4XBO.cjs.map} +1 -1
  6. package/dist/docs/SKILL.md +3 -3
  7. package/dist/docs/assets/SOURCE_MAP.json +35 -35
  8. package/dist/docs/references/docs-agents-agent-approval.md +2 -2
  9. package/dist/docs/references/docs-agents-networks.md +1 -1
  10. package/dist/docs/references/docs-long-running-agents-background-tasks.md +2 -2
  11. package/dist/docs/references/docs-long-running-agents-goals.md +4 -4
  12. package/dist/docs/references/docs-memory-memory-processors.md +67 -0
  13. package/dist/docs/references/docs-memory-message-history.md +56 -2
  14. package/dist/docs/references/docs-memory-observational-memory.md +3 -3
  15. package/dist/docs/references/docs-memory-overview.md +3 -3
  16. package/dist/docs/references/docs-memory-semantic-recall.md +35 -1
  17. package/dist/docs/references/docs-storage-overview.md +214 -0
  18. package/dist/docs/references/reference-memory-observational-memory.md +1 -1
  19. package/dist/docs/references/reference-storage-dynamodb.md +1 -1
  20. package/dist/docs/references/reference-storage-mongodb.md +46 -46
  21. package/dist/docs/references/reference-vectors-mongodb.md +93 -4
  22. package/dist/index.cjs +13 -13
  23. package/dist/index.js +1 -1
  24. package/dist/{observational-memory-TEIGXE56.cjs → observational-memory-36K5KQCO.cjs} +28 -28
  25. package/dist/{observational-memory-TEIGXE56.cjs.map → observational-memory-36K5KQCO.cjs.map} +1 -1
  26. package/dist/{observational-memory-NNGAOKRQ.js → observational-memory-JABZ6XNI.js} +3 -3
  27. package/dist/{observational-memory-NNGAOKRQ.js.map → observational-memory-JABZ6XNI.js.map} +1 -1
  28. package/dist/processors/index.cjs +26 -26
  29. package/dist/processors/index.js +1 -1
  30. package/package.json +8 -8
  31. package/dist/docs/references/docs-memory-storage.md +0 -267
@@ -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.2-alpha.0"
6
+ version: "1.22.3-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -21,15 +21,15 @@ Read the individual reference documents for detailed explanations and code examp
21
21
  - [Supervisor agents](references/docs-agents-supervisor-agents.md) - Learn how to coordinate multiple agents with delegation hooks, iteration monitoring, message filtering, and task completion scoring.
22
22
  - [Evals with memory](references/docs-evals-evals-with-memory.md) - Run scorers against memory-enabled agents — including observational memory in thread scope — using runEvals and dataset experiments.
23
23
  - [Background tasks](references/docs-long-running-agents-background-tasks.md) - Learn how to dispatch long-running tool calls in the background, keep the stream open until they complete, and orchestrate subagents asynchronously.
24
- - [Goals](references/docs-long-running-agents-goals.md) - Learn how to set a durable objective on an agent that is judged in the execution loop, so the agent keeps working until the goal is complete or the run budget is exhausted.
24
+ - [Goals](references/docs-long-running-agents-goals.md) - Learn how to set a durable objective on an agent that's judged in the execution loop, so the agent keeps working until the goal is complete or the run budget is exhausted.
25
25
  - [Memory processors](references/docs-memory-memory-processors.md) - Learn how to use memory processors in Mastra to filter, trim, and transform messages before they're sent to the language model to manage context window limits.
26
26
  - [Message history](references/docs-memory-message-history.md) - Learn how to configure message history in Mastra to store recent messages from the current conversation.
27
27
  - [Multi-user threads](references/docs-memory-multi-user-threads.md) - Share one Mastra thread between multiple users by carrying speaker identity in the message body.
28
28
  - [Observational Memory](references/docs-memory-observational-memory.md) - Learn how Observational Memory keeps your agent's context window small while preserving long-term memory across conversations.
29
29
  - [Memory overview](references/docs-memory-overview.md) - Learn how Mastra's memory system works with working memory, message history, semantic recall, and observational memory.
30
30
  - [Semantic recall](references/docs-memory-semantic-recall.md) - Learn how to use semantic recall in Mastra to retrieve relevant messages from past conversations using vector search and embeddings.
31
- - [Storage](references/docs-memory-storage.md) - Configure storage for Mastra to persist conversations and other runtime state.
32
31
  - [Working memory](references/docs-memory-working-memory.md) - Learn how to configure working memory in Mastra to store persistent user data, preferences.
32
+ - [Storage overview](references/docs-storage-overview.md) - Configure storage for Mastra to persist runtime state across agents, workflows, observability, evals, schedules, and memory.
33
33
 
34
34
  ### Reference
35
35
 
@@ -1,129 +1,129 @@
1
1
  {
2
- "version": "1.22.2-alpha.0",
2
+ "version": "1.22.3-alpha.0",
3
3
  "package": "@mastra/memory",
4
4
  "exports": {
5
5
  "Extractor": {
6
6
  "types": "dist/processors/index.d.ts",
7
- "implementation": "dist/chunk-TB6SV7QK.js",
7
+ "implementation": "dist/chunk-5PG7DW2T.js",
8
8
  "line": 316
9
9
  },
10
10
  "ModelByInputTokens": {
11
11
  "types": "dist/processors/index.d.ts",
12
- "implementation": "dist/chunk-TB6SV7QK.js",
12
+ "implementation": "dist/chunk-5PG7DW2T.js",
13
13
  "line": 1354
14
14
  },
15
15
  "OBSERVER_SYSTEM_PROMPT": {
16
16
  "types": "dist/processors/index.d.ts",
17
- "implementation": "dist/chunk-TB6SV7QK.js"
17
+ "implementation": "dist/chunk-5PG7DW2T.js"
18
18
  },
19
19
  "ObservationalMemory": {
20
20
  "types": "dist/processors/index.d.ts",
21
- "implementation": "dist/chunk-TB6SV7QK.js",
21
+ "implementation": "dist/chunk-5PG7DW2T.js",
22
22
  "line": 27533
23
23
  },
24
24
  "ObservationalMemoryProcessor": {
25
25
  "types": "dist/processors/index.d.ts",
26
- "implementation": "dist/chunk-TB6SV7QK.js",
26
+ "implementation": "dist/chunk-5PG7DW2T.js",
27
27
  "line": 30164
28
28
  },
29
29
  "TokenCounter": {
30
30
  "types": "dist/processors/index.d.ts",
31
- "implementation": "dist/chunk-TB6SV7QK.js",
31
+ "implementation": "dist/chunk-5PG7DW2T.js",
32
32
  "line": 26858
33
33
  },
34
34
  "WorkingMemoryExtractor": {
35
35
  "types": "dist/processors/index.d.ts",
36
- "implementation": "dist/chunk-TB6SV7QK.js",
36
+ "implementation": "dist/chunk-5PG7DW2T.js",
37
37
  "line": 20684
38
38
  },
39
39
  "buildObserverPrompt": {
40
40
  "types": "dist/processors/index.d.ts",
41
- "implementation": "dist/chunk-TB6SV7QK.js",
41
+ "implementation": "dist/chunk-5PG7DW2T.js",
42
42
  "line": 4465
43
43
  },
44
44
  "buildObserverSystemPrompt": {
45
45
  "types": "dist/processors/index.d.ts",
46
- "implementation": "dist/chunk-TB6SV7QK.js",
46
+ "implementation": "dist/chunk-5PG7DW2T.js",
47
47
  "line": 3732
48
48
  },
49
49
  "combineObservationGroupRanges": {
50
50
  "types": "dist/processors/index.d.ts",
51
- "implementation": "dist/chunk-TB6SV7QK.js",
51
+ "implementation": "dist/chunk-5PG7DW2T.js",
52
52
  "line": 1446
53
53
  },
54
54
  "deriveObservationGroupProvenance": {
55
55
  "types": "dist/processors/index.d.ts",
56
- "implementation": "dist/chunk-TB6SV7QK.js",
56
+ "implementation": "dist/chunk-5PG7DW2T.js",
57
57
  "line": 1480
58
58
  },
59
59
  "extractCurrentTask": {
60
60
  "types": "dist/processors/index.d.ts",
61
- "implementation": "dist/chunk-TB6SV7QK.js",
61
+ "implementation": "dist/chunk-5PG7DW2T.js",
62
62
  "line": 4588
63
63
  },
64
64
  "formatMessagesForObserver": {
65
65
  "types": "dist/processors/index.d.ts",
66
- "implementation": "dist/chunk-TB6SV7QK.js",
66
+ "implementation": "dist/chunk-5PG7DW2T.js",
67
67
  "line": 4187
68
68
  },
69
69
  "getObservationsAsOf": {
70
70
  "types": "dist/processors/index.d.ts",
71
- "implementation": "dist/chunk-TB6SV7QK.js",
71
+ "implementation": "dist/chunk-5PG7DW2T.js",
72
72
  "line": 30386
73
73
  },
74
74
  "hasCurrentTaskSection": {
75
75
  "types": "dist/processors/index.d.ts",
76
- "implementation": "dist/chunk-TB6SV7QK.js",
76
+ "implementation": "dist/chunk-5PG7DW2T.js",
77
77
  "line": 4576
78
78
  },
79
79
  "injectAnchorIds": {
80
80
  "types": "dist/processors/index.d.ts",
81
- "implementation": "dist/chunk-TB6SV7QK.js",
81
+ "implementation": "dist/chunk-5PG7DW2T.js",
82
82
  "line": 3287
83
83
  },
84
84
  "optimizeObservationsForContext": {
85
85
  "types": "dist/processors/index.d.ts",
86
- "implementation": "dist/chunk-TB6SV7QK.js",
86
+ "implementation": "dist/chunk-5PG7DW2T.js",
87
87
  "line": 4599
88
88
  },
89
89
  "parseAnchorId": {
90
90
  "types": "dist/processors/index.d.ts",
91
- "implementation": "dist/chunk-TB6SV7QK.js",
91
+ "implementation": "dist/chunk-5PG7DW2T.js",
92
92
  "line": 3260
93
93
  },
94
94
  "parseObservationGroups": {
95
95
  "types": "dist/processors/index.d.ts",
96
- "implementation": "dist/chunk-TB6SV7QK.js",
96
+ "implementation": "dist/chunk-5PG7DW2T.js",
97
97
  "line": 1415
98
98
  },
99
99
  "parseObserverOutput": {
100
100
  "types": "dist/processors/index.d.ts",
101
- "implementation": "dist/chunk-TB6SV7QK.js",
101
+ "implementation": "dist/chunk-5PG7DW2T.js",
102
102
  "line": 4479
103
103
  },
104
104
  "reconcileObservationGroupsFromReflection": {
105
105
  "types": "dist/processors/index.d.ts",
106
- "implementation": "dist/chunk-TB6SV7QK.js",
106
+ "implementation": "dist/chunk-5PG7DW2T.js",
107
107
  "line": 1504
108
108
  },
109
109
  "renderObservationGroupsForReflection": {
110
110
  "types": "dist/processors/index.d.ts",
111
- "implementation": "dist/chunk-TB6SV7QK.js",
111
+ "implementation": "dist/chunk-5PG7DW2T.js",
112
112
  "line": 1460
113
113
  },
114
114
  "stripEphemeralAnchorIds": {
115
115
  "types": "dist/processors/index.d.ts",
116
- "implementation": "dist/chunk-TB6SV7QK.js",
116
+ "implementation": "dist/chunk-5PG7DW2T.js",
117
117
  "line": 3317
118
118
  },
119
119
  "stripObservationGroups": {
120
120
  "types": "dist/processors/index.d.ts",
121
- "implementation": "dist/chunk-TB6SV7QK.js",
121
+ "implementation": "dist/chunk-5PG7DW2T.js",
122
122
  "line": 1437
123
123
  },
124
124
  "wrapInObservationGroup": {
125
125
  "types": "dist/processors/index.d.ts",
126
- "implementation": "dist/chunk-TB6SV7QK.js",
126
+ "implementation": "dist/chunk-5PG7DW2T.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-TB6SV7QK.js",
147
+ "implementation": "dist/chunk-5PG7DW2T.js",
148
148
  "line": 22109
149
149
  },
150
150
  "MessageHistory": {
151
151
  "types": "dist/index.d.ts",
152
- "implementation": "dist/chunk-TB6SV7QK.js"
152
+ "implementation": "dist/chunk-5PG7DW2T.js"
153
153
  },
154
154
  "SemanticRecall": {
155
155
  "types": "dist/index.d.ts",
156
- "implementation": "dist/chunk-TB6SV7QK.js"
156
+ "implementation": "dist/chunk-5PG7DW2T.js"
157
157
  },
158
158
  "WorkingMemory": {
159
159
  "types": "dist/index.d.ts",
160
- "implementation": "dist/chunk-TB6SV7QK.js"
160
+ "implementation": "dist/chunk-5PG7DW2T.js"
161
161
  },
162
162
  "deepMergeWorkingMemory": {
163
163
  "types": "dist/index.d.ts",
164
- "implementation": "dist/chunk-TB6SV7QK.js",
164
+ "implementation": "dist/chunk-5PG7DW2T.js",
165
165
  "line": 21748
166
166
  },
167
167
  "extractWorkingMemoryContent": {
168
168
  "types": "dist/index.d.ts",
169
- "implementation": "dist/chunk-TB6SV7QK.js",
169
+ "implementation": "dist/chunk-5PG7DW2T.js",
170
170
  "line": 22064
171
171
  },
172
172
  "extractWorkingMemoryTags": {
173
173
  "types": "dist/index.d.ts",
174
- "implementation": "dist/chunk-TB6SV7QK.js",
174
+ "implementation": "dist/chunk-5PG7DW2T.js",
175
175
  "line": 22032
176
176
  },
177
177
  "removeWorkingMemoryTags": {
178
178
  "types": "dist/index.d.ts",
179
- "implementation": "dist/chunk-TB6SV7QK.js",
179
+ "implementation": "dist/chunk-5PG7DW2T.js",
180
180
  "line": 22045
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-TB6SV7QK.js",
200
+ "chunk-5PG7DW2T.js",
201
201
  "chunk-LSJJAJAF.js"
202
202
  ]
203
203
  }
@@ -48,7 +48,7 @@ for await (const chunk of stream.fullStream) {
48
48
  }
49
49
  ```
50
50
 
51
- > **Note:** Agent approval uses snapshots to capture request state. Configure a [storage provider](https://mastra.ai/docs/memory/storage) on your Mastra instance or you'll see a "snapshot not found" error.
51
+ > **Note:** Agent approval uses snapshots to capture request state. Configure a [storage provider](https://mastra.ai/docs/storage/overview) on your Mastra instance or you'll see a "snapshot not found" error.
52
52
  >
53
53
  > Snapshots for agent runs are minimal resume artifacts: they hold only what's needed to resume the suspended run and are deleted once the run finishes. Use [tracing](https://mastra.ai/docs/observability/overview) for the execution record and [memory](https://mastra.ai/docs/memory/overview) for the conversation history.
54
54
 
@@ -420,7 +420,7 @@ Each returned run includes the suspended tool calls (`toolCallId`, `toolName`, `
420
420
 
421
421
  The same discovery is available over HTTP as `GET /agents/:agentId/suspended-runs` and in the client SDK as [`agent.listSuspendedRuns()`](https://mastra.ai/reference/client-js/agents), so browser-based approval UIs can rediscover pending runs directly.
422
422
 
423
- > **Note:** Suspended runs only survive restarts when your Mastra instance is configured with a persistent [storage provider](https://mastra.ai/docs/memory/storage). The default in-memory store loses snapshots when the process exits.
423
+ > **Note:** Suspended runs only survive restarts when your Mastra instance is configured with a persistent [storage provider](https://mastra.ai/docs/storage/overview). The default in-memory store loses snapshots when the process exits.
424
424
 
425
425
  ## Tool approval: Supervisor agents
426
426
 
@@ -95,7 +95,7 @@ console.log(final?.summary)
95
95
 
96
96
  When a primitive requires approval, the stream emits an `agent-execution-approval` or `tool-execution-approval` chunk. Use `approveNetworkToolCall()` or `declineNetworkToolCall()` to respond.
97
97
 
98
- Network approval uses snapshots to capture execution state. Ensure a [storage provider](https://mastra.ai/docs/memory/storage) is enabled in your Mastra instance.
98
+ Network approval uses snapshots to capture execution state. Ensure a [storage provider](https://mastra.ai/docs/storage/overview) is enabled in your Mastra instance.
99
99
 
100
100
  ```typescript
101
101
  const stream = await routingAgent.network('Perform some sensitive action', {
@@ -16,7 +16,7 @@ Use background tasks when a tool call may take long enough that the user shouldn
16
16
 
17
17
  For tool calls that return quickly, foreground execution using `agent.stream()` and `agent.generate()` is simpler.
18
18
 
19
- > **Note:** Background tasks require a configured [storage](https://mastra.ai/docs/memory/storage) backend on the Mastra instance. Tasks are persisted so they survive process restarts.
19
+ > **Note:** Background tasks require a configured [storage](https://mastra.ai/docs/storage/overview) backend on the Mastra instance. Tasks are persisted so they survive process restarts.
20
20
 
21
21
  ## Quickstart
22
22
 
@@ -379,4 +379,4 @@ These read from storage rather than the pubsub stream, so they're suitable for p
379
379
  - [Durable agents](https://mastra.ai/docs/long-running-agents/durable-agents)
380
380
  - [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents)
381
381
  - [Stream chunk types](https://mastra.ai/reference/streaming/ChunkType)
382
- - [Storage](https://mastra.ai/docs/memory/storage)
382
+ - [Storage](https://mastra.ai/docs/storage/overview)
@@ -6,7 +6,7 @@
6
6
 
7
7
  > **Beta:** The Goals feature is in beta stage and subject to breaking changes in minor versions until it graduates from its beta status.
8
8
 
9
- A goal is a durable, thread-scoped objective: a standing instruction the agent keeps working toward across loop iterations until a judge model decides it is satisfied or a run budget is exhausted. The objective is persisted in thread state, so it survives reloads and is evaluated in-loop — even when a new message arrives in the middle of an already-running turn.
9
+ A goal is a durable, thread-scoped objective: a standing instruction the agent keeps working toward across loop iterations until a judge model decides it's satisfied or a run budget is exhausted. The objective is persisted in thread state, so it survives reloads and is evaluated in-loop — even when a new message arrives in the middle of an already-running turn.
10
10
 
11
11
  Goals build on the same machinery as [`isTaskComplete`](https://mastra.ai/docs/agents/supervisor-agents): an LLM-as-judge scores the agent's output each iteration and gates the loop. The difference is that a goal is **durable** (stored in thread state, not passed per call) and is set and updated through `Agent` methods rather than per-`stream()` options.
12
12
 
@@ -22,7 +22,7 @@ For a one-off completion check within a single `stream()` call, use [`isTaskComp
22
22
 
23
23
  ## Quickstart
24
24
 
25
- Goals require a configured [storage](https://mastra.ai/docs/memory/storage) backend and a memory-backed thread. Add a `goal` config to the agent — a judge model is required for the goal to do anything — then set an objective for a thread:
25
+ Goals require a configured [storage](https://mastra.ai/docs/storage/overview) backend and a memory-backed thread. Add a `goal` config to the agent — a judge model is required for the goal to do anything — then set an objective for a thread:
26
26
 
27
27
  ```typescript
28
28
  import { Agent } from '@mastra/core/agent'
@@ -89,7 +89,7 @@ Each evaluation emits a typed `goal` stream chunk (`GoalEvaluationPayload`: `obj
89
89
 
90
90
  ## Managing the objective
91
91
 
92
- Control the objective for a thread with `Agent` methods. All of them no-op when the run is not memory-backed (they require storage and a `threadId`):
92
+ Control the objective for a thread with `Agent` methods. All of them no-op when the run isn't memory-backed (they require storage and a `threadId`):
93
93
 
94
94
  ```typescript
95
95
  // Read the current objective record.
@@ -111,4 +111,4 @@ Per-objective values written by `setObjective` / `updateObjectiveOptions` take p
111
111
 
112
112
  - [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents) — `isTaskComplete` and the rubric scorer
113
113
  - [Signal providers](https://mastra.ai/docs/long-running-agents/signal-providers) — how the objective is projected into context
114
- - [Memory storage](https://mastra.ai/docs/memory/storage) — the storage backend goals require
114
+ - [Memory storage](https://mastra.ai/docs/storage/overview) — the storage backend goals require
@@ -309,6 +309,73 @@ const agent = new Agent({
309
309
 
310
310
  Both scenarios are safe - guardrails prevent inappropriate content from being persisted to memory
311
311
 
312
+ ## Handling large attachments
313
+
314
+ Some storage providers enforce record size limits that base64-encoded file attachments can exceed:
315
+
316
+ | Provider | Record size limit |
317
+ | ------------------------------------------------------------------ | ----------------- |
318
+ | [DynamoDB](https://mastra.ai/reference/storage/dynamodb) | 400 KB |
319
+ | [Convex](https://mastra.ai/reference/storage/convex) | 1 MiB |
320
+ | [Cloudflare D1](https://mastra.ai/reference/storage/cloudflare-d1) | 1 MiB |
321
+
322
+ PostgreSQL, MongoDB, and libSQL have higher limits and are usually unaffected.
323
+
324
+ Use an input processor to upload attachments to external storage, then replace them with URL references before messages are persisted.
325
+
326
+ ```typescript
327
+ import type { Processor } from '@mastra/core/processors'
328
+ import type { MastraDBMessage } from '@mastra/core/memory'
329
+
330
+ export class AttachmentUploader implements Processor {
331
+ id = 'attachment-uploader'
332
+
333
+ async processInput({ messages }: { messages: MastraDBMessage[] }) {
334
+ return Promise.all(messages.map(message => this.processMessage(message)))
335
+ }
336
+
337
+ async processMessage(message: MastraDBMessage) {
338
+ const attachments = message.content.experimental_attachments
339
+ if (!attachments?.length) return message
340
+
341
+ const uploaded = await Promise.all(
342
+ attachments.map(async attachment => {
343
+ if (!attachment.url?.startsWith('data:')) return attachment
344
+
345
+ const url = await this.upload(attachment.url, attachment.contentType)
346
+ return { ...attachment, url }
347
+ }),
348
+ )
349
+
350
+ return { ...message, content: { ...message.content, experimental_attachments: uploaded } }
351
+ }
352
+
353
+ async upload(dataUri: string, contentType?: string): Promise<string> {
354
+ const base64 = dataUri.split(',')[1]
355
+ const buffer = Buffer.from(base64, 'base64')
356
+
357
+ throw new Error('Implement upload() with your storage provider')
358
+ }
359
+ }
360
+ ```
361
+
362
+ Use the processor with your agent:
363
+
364
+ ```typescript
365
+ import { Agent } from '@mastra/core/agent'
366
+ import { Memory } from '@mastra/memory'
367
+ import { AttachmentUploader } from '../processors/attachment-uploader'
368
+
369
+ export const supportAgent = new Agent({
370
+ id: 'support-agent',
371
+ name: 'Support agent',
372
+ instructions: 'Answer customer support questions.',
373
+ model: 'openai/gpt-5.5',
374
+ memory: new Memory({ lastMessages: 10 }),
375
+ inputProcessors: [new AttachmentUploader()],
376
+ })
377
+ ```
378
+
312
379
  ## Related documentation
313
380
 
314
381
  - [Processors](https://mastra.ai/docs/agents/processors): General processor concepts and custom processor creation
@@ -6,7 +6,7 @@ Message history is the most basic and important form of memory. It gives the LLM
6
6
 
7
7
  You can also retrieve message history to display past conversations in your UI.
8
8
 
9
- > **Info:** Each message belongs to a thread (the conversation) and a resource (the user or entity it's associated with). See [Threads and resources](https://mastra.ai/docs/memory/storage) for more detail.
9
+ > **Info:** Each message belongs to a thread (the conversation) and a resource (the user or entity it's associated with). See [Threads and resources](#threads-and-resources) for more detail.
10
10
 
11
11
  > **Warning:** When you use memory with a client application, send **only the new message** from the client instead of the full conversation history.
12
12
  >
@@ -14,9 +14,18 @@ You can also retrieve message history to display past conversations in your UI.
14
14
  >
15
15
  > For an AI SDK example, see [Using Mastra Memory](https://mastra.ai/guides/build-your-ui/ai-sdk-ui).
16
16
 
17
+ ## Threads and resources
18
+
19
+ Mastra organizes conversations using two identifiers:
20
+
21
+ - **Thread**: A conversation session containing a sequence of messages.
22
+ - **Resource**: The entity that owns the thread, such as a user, organization, project, or another domain entity in your application.
23
+
24
+ Studio automatically generates a thread and resource ID for you. When calling `stream()` or `generate()` yourself, provide these identifiers explicitly.
25
+
17
26
  ## Getting started
18
27
 
19
- Install the Mastra memory module along with a [storage adapter](https://mastra.ai/docs/memory/storage) for your database. The examples below use `@mastra/libsql`, which stores data locally in a `mastra.db` file.
28
+ Install the Mastra memory module along with a [storage adapter](https://mastra.ai/docs/storage/overview) for your database. The examples below use `@mastra/libsql`, which stores data locally in a `mastra.db` file.
20
29
 
21
30
  **npm**:
22
31
 
@@ -113,6 +122,51 @@ You can use this history in two ways:
113
122
 
114
123
  > **Tip:** When memory is enabled, [Studio](https://mastra.ai/docs/studio/overview) uses message history to display past conversations in the chat sidebar.
115
124
 
125
+ ## Thread title generation
126
+
127
+ Mastra can automatically generate descriptive thread titles based on the user's first message when `generateTitle` is enabled. Use this option when you build a chat interface that renders conversation titles in a thread list or sidebar.
128
+
129
+ ```typescript
130
+ import { Agent } from '@mastra/core/agent'
131
+ import { Memory } from '@mastra/memory'
132
+
133
+ export const supportAgent = new Agent({
134
+ id: 'support-agent',
135
+ name: 'Support agent',
136
+ instructions: 'Answer customer support questions.',
137
+ model: 'openai/gpt-5.5',
138
+ memory: new Memory({
139
+ options: {
140
+ generateTitle: true,
141
+ },
142
+ }),
143
+ })
144
+ ```
145
+
146
+ Title generation runs asynchronously after the agent responds and doesn't affect response time.
147
+
148
+ To optimize cost or behavior, provide a smaller [`model`](https://mastra.ai/models) and custom `instructions`:
149
+
150
+ ```typescript
151
+ import { Agent } from '@mastra/core/agent'
152
+ import { Memory } from '@mastra/memory'
153
+
154
+ export const supportAgent = new Agent({
155
+ id: 'support-agent',
156
+ name: 'Support agent',
157
+ instructions: 'Answer customer support questions.',
158
+ model: 'openai/gpt-5.5',
159
+ memory: new Memory({
160
+ options: {
161
+ generateTitle: {
162
+ model: 'openai/gpt-5-mini',
163
+ instructions: 'Generate a one-word title.',
164
+ },
165
+ },
166
+ }),
167
+ })
168
+ ```
169
+
116
170
  ## Accessing memory
117
171
 
118
172
  To access memory functions for querying, cloning, or deleting threads and messages, call `getMemory()` on an agent:
@@ -217,7 +217,7 @@ new Extractor({
217
217
  })
218
218
  ```
219
219
 
220
- By default, OM shows the last extracted value to the extractor on later runs. Set `includePreviousExtraction: false` when the Observer should not see the previous value.
220
+ By default, OM shows the last extracted value to the extractor on later runs. Set `includePreviousExtraction: false` when the Observer shouldn't see the previous value.
221
221
 
222
222
  ```typescript
223
223
  new Extractor({
@@ -263,7 +263,7 @@ const memory = new Memory({
263
263
 
264
264
  This setting adds `WorkingMemoryExtractor`, defaults `workingMemory.agentManaged` to `false`, and defaults `workingMemory.useStateSignals` to `true`. Set `workingMemory.agentManaged: true` if the main agent should still receive working memory tool and instruction injection.
265
265
 
266
- Use `onExtracted` to normalize or react to custom extracted values before they are persisted:
266
+ Use `onExtracted` to normalize or react to custom extracted values before they're persisted:
267
267
 
268
268
  ```typescript
269
269
  new Extractor({
@@ -280,7 +280,7 @@ new Extractor({
280
280
  })
281
281
  ```
282
282
 
283
- Extractor failures are reported in OM markers and do not block other successful extractor values. See [the API reference](https://mastra.ai/reference/memory/observational-memory) for the full `Extractor` shape.
283
+ Extractor failures are reported in OM markers and don't block other successful extractor values. See [the API reference](https://mastra.ai/reference/memory/observational-memory) for the full `Extractor` shape.
284
284
 
285
285
  If your Observer model is text-only or its API rejects multimodal input, set `observation.observeAttachments` to `false` to drop attachments before they reach the Observer. The readable placeholders (`[Image #1: ...]`, `[File #1: ...]`) are kept in the transcript so the Observer can still reason about what was shared without receiving the binary payload. The same filter applies to tool results that contain image or file parts:
286
286
 
@@ -13,7 +13,7 @@ Mastra agents can be configured to store [message history](https://mastra.ai/doc
13
13
 
14
14
  If the combined memory exceeds the model's context limit, [memory processors](https://mastra.ai/docs/memory/memory-processors) can filter, trim, or prioritize content so the most relevant information is preserved.
15
15
 
16
- Memory results will be stored in one or more of your configured [storage providers](https://mastra.ai/docs/memory/storage).
16
+ Memory results will be stored in one or more of your configured [storage providers](https://mastra.ai/docs/storage/overview).
17
17
 
18
18
  ## When to use memory
19
19
 
@@ -75,7 +75,7 @@ Use memory when your agent needs to maintain multi-turn conversations that refer
75
75
  bun add @mastra/libsql@latest
76
76
  ```
77
77
 
78
- > **Note:** For more details on available providers and how storage works in Mastra, visit the [storage](https://mastra.ai/docs/memory/storage) documentation.
78
+ > **Note:** For more details on available providers and how storage works in Mastra, visit the [storage](https://mastra.ai/docs/storage/overview) documentation.
79
79
 
80
80
  3. Add the storage provider to your main Mastra instance to enable memory across all configured agents.
81
81
 
@@ -178,7 +178,7 @@ Each delegation creates a fresh `threadId` and a deterministic `resourceId` for
178
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.
179
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
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.
181
+ > **Note:** Title generation (`generateTitle`) is a top-level thread concern and **isn't** 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.
182
182
 
183
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.
184
184
 
@@ -22,6 +22,8 @@ After getting a response from the LLM, all new messages (user, assistant, and to
22
22
 
23
23
  Semantic recall is disabled by default. To enable it, set `semanticRecall: true` in `options` and provide a `vector` store and `embedder`:
24
24
 
25
+ **LibSQL**:
26
+
25
27
  ```typescript
26
28
  import { Agent } from '@mastra/core/agent'
27
29
  import { Memory } from '@mastra/memory'
@@ -50,6 +52,38 @@ const agent = new Agent({
50
52
  })
51
53
  ```
52
54
 
55
+ **MongoDB**:
56
+
57
+ ```typescript
58
+ import { Agent } from '@mastra/core/agent'
59
+ import { Memory } from '@mastra/memory'
60
+ import { MongoDBStore, MongoDBVector } from '@mastra/mongodb'
61
+ import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
62
+
63
+ const agent = new Agent({
64
+ id: 'support-agent',
65
+ name: 'SupportAgent',
66
+ instructions: 'You are a helpful support agent.',
67
+ model: 'openai/gpt-5.5',
68
+ memory: new Memory({
69
+ storage: new MongoDBStore({
70
+ id: 'agent-storage',
71
+ uri: process.env.MONGODB_URI,
72
+ dbName: process.env.MONGODB_DB_NAME,
73
+ }),
74
+ vector: new MongoDBVector({
75
+ id: 'agent-vector',
76
+ uri: process.env.MONGODB_URI,
77
+ dbName: process.env.MONGODB_DB_NAME,
78
+ }),
79
+ embedder: new ModelRouterEmbeddingModel('openai/text-embedding-3-small'),
80
+ options: {
81
+ semanticRecall: true,
82
+ },
83
+ }),
84
+ })
85
+ ```
86
+
53
87
  ## Using the `recall()` method
54
88
 
55
89
  While `listMessages` retrieves messages by thread ID with basic pagination, [`recall()`](https://mastra.ai/reference/memory/recall) adds support for **semantic search**. When you need to find messages by meaning rather than recency, use `recall()` with a `vectorSearchString`:
@@ -146,7 +180,7 @@ const agent = new Agent({
146
180
  })
147
181
  ```
148
182
 
149
- > **Note:** `scope: 'resource'` is supported by the LibSQL, PostgreSQL, and Upstash storage adapters.
183
+ > **Note:** `scope: 'resource'` is supported by the LibSQL, PostgreSQL, MongoDB, and Upstash storage adapters.
150
184
 
151
185
  ### Metadata filtering
152
186