@mastra/mongodb 1.5.5 → 1.5.6

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,23 @@
1
1
  # @mastra/mongodb
2
2
 
3
+ ## 1.5.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Added dated message boundary delimiters when activating buffered observations for improved cache stability. ([#14367](https://github.com/mastra-ai/mastra/pull/14367))
8
+
9
+ - Updated dependencies [[`51970b3`](https://github.com/mastra-ai/mastra/commit/51970b3828494d59a8dd4df143b194d37d31e3f5), [`4444280`](https://github.com/mastra-ai/mastra/commit/444428094253e916ec077e66284e685fde67021e), [`085e371`](https://github.com/mastra-ai/mastra/commit/085e3718a7d0fe9a210fe7dd1c867b9bdfe8d16b), [`b77aa19`](https://github.com/mastra-ai/mastra/commit/b77aa1981361c021f2c881bee8f0c703687f00da), [`dbb879a`](https://github.com/mastra-ai/mastra/commit/dbb879af0b809c668e9b3a9d8bac97d806caa267), [`8b4ce84`](https://github.com/mastra-ai/mastra/commit/8b4ce84aed0808b9805cc4fd7147c1f8a2ef7a36), [`8d4cfe6`](https://github.com/mastra-ai/mastra/commit/8d4cfe6b9a7157d3876206227ec9f04cde6dbc4a), [`dd6ca1c`](https://github.com/mastra-ai/mastra/commit/dd6ca1cdea3b8b6182f4cf61df41070ba0cc0deb), [`ce26fe2`](https://github.com/mastra-ai/mastra/commit/ce26fe2166dd90254f8bee5776e55977143e97de), [`68a019d`](https://github.com/mastra-ai/mastra/commit/68a019d30d22251ddd628a2947d60215c03c350a), [`4cb4edf`](https://github.com/mastra-ai/mastra/commit/4cb4edf3c909d197ec356c1790d13270514ffef6), [`8de3555`](https://github.com/mastra-ai/mastra/commit/8de355572c6fd838f863a3e7e6fe24d0947b774f), [`b26307f`](https://github.com/mastra-ai/mastra/commit/b26307f050df39629511b0e831b8fc26973ce8b1), [`68a019d`](https://github.com/mastra-ai/mastra/commit/68a019d30d22251ddd628a2947d60215c03c350a)]:
10
+ - @mastra/core@1.14.0
11
+
12
+ ## 1.5.6-alpha.0
13
+
14
+ ### Patch Changes
15
+
16
+ - Added dated message boundary delimiters when activating buffered observations for improved cache stability. ([#14367](https://github.com/mastra-ai/mastra/pull/14367))
17
+
18
+ - Updated dependencies [[`4444280`](https://github.com/mastra-ai/mastra/commit/444428094253e916ec077e66284e685fde67021e), [`dbb879a`](https://github.com/mastra-ai/mastra/commit/dbb879af0b809c668e9b3a9d8bac97d806caa267), [`8de3555`](https://github.com/mastra-ai/mastra/commit/8de355572c6fd838f863a3e7e6fe24d0947b774f)]:
19
+ - @mastra/core@1.14.0-alpha.2
20
+
3
21
  ## 1.5.5
4
22
 
5
23
  ### 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.5.5"
6
+ version: "1.5.6"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.5",
2
+ "version": "1.5.6",
3
3
  "package": "@mastra/mongodb",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -26,7 +26,7 @@ const agent = new Agent({
26
26
  id: 'personal-assistant',
27
27
  name: 'PersonalAssistant',
28
28
  instructions: 'You are a helpful personal assistant.',
29
- model: 'openai/gpt-5.1',
29
+ model: 'openai/gpt-5.4',
30
30
  memory: new Memory({
31
31
  options: {
32
32
  workingMemory: {
@@ -268,7 +268,7 @@ Schema-based working memory uses **merge semantics**, meaning the agent only nee
268
268
  ## Choosing between template and schema
269
269
 
270
270
  - Use a **template** (Markdown) if you want the agent to maintain memory as a free-form text block, such as a user profile or scratchpad. Templates use **replace semantics** — the agent must provide the complete memory content on each update.
271
- - Use a **schema** if you need structured, type-safe data that can be validated and programmatically accessed as JSON. Schemas use **merge semantics** — the agent only provides fields to update, and existing fields are preserved.
271
+ - Use a **schema** if you need structured, type-safe data that can be validated and programmatically accessed as JSON. The `workingMemory.schema` field accepts any `PublicSchema`-compatible schema (including Zod v3, Zod v4, JSON Schema, or already-standard schemas). Schemas use **merge semantics** — the agent only provides fields to update, and existing fields are preserved.
272
272
  - Only one mode can be active at a time: setting both `template` and `schema` isn't supported.
273
273
 
274
274
  ## Example: Multi-step retention
@@ -272,7 +272,7 @@ import { PGVECTOR_PROMPT } from '@mastra/pg'
272
272
  export const ragAgent = new Agent({
273
273
  id: 'rag-agent',
274
274
  name: 'RAG Agent',
275
- model: 'openai/gpt-5.1',
275
+ model: 'openai/gpt-5.4',
276
276
  instructions: `
277
277
  Process queries using the provided context. Structure responses to be concise and relevant.
278
278
  ${PGVECTOR_PROMPT}
@@ -289,7 +289,7 @@ import { PINECONE_PROMPT } from '@mastra/pinecone'
289
289
  export const ragAgent = new Agent({
290
290
  id: 'rag-agent',
291
291
  name: 'RAG Agent',
292
- model: 'openai/gpt-5.1',
292
+ model: 'openai/gpt-5.4',
293
293
  instructions: `
294
294
  Process queries using the provided context. Structure responses to be concise and relevant.
295
295
  ${PINECONE_PROMPT}
@@ -306,7 +306,7 @@ import { QDRANT_PROMPT } from '@mastra/qdrant'
306
306
  export const ragAgent = new Agent({
307
307
  id: 'rag-agent',
308
308
  name: 'RAG Agent',
309
- model: 'openai/gpt-5.1',
309
+ model: 'openai/gpt-5.4',
310
310
  instructions: `
311
311
  Process queries using the provided context. Structure responses to be concise and relevant.
312
312
  ${QDRANT_PROMPT}
@@ -323,7 +323,7 @@ import { CHROMA_PROMPT } from '@mastra/chroma'
323
323
  export const ragAgent = new Agent({
324
324
  id: 'rag-agent',
325
325
  name: 'RAG Agent',
326
- model: 'openai/gpt-5.1',
326
+ model: 'openai/gpt-5.4',
327
327
  instructions: `
328
328
  Process queries using the provided context. Structure responses to be concise and relevant.
329
329
  ${CHROMA_PROMPT}
@@ -340,7 +340,7 @@ import { ASTRA_PROMPT } from '@mastra/astra'
340
340
  export const ragAgent = new Agent({
341
341
  id: 'rag-agent',
342
342
  name: 'RAG Agent',
343
- model: 'openai/gpt-5.1',
343
+ model: 'openai/gpt-5.4',
344
344
  instructions: `
345
345
  Process queries using the provided context. Structure responses to be concise and relevant.
346
346
  ${ASTRA_PROMPT}
@@ -357,7 +357,7 @@ import { LIBSQL_PROMPT } from '@mastra/libsql'
357
357
  export const ragAgent = new Agent({
358
358
  id: 'rag-agent',
359
359
  name: 'RAG Agent',
360
- model: 'openai/gpt-5.1',
360
+ model: 'openai/gpt-5.4',
361
361
  instructions: `
362
362
  Process queries using the provided context. Structure responses to be concise and relevant.
363
363
  ${LIBSQL_PROMPT}
@@ -374,7 +374,7 @@ import { UPSTASH_PROMPT } from '@mastra/upstash'
374
374
  export const ragAgent = new Agent({
375
375
  id: 'rag-agent',
376
376
  name: 'RAG Agent',
377
- model: 'openai/gpt-5.1',
377
+ model: 'openai/gpt-5.4',
378
378
  instructions: `
379
379
  Process queries using the provided context. Structure responses to be concise and relevant.
380
380
  ${UPSTASH_PROMPT}
@@ -391,7 +391,7 @@ import { VECTORIZE_PROMPT } from '@mastra/vectorize'
391
391
  export const ragAgent = new Agent({
392
392
  id: 'rag-agent',
393
393
  name: 'RAG Agent',
394
- model: 'openai/gpt-5.1',
394
+ model: 'openai/gpt-5.4',
395
395
  instructions: `
396
396
  Process queries using the provided context. Structure responses to be concise and relevant.
397
397
  ${VECTORIZE_PROMPT}
@@ -408,7 +408,7 @@ import { MONGODB_PROMPT } from '@mastra/mongodb'
408
408
  export const ragAgent = new Agent({
409
409
  id: 'rag-agent',
410
410
  name: 'RAG Agent',
411
- model: 'openai/gpt-5.1',
411
+ model: 'openai/gpt-5.4',
412
412
  instructions: `
413
413
  Process queries using the provided context. Structure responses to be concise and relevant.
414
414
  ${MONGODB_PROMPT}
@@ -425,7 +425,7 @@ import { OPENSEARCH_PROMPT } from '@mastra/opensearch'
425
425
  export const ragAgent = new Agent({
426
426
  id: 'rag-agent',
427
427
  name: 'RAG Agent',
428
- model: 'openai/gpt-5.1',
428
+ model: 'openai/gpt-5.4',
429
429
  instructions: `
430
430
  Process queries using the provided context. Structure responses to be concise and relevant.
431
431
  ${OPENSEARCH_PROMPT}
@@ -442,7 +442,7 @@ import { S3VECTORS_PROMPT } from '@mastra/s3vectors'
442
442
  export const ragAgent = new Agent({
443
443
  id: 'rag-agent',
444
444
  name: 'RAG Agent',
445
- model: 'openai/gpt-5.1',
445
+ model: 'openai/gpt-5.4',
446
446
  instructions: `
447
447
  Process queries using the provided context. Structure responses to be concise and relevant.
448
448
  ${S3VECTORS_PROMPT}
@@ -472,7 +472,7 @@ const initialResults = await pgVector.query({
472
472
  })
473
473
 
474
474
  // Create a relevance scorer
475
- const relevanceProvider = new MastraAgentRelevanceScorer('relevance-scorer', 'openai/gpt-5.1')
475
+ const relevanceProvider = new MastraAgentRelevanceScorer('relevance-scorer', 'openai/gpt-5.4')
476
476
 
477
477
  // Re-rank the results
478
478
  const rerankedResults = await rerank({
@@ -206,7 +206,7 @@ export const mongodbAgent = new Agent({
206
206
  name: 'mongodb-agent',
207
207
  instructions:
208
208
  'You are an AI agent with the ability to automatically recall memories from previous interactions.',
209
- model: 'openai/gpt-5.1',
209
+ model: 'openai/gpt-5.4',
210
210
  memory: new Memory({
211
211
  storage: new MongoDBStore({
212
212
  uri: process.env.MONGODB_URI!,
@@ -265,7 +265,7 @@ export const mongodbAgent = new Agent({
265
265
  name: 'mongodb-agent',
266
266
  instructions:
267
267
  'You are an AI agent with the ability to automatically recall memories from previous interactions.',
268
- model: 'openai/gpt-5.1',
268
+ model: 'openai/gpt-5.4',
269
269
  memory: new Memory({
270
270
  storage: new MongoDBStore({
271
271
  id: 'mongodb-storage',
package/dist/index.cjs CHANGED
@@ -14,7 +14,7 @@ var evals = require('@mastra/core/evals');
14
14
 
15
15
  // package.json
16
16
  var package_default = {
17
- version: "1.5.5"};
17
+ version: "1.5.6"};
18
18
  var MongoDBFilterTranslator = class extends filter.BaseFilterTranslator {
19
19
  getSupportedOperators() {
20
20
  return {
@@ -4384,15 +4384,15 @@ var MemoryStorageMongoDB = class _MemoryStorageMongoDB extends storage.MemorySto
4384
4384
  let bestUnderTokens = 0;
4385
4385
  for (let i = 0; i < chunks.length; i++) {
4386
4386
  cumulativeMessageTokens += chunks[i].messageTokens ?? 0;
4387
- const boundary = i + 1;
4387
+ const boundary2 = i + 1;
4388
4388
  if (cumulativeMessageTokens >= targetMessageTokens) {
4389
4389
  if (bestOverBoundary === 0 || cumulativeMessageTokens < bestOverTokens) {
4390
- bestOverBoundary = boundary;
4390
+ bestOverBoundary = boundary2;
4391
4391
  bestOverTokens = cumulativeMessageTokens;
4392
4392
  }
4393
4393
  } else {
4394
4394
  if (cumulativeMessageTokens > bestUnderTokens) {
4395
- bestUnderBoundary = boundary;
4395
+ bestUnderBoundary = boundary2;
4396
4396
  bestUnderTokens = cumulativeMessageTokens;
4397
4397
  }
4398
4398
  }
@@ -4426,9 +4426,12 @@ var MemoryStorageMongoDB = class _MemoryStorageMongoDB extends storage.MemorySto
4426
4426
  const lastObservedAt = input.lastObservedAt ?? (latestChunk?.lastObservedAt ? new Date(latestChunk.lastObservedAt) : /* @__PURE__ */ new Date());
4427
4427
  const existingActive = doc.activeObservations || "";
4428
4428
  const existingTokenCount = Number(doc.observationTokenCount || 0);
4429
- const newActive = existingActive ? `${existingActive}
4429
+ const boundary = `
4430
4430
 
4431
- ${activatedContent}` : activatedContent;
4431
+ --- message boundary (${lastObservedAt.toISOString()}) ---
4432
+
4433
+ `;
4434
+ const newActive = existingActive ? `${existingActive}${boundary}${activatedContent}` : activatedContent;
4432
4435
  const newTokenCount = existingTokenCount + activatedTokens;
4433
4436
  const existingPending = Number(doc.pendingMessageTokens || 0);
4434
4437
  const newPending = Math.max(0, existingPending - activatedMessageTokens);