@mastra/memory 1.1.0-alpha.1 → 1.1.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,56 @@
1
1
  # @mastra/memory
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added Observational Memory — a new memory system that keeps your agent's context window small while preserving long-term memory across conversations. ([#12599](https://github.com/mastra-ai/mastra/pull/12599))
8
+
9
+ **Why:** Long conversations cause context rot and waste tokens. Observational Memory compresses conversation history into observations (5–40x compression) and periodically condenses those into reflections. Your agent stays fast and focused, even after thousands of messages.
10
+
11
+ **Usage:**
12
+
13
+ ```ts
14
+ import { Memory } from '@mastra/memory';
15
+ import { PostgresStore } from '@mastra/pg';
16
+
17
+ const memory = new Memory({
18
+ storage: new PostgresStore({ connectionString: process.env.DATABASE_URL }),
19
+ options: {
20
+ observationalMemory: true,
21
+ },
22
+ });
23
+
24
+ const agent = new Agent({
25
+ name: 'my-agent',
26
+ model: openai('gpt-4o'),
27
+ memory,
28
+ });
29
+ ```
30
+
31
+ **What's new:**
32
+ - `observationalMemory: true` enables the three-tier memory system (recent messages → observations → reflections)
33
+ - Thread-scoped (per-conversation) and resource-scoped (shared across all threads for a user) modes
34
+ - Manual `observe()` API for triggering observation outside the normal agent loop
35
+ - New OM storage methods for pg, libsql, and mongodb adapters (conditionally enabled)
36
+ - `Agent.findProcessor()` method for looking up processors by ID
37
+ - `processorStates` for persisting processor state across loop iterations
38
+ - Abort signal propagation to processors
39
+ - `ProcessorStreamWriter` for custom stream events from processors
40
+
41
+ - Expose token usage from embedding operations ([#12556](https://github.com/mastra-ai/mastra/pull/12556))
42
+ - `saveMessages` now returns `usage: { tokens: number }` with aggregated token count from all embeddings
43
+ - `recall` now returns `usage: { tokens: number }` from the vector search query embedding
44
+ - Updated abstract method signatures in `MastraMemory` to include optional `usage` in return types
45
+
46
+ This allows users to track embedding token usage when using the Memory class.
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [[`e6fc281`](https://github.com/mastra-ai/mastra/commit/e6fc281896a3584e9e06465b356a44fe7faade65), [`97be6c8`](https://github.com/mastra-ai/mastra/commit/97be6c8963130fca8a664fcf99d7b3a38e463595), [`2770921`](https://github.com/mastra-ai/mastra/commit/2770921eec4d55a36b278d15c3a83f694e462ee5), [`b1695db`](https://github.com/mastra-ai/mastra/commit/b1695db2d7be0c329d499619c7881899649188d0), [`5fe1fe0`](https://github.com/mastra-ai/mastra/commit/5fe1fe0109faf2c87db34b725d8a4571a594f80e), [`4133d48`](https://github.com/mastra-ai/mastra/commit/4133d48eaa354cdb45920dc6265732ffbc96788d), [`abae238`](https://github.com/mastra-ai/mastra/commit/abae238c755ebaf867bbfa1a3a219ef003a1021a), [`5dd01cc`](https://github.com/mastra-ai/mastra/commit/5dd01cce68d61874aa3ecbd91ee17884cfd5aca2), [`13e0a2a`](https://github.com/mastra-ai/mastra/commit/13e0a2a2bcec01ff4d701274b3727d5e907a6a01), [`f6673b8`](https://github.com/mastra-ai/mastra/commit/f6673b893b65b7d273ad25ead42e990704cc1e17), [`cd6be8a`](https://github.com/mastra-ai/mastra/commit/cd6be8ad32741cd41cabf508355bb31b71e8a5bd), [`9eb4e8e`](https://github.com/mastra-ai/mastra/commit/9eb4e8e39efbdcfff7a40ff2ce07ce2714c65fa8), [`c987384`](https://github.com/mastra-ai/mastra/commit/c987384d6c8ca844a9701d7778f09f5a88da7f9f), [`cb8cc12`](https://github.com/mastra-ai/mastra/commit/cb8cc12bfadd526aa95a01125076f1da44e4afa7), [`aa37c84`](https://github.com/mastra-ai/mastra/commit/aa37c84d29b7db68c72517337932ef486c316275), [`62f5d50`](https://github.com/mastra-ai/mastra/commit/62f5d5043debbba497dacb7ab008fe86b38b8de3), [`47eba72`](https://github.com/mastra-ai/mastra/commit/47eba72f0397d0d14fbe324b97940c3d55e5a525)]:
51
+ - @mastra/core@1.2.0
52
+ - @mastra/schema-compat@1.1.0
53
+
3
54
  ## 1.1.0-alpha.1
4
55
 
5
56
  ### Minor Changes
@@ -33,4 +33,4 @@ docs/
33
33
  ## Version
34
34
 
35
35
  Package: @mastra/memory
36
- Version: 1.1.0-alpha.1
36
+ Version: 1.1.0
@@ -5,7 +5,7 @@ description: Documentation for @mastra/memory. Includes links to type definition
5
5
 
6
6
  # @mastra/memory Documentation
7
7
 
8
- > **Version**: 1.1.0-alpha.1
8
+ > **Version**: 1.1.0
9
9
  > **Package**: @mastra/memory
10
10
 
11
11
  ## Quick Navigation
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.0-alpha.1",
2
+ "version": "1.1.0",
3
3
  "package": "@mastra/memory",
4
4
  "exports": {
5
5
  "OBSERVATIONAL_MEMORY_DEFAULTS": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/memory",
3
- "version": "1.1.0-alpha.1",
3
+ "version": "1.1.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -41,7 +41,7 @@
41
41
  "json-schema": "^0.4.0",
42
42
  "lru-cache": "^11.2.2",
43
43
  "xxhash-wasm": "^1.1.0",
44
- "@mastra/schema-compat": "1.1.0-alpha.0"
44
+ "@mastra/schema-compat": "1.1.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@ai-sdk/openai": "^1.3.24",
@@ -56,12 +56,12 @@
56
56
  "typescript": "^5.9.3",
57
57
  "typescript-eslint": "^8.51.0",
58
58
  "vitest": "4.0.16",
59
- "@internal/ai-v6": "0.0.3",
60
- "@internal/ai-sdk-v5": "0.0.3",
61
- "@internal/lint": "0.0.56",
62
- "@internal/types-builder": "0.0.31",
63
- "@mastra/core": "1.2.0-alpha.1",
64
- "@internal/ai-sdk-v4": "0.0.3"
59
+ "@internal/ai-sdk-v5": "0.0.4",
60
+ "@internal/lint": "0.0.57",
61
+ "@internal/types-builder": "0.0.32",
62
+ "@internal/ai-sdk-v4": "0.0.4",
63
+ "@internal/ai-v6": "0.0.4",
64
+ "@mastra/core": "1.2.0"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "@mastra/core": ">=1.0.0-0 <2.0.0-0",