@mastra/mongodb 1.12.1-alpha.0 → 1.13.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # @mastra/mongodb
2
2
 
3
+ ## 1.13.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added atomic caller-defined dataset IDs for idempotent dataset creation across built-in storage adapters. Supplying `id` to `mastra.datasets.create()` now creates the dataset once and resolves compatible retries to the persisted record; incompatible immutable identity fields throw `DATASET_ID_CONFLICT`. ([#19370](https://github.com/mastra-ai/mastra/pull/19370))
8
+
9
+ - Added caller-defined dataset item identities for safe retries across all dataset storage adapters. ([#19384](https://github.com/mastra-ai/mastra/pull/19384))
10
+
11
+ Dataset items can now include an `externalId` when calling `addItem` or `addItems`:
12
+
13
+ ```ts
14
+ await dataset.addItem({
15
+ externalId: 'source-item-123',
16
+ input: { prompt: 'Hello' },
17
+ });
18
+ ```
19
+
20
+ Retrying with the same identity and payload returns the existing item. Reusing an identity with different content returns a typed conflict, including during concurrent writes. Updates and deletes preserve the identity, Spanner retries transactions without changing the outcome, and MySQL batch writes now preserve every supported dataset item field.
21
+
22
+ ### Patch Changes
23
+
24
+ - Raised the `@mastra/core` peer dependency floor to `>=1.51.0-0` so the dataset item identity helpers used by the storage adapters are available at runtime. ([#19384](https://github.com/mastra-ai/mastra/pull/19384))
25
+
26
+ - Updated dependencies [[`a99eae8`](https://github.com/mastra-ai/mastra/commit/a99eae8908e500c1b2d12f9d277be616b98617a5), [`fd13f8e`](https://github.com/mastra-ai/mastra/commit/fd13f8e21990f9904c3eedba3a626bb4a929cdb8), [`f703f87`](https://github.com/mastra-ai/mastra/commit/f703f878de072d51fda557f9c50867d8252bef05), [`0ad646f`](https://github.com/mastra-ai/mastra/commit/0ad646f71a530f2454664299e5e01bfd13fa12e5)]:
27
+ - @mastra/core@1.51.0-alpha.13
28
+
29
+ ## 1.12.1
30
+
31
+ ### Patch Changes
32
+
33
+ - Update `@mastra/core` peer dependency for the unified schedules API ([#18874](https://github.com/mastra-ai/mastra/pull/18874))
34
+
35
+ - Schedule rows persisted with the legacy `target.type: 'heartbeat'` are now normalized to `target.type: 'agent'` when read, so existing agent schedules keep firing after the heartbeats-to-schedules rename in `@mastra/core`. ([#18874](https://github.com/mastra-ai/mastra/pull/18874))
36
+
37
+ - Updated dependencies [[`b291760`](https://github.com/mastra-ai/mastra/commit/b291760df9d6c7e4fc72606c8f0a4af2cf6e946c), [`3ffb8b7`](https://github.com/mastra-ai/mastra/commit/3ffb8b720e90f5e6977129ec1f6707d43c2bebe0), [`6ef59fe`](https://github.com/mastra-ai/mastra/commit/6ef59fef1da52ed8da5fbb2a892c71cf4fb6c739), [`4039488`](https://github.com/mastra-ai/mastra/commit/403948898af7293198d9e8b3e7fb47f623c78b94), [`29b7ea6`](https://github.com/mastra-ai/mastra/commit/29b7ea64e72b5523d5bdcbd34ee03d2b854d54e1), [`b2c9d70`](https://github.com/mastra-ai/mastra/commit/b2c9d70757207fb01a9069549e69b6f0d73a6636), [`a51c63d`](https://github.com/mastra-ai/mastra/commit/a51c63d8ee639e4daeba2a0be093efa6a1b5e52f), [`252f63d`](https://github.com/mastra-ai/mastra/commit/252f63d8fec723955adb2202be2f01a75ad0e69c), [`5ea76a7`](https://github.com/mastra-ai/mastra/commit/5ea76a723d966c72da9aa3ab30ae20276e049765), [`6445560`](https://github.com/mastra-ai/mastra/commit/6445560327045d20b239585fc63fed72e9ce36ec), [`e2b9f33`](https://github.com/mastra-ai/mastra/commit/e2b9f33456fd638eca555f9466c6519d8d049666), [`10959d5`](https://github.com/mastra-ai/mastra/commit/10959d509d824f682d40ff96e05ee044aec3b0e5), [`c547a77`](https://github.com/mastra-ai/mastra/commit/c547a7729bdf64dfc2df29c965046c0712a18f10), [`a0085fa`](https://github.com/mastra-ai/mastra/commit/a0085fa0934e52c37c8c8b3d75a6bb5cd199af36), [`a2ba369`](https://github.com/mastra-ai/mastra/commit/a2ba369e796dfab610f41c6875965b488272fa55), [`ffc3c17`](https://github.com/mastra-ai/mastra/commit/ffc3c17274ea17c11aa6f73d3140649cd7fc8abc), [`81542c1`](https://github.com/mastra-ai/mastra/commit/81542c1835c35bc32f2ce4fa9136ee11993cd299), [`3908e53`](https://github.com/mastra-ai/mastra/commit/3908e53ce04bbea04f5e0c097d7aa298c35fabee), [`cb24ce7`](https://github.com/mastra-ai/mastra/commit/cb24ce76bd16ca88eb6a963f6277f8780e703029), [`02705fd`](https://github.com/mastra-ai/mastra/commit/02705fd2f5a9062210d64ea061adeeb10dc9452e), [`ae51e81`](https://github.com/mastra-ai/mastra/commit/ae51e818825582d42500338dfc1929a082eff0ba), [`6f304ef`](https://github.com/mastra-ai/mastra/commit/6f304ef319e99725e884bdb8d3193c001b6e5964), [`5f9858f`](https://github.com/mastra-ai/mastra/commit/5f9858f791f1137ca7d52d23559fb4568f7a9026)]:
38
+ - @mastra/core@1.50.0
39
+
3
40
  ## 1.12.1-alpha.0
4
41
 
5
42
  ### Patch Changes
@@ -3,7 +3,7 @@ name: mastra-mongodb
3
3
  description: Documentation for @mastra/mongodb. Use when working with @mastra/mongodb APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/mongodb"
6
- version: "1.12.1-alpha.0"
6
+ version: "1.13.0-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -16,12 +16,15 @@ Read the individual reference documents for detailed explanations and code examp
16
16
 
17
17
  ### Docs
18
18
 
19
+ - [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.
19
20
  - [Working memory](references/docs-memory-working-memory.md) - Learn how to configure working memory in Mastra to store persistent user data, preferences.
20
21
  - [Retrieval, semantic search, reranking](references/docs-rag-retrieval.md) - Guide on retrieval processes in Mastra's RAG systems, including semantic search, filtering, and re-ranking.
21
22
  - [Storing embeddings in a vector database](references/docs-rag-vector-databases.md) - Guide on vector storage options in Mastra, including embedded and dedicated vector databases for similarity search.
23
+ - [Storage overview](references/docs-storage-overview.md) - Configure storage for Mastra to persist runtime state across agents, workflows, observability, evals, schedules, and memory.
22
24
 
23
25
  ### Reference
24
26
 
27
+ - [Reference: Composite storage](references/reference-storage-composite.md) - Documentation for combining multiple storage backends in Mastra.
25
28
  - [Reference: MongoDB storage](references/reference-storage-mongodb.md) - Documentation for the MongoDB storage implementation in Mastra.
26
29
  - [Reference: MongoDB vector store](references/reference-vectors-mongodb.md) - Documentation for the MongoDBVector class in Mastra, which provides vector search using MongoDB Atlas and Atlas Vector Search.
27
30
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.12.1-alpha.0",
2
+ "version": "1.13.0-alpha.0",
3
3
  "package": "@mastra/mongodb",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -0,0 +1,401 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Semantic recall
4
+
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.
6
+
7
+ > **📹 Watch:** Watch [Mastra semantic recall](https://www.youtube.com/watch?v=UVZtK8cK8xQ\&pp=ygUVbWFzdHJhIHdvcmtpbmcgbWVtb3J5) to see how agents retrieve relevant messages from past conversations.
8
+
9
+ ## How semantic recall works
10
+
11
+ Semantic recall is RAG-based search that helps agents maintain context across longer interactions when messages are no longer within [recent message history](https://mastra.ai/docs/memory/message-history).
12
+
13
+ It uses vector embeddings of messages for similarity search, integrates with various vector stores, and has configurable context windows around retrieved messages.
14
+
15
+ ![Diagram showing Mastra Memory semantic recall](/assets/images/semantic-recall-fd7b9336a6d0d18019216cb6d3dbe710.png)
16
+
17
+ When it's enabled, new messages are used to query a vector DB for semantically similar messages.
18
+
19
+ After getting a response from the LLM, all new messages (user, assistant, and tool calls/results) are inserted into the vector DB to be recalled in later interactions.
20
+
21
+ ## Quickstart
22
+
23
+ Semantic recall is disabled by default. To enable it, set `semanticRecall: true` in `options` and provide a `vector` store and `embedder`:
24
+
25
+ **LibSQL**:
26
+
27
+ ```typescript
28
+ import { Agent } from '@mastra/core/agent'
29
+ import { Memory } from '@mastra/memory'
30
+ import { LibSQLStore, LibSQLVector } from '@mastra/libsql'
31
+ import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
32
+
33
+ const agent = new Agent({
34
+ id: 'support-agent',
35
+ name: 'SupportAgent',
36
+ instructions: 'You are a helpful support agent.',
37
+ model: 'openai/gpt-5.5',
38
+ memory: new Memory({
39
+ storage: new LibSQLStore({
40
+ id: 'agent-storage',
41
+ url: 'file:./local.db',
42
+ }),
43
+ vector: new LibSQLVector({
44
+ id: 'agent-vector',
45
+ url: 'file:./local.db',
46
+ }),
47
+ embedder: new ModelRouterEmbeddingModel('openai/text-embedding-3-small'),
48
+ options: {
49
+ semanticRecall: true,
50
+ },
51
+ }),
52
+ })
53
+ ```
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
+
87
+ ## Using the `recall()` method
88
+
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`:
90
+
91
+ ```typescript
92
+ const memory = await agent.getMemory()
93
+
94
+ // Basic recall - similar to listMessages
95
+ const { messages } = await memory!.recall({
96
+ threadId: 'thread-123',
97
+ perPage: 50,
98
+ })
99
+
100
+ // Semantic recall - find messages by meaning
101
+ const { messages: relevantMessages } = await memory!.recall({
102
+ threadId: 'thread-123',
103
+ vectorSearchString: 'What did we discuss about the project deadline?',
104
+ threadConfig: {
105
+ semanticRecall: true,
106
+ },
107
+ })
108
+ ```
109
+
110
+ ## Storage configuration
111
+
112
+ Semantic recall relies on a [storage and vector db](https://mastra.ai/reference/memory/memory-class) to store messages and their embeddings.
113
+
114
+ ```ts
115
+ import { Memory } from '@mastra/memory'
116
+ import { Agent } from '@mastra/core/agent'
117
+ import { LibSQLStore, LibSQLVector } from '@mastra/libsql'
118
+
119
+ const agent = new Agent({
120
+ memory: new Memory({
121
+ // this is the default storage db if omitted
122
+ storage: new LibSQLStore({
123
+ id: 'agent-storage',
124
+ url: 'file:./local.db',
125
+ }),
126
+ // this is the default vector db if omitted
127
+ vector: new LibSQLVector({
128
+ id: 'agent-vector',
129
+ url: 'file:./local.db',
130
+ }),
131
+ options: {
132
+ semanticRecall: true,
133
+ },
134
+ }),
135
+ })
136
+ ```
137
+
138
+ Each vector store page below includes installation instructions, configuration parameters, and usage examples:
139
+
140
+ - [Astra](https://mastra.ai/reference/vectors/astra)
141
+ - [Chroma](https://mastra.ai/reference/vectors/chroma)
142
+ - [Cloudflare Vectorize](https://mastra.ai/reference/vectors/vectorize)
143
+ - [Convex](https://mastra.ai/reference/vectors/convex)
144
+ - [Couchbase](https://mastra.ai/reference/vectors/couchbase)
145
+ - [DuckDB](https://mastra.ai/reference/vectors/duckdb)
146
+ - [Elasticsearch](https://mastra.ai/reference/vectors/elasticsearch)
147
+ - [LanceDB](https://mastra.ai/reference/vectors/lance)
148
+ - [libSQL](https://mastra.ai/reference/vectors/libsql)
149
+ - [MongoDB](https://mastra.ai/reference/vectors/mongodb)
150
+ - [OpenSearch](https://mastra.ai/reference/vectors/opensearch)
151
+ - [Pinecone](https://mastra.ai/reference/vectors/pinecone)
152
+ - [PostgreSQL](https://mastra.ai/reference/vectors/pg)
153
+ - [Qdrant](https://mastra.ai/reference/vectors/qdrant)
154
+ - [S3 Vectors](https://mastra.ai/reference/vectors/s3vectors)
155
+ - [Turbopuffer](https://mastra.ai/reference/vectors/turbopuffer)
156
+ - [Upstash](https://mastra.ai/reference/vectors/upstash)
157
+
158
+ ## Recall configuration
159
+
160
+ The following options control semantic recall behavior:
161
+
162
+ 1. **topK**: The number of similar messages to retrieve
163
+ 2. **messageRange**: The surrounding messages to include with each match
164
+ 3. **scope**: Whether to search the current thread or all threads for a resource
165
+ 4. **filter**: Metadata criteria that restrict search results
166
+
167
+ ```typescript
168
+ const agent = new Agent({
169
+ id: 'agent',
170
+ memory: new Memory({
171
+ options: {
172
+ semanticRecall: {
173
+ topK: 3, // Retrieve 3 similar messages
174
+ messageRange: 2, // Include 2 messages before and after each match
175
+ scope: 'resource', // Search all threads for this resource
176
+ filter: { projectId: { $eq: 'project-a' } },
177
+ },
178
+ },
179
+ }),
180
+ })
181
+ ```
182
+
183
+ > **Note:** `scope: 'resource'` is supported by the LibSQL, PostgreSQL, MongoDB, and Upstash storage adapters.
184
+
185
+ ### Metadata filtering
186
+
187
+ The `filter` option restricts semantic recall results to messages with matching thread metadata.
188
+
189
+ ```typescript
190
+ const agent = new Agent({
191
+ id: 'agent',
192
+ memory: new Memory({
193
+ options: {
194
+ semanticRecall: {
195
+ scope: 'resource',
196
+ filter: {
197
+ projectId: { $eq: 'project-a' },
198
+ category: { $in: ['work', 'personal'] },
199
+ },
200
+ },
201
+ },
202
+ }),
203
+ })
204
+ ```
205
+
206
+ Filters match metadata stored on message embeddings when messages are saved. If thread metadata changes later, existing embeddings keep their previous metadata until those messages are saved or indexed again.
207
+
208
+ Supported filter operators:
209
+
210
+ - `$and`: Logical AND
211
+ - `$eq`: Equal to
212
+ - `$gt`: Greater than
213
+ - `$gte`: Greater than or equal
214
+ - `$in`: In array
215
+ - `$lt`: Less than
216
+ - `$lte`: Less than or equal
217
+ - `$ne`: Not equal to
218
+ - `$nin`: Not in array
219
+ - `$or`: Logical OR
220
+
221
+ The following example demonstrates metadata filters for common use cases:
222
+
223
+ ```typescript
224
+ // Filter by project
225
+ const options = {
226
+ semanticRecall: { filter: { projectId: { $eq: 'my-project' } } },
227
+ }
228
+
229
+ // Filter by multiple categories
230
+ const options = {
231
+ semanticRecall: { filter: { category: { $in: ['work', 'research'] } } },
232
+ }
233
+
234
+ // Filter by project and priority
235
+ const options = {
236
+ semanticRecall: {
237
+ filter: {
238
+ $and: [{ projectId: { $eq: 'project-a' } }, { priority: { $gte: 3 } }],
239
+ },
240
+ },
241
+ }
242
+ ```
243
+
244
+ ## Embedder configuration
245
+
246
+ 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.
247
+
248
+ ### Using the Model Router (Recommended)
249
+
250
+ The simplest way is to use a `provider/model` string with autocomplete support:
251
+
252
+ ```ts
253
+ import { Memory } from '@mastra/memory'
254
+ import { Agent } from '@mastra/core/agent'
255
+ import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
256
+
257
+ const agent = new Agent({
258
+ id: 'agent',
259
+ memory: new Memory({
260
+ embedder: new ModelRouterEmbeddingModel('openai/text-embedding-3-small'),
261
+ options: {
262
+ semanticRecall: true,
263
+ },
264
+ }),
265
+ })
266
+ ```
267
+
268
+ Supported embedding models:
269
+
270
+ - **OpenAI**: `text-embedding-3-small`, `text-embedding-3-large`, `text-embedding-ada-002`
271
+ - **Google**: `gemini-embedding-001`
272
+ - **OpenRouter**: Access embedding models from various providers
273
+
274
+ ```ts
275
+ import { Agent } from '@mastra/core/agent'
276
+ import { Memory } from '@mastra/memory'
277
+ import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
278
+
279
+ const agent = new Agent({
280
+ id: 'agent',
281
+ memory: new Memory({
282
+ embedder: new ModelRouterEmbeddingModel({
283
+ providerId: 'openrouter',
284
+ modelId: 'openai/text-embedding-3-small',
285
+ }),
286
+ }),
287
+ })
288
+ ```
289
+
290
+ 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`.
291
+
292
+ ### Using AI SDK Packages
293
+
294
+ You can also use AI SDK embedding models directly:
295
+
296
+ ```ts
297
+ import { Memory } from '@mastra/memory'
298
+ import { Agent } from '@mastra/core/agent'
299
+ import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
300
+
301
+ const agent = new Agent({
302
+ id: 'agent',
303
+ memory: new Memory({
304
+ embedder: new ModelRouterEmbeddingModel('openai/text-embedding-3-small'),
305
+ }),
306
+ })
307
+ ```
308
+
309
+ ### Using FastEmbed (local)
310
+
311
+ To use FastEmbed (a local embedding model), install `@mastra/fastembed`:
312
+
313
+ **npm**:
314
+
315
+ ```bash
316
+ npm install @mastra/fastembed@latest
317
+ ```
318
+
319
+ **pnpm**:
320
+
321
+ ```bash
322
+ pnpm add @mastra/fastembed@latest
323
+ ```
324
+
325
+ **Yarn**:
326
+
327
+ ```bash
328
+ yarn add @mastra/fastembed@latest
329
+ ```
330
+
331
+ **Bun**:
332
+
333
+ ```bash
334
+ bun add @mastra/fastembed@latest
335
+ ```
336
+
337
+ Then configure it in your memory:
338
+
339
+ ```ts
340
+ import { Memory } from '@mastra/memory'
341
+ import { Agent } from '@mastra/core/agent'
342
+ import { fastembed } from '@mastra/fastembed'
343
+
344
+ const agent = new Agent({
345
+ id: 'agent',
346
+ memory: new Memory({
347
+ embedder: fastembed,
348
+ }),
349
+ })
350
+ ```
351
+
352
+ ## PostgreSQL index optimization
353
+
354
+ When using PostgreSQL as your vector store, you can optimize semantic recall performance by configuring the vector index. This is particularly important for large-scale deployments with thousands of messages.
355
+
356
+ PostgreSQL supports both IVFFlat and HNSW indexes. By default, Mastra creates an IVFFlat index, but HNSW indexes typically provide better performance, especially with OpenAI embeddings which use inner product distance.
357
+
358
+ ```typescript
359
+ import { Memory } from '@mastra/memory'
360
+ import { PgStore, PgVector } from '@mastra/pg'
361
+
362
+ const agent = new Agent({
363
+ memory: new Memory({
364
+ storage: new PgStore({
365
+ id: 'agent-storage',
366
+ connectionString: process.env.DATABASE_URL,
367
+ }),
368
+ vector: new PgVector({
369
+ id: 'agent-vector',
370
+ connectionString: process.env.DATABASE_URL,
371
+ }),
372
+ options: {
373
+ semanticRecall: {
374
+ topK: 5,
375
+ messageRange: 2,
376
+ indexConfig: {
377
+ type: 'hnsw', // Use HNSW for better performance
378
+ metric: 'dotproduct', // Best for OpenAI embeddings
379
+ m: 16, // Number of bi-directional links (default: 16)
380
+ efConstruction: 64, // Size of candidate list during construction (default: 64)
381
+ },
382
+ },
383
+ },
384
+ }),
385
+ })
386
+ ```
387
+
388
+ For detailed information about index configuration options and performance tuning, see the [PgVector configuration guide](https://mastra.ai/reference/vectors/pg).
389
+
390
+ ## Disable semantic recall
391
+
392
+ Semantic recall is disabled by default (`semanticRecall: false`). Each call adds latency because new messages are converted into embeddings and used to query a vector database before the LLM receives them.
393
+
394
+ Keep semantic recall disabled when:
395
+
396
+ - Message history provides sufficient context for the current conversation.
397
+ - You're building performance-sensitive applications, like realtime two-way audio, where embedding and vector query latency is noticeable.
398
+
399
+ ## Viewing recalled messages
400
+
401
+ When tracing is enabled, any messages retrieved via semantic recall will appear in the agent's trace output, alongside recent message history (if configured).
@@ -10,6 +10,8 @@ This is useful for maintaining ongoing state that's always relevant and should a
10
10
 
11
11
  If you use [Observational Memory](https://mastra.ai/docs/memory/observational-memory), `observationalMemory.observation.manageWorkingMemory` lets OM update working memory for the agent.
12
12
 
13
+ > **📹 Watch:** Watch [Mastra working memory](https://www.youtube.com/watch?v=UMy_JHLf1n8\&pp=ygUVbWFzdHJhIHdvcmtpbmcgbWVtb3J5) to see how agents keep persistent user context available across interactions.
14
+
13
15
  Working memory can persist at two different scopes:
14
16
 
15
17
  - **Resource-scoped** (default): Memory persists across all conversation threads for the same user
@@ -43,9 +45,7 @@ const agent = new Agent({
43
45
 
44
46
  ## How it works
45
47
 
46
- Working memory is a block of Markdown text that the agent is able to update over time to store continuously relevant information:
47
-
48
- [YouTube video player](https://www.youtube-nocookie.com/embed/UMy_JHLf1n8)
48
+ Working memory is a block of Markdown text that the agent is able to update over time to store continuously relevant information.
49
49
 
50
50
  ## Memory persistence scopes
51
51
 
@@ -14,7 +14,7 @@ import { MongoDBVector } from '@mastra/mongodb'
14
14
  const store = new MongoDBVector({
15
15
  id: 'mongodb-vector',
16
16
  uri: process.env.MONGODB_URI,
17
- dbName: process.env.MONGODB_DATABASE,
17
+ dbName: process.env.MONGODB_DB_NAME,
18
18
  })
19
19
  await store.createIndex({
20
20
  indexName: 'myCollection',
@@ -27,10 +27,14 @@ await store.upsert({
27
27
  })
28
28
  ```
29
29
 
30
- ### Using MongoDB Atlas Vector search
30
+ ### Using MongoDB Atlas Vector Search
31
31
 
32
32
  For detailed setup instructions and best practices, see the [official MongoDB Atlas Vector Search documentation](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/?utm_campaign=devrel\&utm_source=third-party-content\&utm_medium=cta\&utm_content=mastra-docs).
33
33
 
34
+ ### Using VoyageAI with MongoDB
35
+
36
+ MongoDB works seamlessly with VoyageAI's embedding models, which are optimized for retrieval tasks. For complete examples and specialized models, see the [VoyageAI embeddings documentation](https://mastra.ai/models/embeddings) and [MongoDB vector reference](https://mastra.ai/reference/vectors/mongodb).
37
+
34
38
  **PgVector**:
35
39
 
36
40
  ```ts
@@ -359,6 +363,7 @@ The dimension size must match the output dimension of your chosen embedding mode
359
363
 
360
364
  - `OpenAI text-embedding-3-small`: 1536 dimensions (or custom, e.g., 256)
361
365
  - `Cohere embed-multilingual-v3`: 1024 dimensions
366
+ - `VoyageAI voyage-3.5`: 1024 dimensions (or custom: 256, 512, 1024, 2048)
362
367
  - `Google gemini-embedding-001`: 768 dimensions (or custom)
363
368
 
364
369
  > **Warning:** Index dimensions can't be changed after creation. To use a different model, delete and recreate the index with the new dimension size.