@mastra/memory 1.18.2-alpha.1 → 1.18.2

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,44 @@
1
1
  # @mastra/memory
2
2
 
3
+ ## 1.18.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed thread deletion so it also clears thread-scoped observational memory. ([#16628](https://github.com/mastra-ai/mastra/pull/16628))
8
+
9
+ - Fixed Observational Memory missing the observation threshold for messages with large file parts. Previously `TokenCounter`'s local/sync counting path only stringified the file descriptor (`type`, `mimeType`, `filename`) for non-image files, so a 100KB PDF looked like ~8 tokens to OM and the conversation kept replaying the full unobserved history past every reasonable threshold. ([#16562](https://github.com/mastra-ai/mastra/pull/16562))
10
+
11
+ `TokenCounter` now estimates non-image file part tokens locally from the attachment's byte size and mime type using a per-provider heuristic, mirroring the existing local image-token estimator:
12
+ - Anthropic PDFs ≈ `bytes / 3` (floor 1500)
13
+ - Google PDFs ≈ `bytes / 20` (floor 258)
14
+ - OpenAI / unknown PDFs ≈ `bytes / 4` (floor 500)
15
+ - Text-ish mime types (`text/*`, JSON, XML, YAML) ≈ `bytes / 4`
16
+ - Other binary ≈ `bytes / 4`
17
+
18
+ URL-only file parts (no body to size) keep the previous descriptor-only local estimate. `countMessagesAsync()` continues to prefer provider token-count endpoints for supported providers; this change only improves the local fallback used when no provider endpoint is available.
19
+
20
+ ```ts
21
+ // Before: this PDF counted as ~8 tokens locally regardless of size, so OM never triggered.
22
+ const part = {
23
+ type: 'file',
24
+ data: largePdfBase64,
25
+ mimeType: 'application/pdf',
26
+ filename: 'report.pdf',
27
+ };
28
+ // counter.countMessage(message) ≈ 8
29
+
30
+ // After: estimated locally from byte size on the active provider.
31
+ // counter.countMessage(message) ≈ tens of thousands of tokens
32
+ // → OM threshold trips as expected.
33
+ ```
34
+
35
+ The internal token-estimate cache version was bumped, which invalidates persisted estimates from older `@mastra/memory` releases on the next read; entries are recomputed automatically.
36
+
37
+ Fixes https://github.com/mastra-ai/mastra/issues/16522
38
+
39
+ - Updated dependencies [[`b661349`](https://github.com/mastra-ai/mastra/commit/b661349281514691db78941a9044e6e4f1cde7a7), [`816b974`](https://github.com/mastra-ai/mastra/commit/816b974b424e4a1bfae3af30cc41263b6f1c0344), [`271c044`](https://github.com/mastra-ai/mastra/commit/271c044f6b79ff38cfa3409f4385fbd26a0f3185), [`bad08e9`](https://github.com/mastra-ai/mastra/commit/bad08e99c5291884c3ac76743c78c74f53a302c2), [`816b974`](https://github.com/mastra-ai/mastra/commit/816b974b424e4a1bfae3af30cc41263b6f1c0344), [`b32ba5f`](https://github.com/mastra-ai/mastra/commit/b32ba5fde524b46a4ff1bdf38e30d62a2bb29b04), [`75c7c38`](https://github.com/mastra-ai/mastra/commit/75c7c38a4e9af9821931539dd339f57fcc6414e3)]:
40
+ - @mastra/core@1.35.0
41
+
3
42
  ## 1.18.2-alpha.1
4
43
 
5
44
  ### Patch Changes
@@ -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.18.2-alpha.1"
6
+ version: "1.18.2"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.18.2-alpha.1",
2
+ "version": "1.18.2",
3
3
  "package": "@mastra/memory",
4
4
  "exports": {
5
5
  "ModelByInputTokens": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/memory",
3
- "version": "1.18.2-alpha.1",
3
+ "version": "1.18.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -59,12 +59,12 @@
59
59
  "typescript-eslint": "^8.57.0",
60
60
  "vitest": "4.1.5",
61
61
  "zod": "^4.3.6",
62
- "@internal/ai-sdk-v4": "0.0.42",
63
- "@internal/ai-sdk-v5": "0.0.42",
64
- "@internal/ai-v6": "0.0.42",
65
- "@internal/types-builder": "0.0.70",
66
- "@internal/lint": "0.0.95",
67
- "@mastra/core": "1.35.0-alpha.2"
62
+ "@internal/ai-v6": "0.0.43",
63
+ "@internal/ai-sdk-v5": "0.0.43",
64
+ "@internal/ai-sdk-v4": "0.0.43",
65
+ "@internal/lint": "0.0.96",
66
+ "@mastra/core": "1.35.0",
67
+ "@internal/types-builder": "0.0.71"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@mastra/core": ">=1.4.1-0 <2.0.0-0",