@mastra/memory 1.22.0-alpha.3 → 1.22.1-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,72 @@
1
1
  # @mastra/memory
2
2
 
3
+ ## 1.22.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`cc440a3`](https://github.com/mastra-ai/mastra/commit/cc440a39400d8ce06655462b26c1666a1b3d4320), [`ea6327b`](https://github.com/mastra-ai/mastra/commit/ea6327ba2d63ca647804bc97b347e03a58617162), [`3439fa8`](https://github.com/mastra-ai/mastra/commit/3439fa836ecfcaa257b40c20b30ac2a8be22e9ea), [`85107f2`](https://github.com/mastra-ai/mastra/commit/85107f2758b527147fccbedff962961927c2d3b8), [`1042cb4`](https://github.com/mastra-ai/mastra/commit/1042cb4da227c0a1315a6362262be3058866c5f8), [`06ff9e0`](https://github.com/mastra-ai/mastra/commit/06ff9e0befd1d642ab87ff749285ee4091205c7e), [`7f5e1ff`](https://github.com/mastra-ai/mastra/commit/7f5e1ff695a92f672bb3976363925d1e9136b54a), [`b8375c1`](https://github.com/mastra-ai/mastra/commit/b8375c1f8fe905df8ae2ae9a893bb365f17aec4e), [`003f35d`](https://github.com/mastra-ai/mastra/commit/003f35d19e07b23b4bacc591c8bc0c59b42124ae)]:
8
+ - @mastra/core@1.49.0-alpha.1
9
+ - @mastra/schema-compat@1.3.3-alpha.0
10
+
11
+ ## 1.22.0
12
+
13
+ ### Minor Changes
14
+
15
+ - add observational memory extractors ([#18653](https://github.com/mastra-ai/mastra/pull/18653))
16
+
17
+ Introduces a public Extractor API for Observational Memory
18
+ with inline XML extraction and structured follow-up modes.
19
+ Includes built-in extractors for current task, suggested
20
+ response, and thread title. Persists extracted values into
21
+ thread OM metadata with key-level merging and carry-forward
22
+ into future observer/reflector prompts.
23
+
24
+ - add OM-managed working memory ([#18654](https://github.com/mastra-ai/mastra/pull/18654))
25
+
26
+ Adds `observationalMemory.observation.manageWorkingMemory` so the Observer can update working memory automatically instead of requiring the main agent to call the working memory tool.
27
+
28
+ ```ts
29
+ new Memory({
30
+ options: {
31
+ workingMemory: { enabled: true },
32
+ observationalMemory: {
33
+ enabled: true,
34
+ observation: { manageWorkingMemory: true },
35
+ },
36
+ },
37
+ });
38
+ ```
39
+
40
+ This option adds `WorkingMemoryExtractor`, defaults `workingMemory.agentManaged` to `false`, and defaults `workingMemory.useStateSignals` to `true` when working memory is enabled. Set `workingMemory.agentManaged: true` to keep the main agent's working memory tool and instructions enabled.
41
+
42
+ ### Patch Changes
43
+
44
+ - Expose `providerMetadata` on Observational Memory `ObserveHooks` results ([#18563](https://github.com/mastra-ai/mastra/pull/18563))
45
+
46
+ `onObservationEnd` and `onReflectionEnd` now receive the OM model call's `providerMetadata` alongside `usage`, so you can read per-call provider details — for example the AI Gateway's cost and generation id — straight from the hook instead of wrapping the observer/reflector models in a model-stream middleware:
47
+
48
+ ```ts
49
+ const hooks: ObserveHooks = {
50
+ onObservationEnd: ({ usage, providerMetadata }) => {
51
+ const gateway = providerMetadata?.gateway;
52
+ recordCost({ tokens: usage?.totalTokens, cost: gateway?.cost, generationId: gateway?.generationId });
53
+ },
54
+ onReflectionEnd: ({ usage, providerMetadata }) => {
55
+ recordCost({ tokens: usage?.totalTokens, cost: providerMetadata?.gateway?.cost });
56
+ },
57
+ };
58
+ ```
59
+
60
+ The field is additive and optional, and is omitted entirely when the provider emits no metadata, so existing hook consumers are unaffected. For batched observations and multi-attempt reflections it reflects the last batch/attempt that emitted provider metadata.
61
+
62
+ - add Studio support for observational memory extractors ([#18655](https://github.com/mastra-ai/mastra/pull/18655))
63
+
64
+ Adds `bufferedObservationChunks` and extraction metadata to the buffer-status API and client types so extracted values flow through during live streaming. Renders observational memory indicators from a normalized cycle model that preserves extraction data across streaming, refetch, reload, activation, and failure transitions.
65
+
66
+ - Updated dependencies [[`b9a2961`](https://github.com/mastra-ai/mastra/commit/b9a2961c1be81e3639c0879e58588c26dd0ae866), [`b33c77d`](https://github.com/mastra-ai/mastra/commit/b33c77d5293f14a794f3ec38dc947a6676de2764), [`1274eb3`](https://github.com/mastra-ai/mastra/commit/1274eb3a9508f579ceb3187fbce34408222d4b71), [`cdd5f93`](https://github.com/mastra-ai/mastra/commit/cdd5f939cefa67390629704dce92563ccbf492b2), [`1274eb3`](https://github.com/mastra-ai/mastra/commit/1274eb3a9508f579ceb3187fbce34408222d4b71), [`0ac14ce`](https://github.com/mastra-ai/mastra/commit/0ac14cea48e1b0a7857782153c78f7242fdf7e1a), [`9566d27`](https://github.com/mastra-ai/mastra/commit/9566d27ead3d95bdbe5a69e5a082a68222829cf2), [`8be63b0`](https://github.com/mastra-ai/mastra/commit/8be63b015fb8d72cea1220f05e7dc3bb997cc249), [`1009f77`](https://github.com/mastra-ai/mastra/commit/1009f772aa40016b49267c8566d0c29f6a16aa3c), [`1b8728a`](https://github.com/mastra-ai/mastra/commit/1b8728a57fd844205a452b0b4216d20ff60c784a), [`23c31de`](https://github.com/mastra-ai/mastra/commit/23c31de96ed8153402dcf092ac84b27a0c3638c1), [`0368766`](https://github.com/mastra-ai/mastra/commit/0368766744c7ea3df4d6059e2cc15f7bdf55f5a6), [`d0702ee`](https://github.com/mastra-ai/mastra/commit/d0702eedc1594cb2d0d83476440cfc2ec8820adb), [`9feeaa0`](https://github.com/mastra-ai/mastra/commit/9feeaa0f9a1af07039e5b4f22b932b0cb18617e8), [`6f578ac`](https://github.com/mastra-ai/mastra/commit/6f578acba84930b406b2a0700b17cfdfaf5aae56), [`345eecc`](https://github.com/mastra-ai/mastra/commit/345eecce6ba519b5d987f0e10b5de4c8e5734580), [`1917c53`](https://github.com/mastra-ai/mastra/commit/1917c53b19dac43926f29c496893b0686462dca4), [`c01012f`](https://github.com/mastra-ai/mastra/commit/c01012f50368d29eb3fc3764df42d48291973d23), [`705ba98`](https://github.com/mastra-ai/mastra/commit/705ba98726d388a596e896225f237907ca6807a9), [`95857bc`](https://github.com/mastra-ai/mastra/commit/95857bcd6669da7193f503e803f0d72a2bd66be6), [`e62c108`](https://github.com/mastra-ai/mastra/commit/e62c108409dfd6a6cac0a48ec39c5cc81d24fd52), [`2866f04`](https://github.com/mastra-ai/mastra/commit/2866f04953edb78c1637fa45cc53abe24122edcb), [`ee14cae`](https://github.com/mastra-ai/mastra/commit/ee14cae244805783bde518a6142de28b744b169c), [`e84e791`](https://github.com/mastra-ai/mastra/commit/e84e79174031d7bc8793ca6c805eb38b06e7cfb1), [`c2f0b7f`](https://github.com/mastra-ai/mastra/commit/c2f0b7f1370f4428d165f51f0d1d9a48331cc257), [`213feb8`](https://github.com/mastra-ai/mastra/commit/213feb87bfdd1d8ec00ea660e218f9bcfcb34e7b), [`58e287b`](https://github.com/mastra-ai/mastra/commit/58e287b1edaf978b13745a1795989cad3826e82b), [`e420b3c`](https://github.com/mastra-ai/mastra/commit/e420b3c3ffc98bbc5b791897ea390bb47af99696), [`be875ed`](https://github.com/mastra-ai/mastra/commit/be875ed43f856742ce58529f531b5ea0ae6911f3), [`9eefdc0`](https://github.com/mastra-ai/mastra/commit/9eefdc0ac03f989718c6d835334940a977938895), [`bfbbb01`](https://github.com/mastra-ai/mastra/commit/bfbbb01bd845ba54cdc0c678c277d08a7cb847e4), [`7d112ca`](https://github.com/mastra-ai/mastra/commit/7d112ca17078479b2659b88ba1c85b936cfc111c)]:
67
+ - @mastra/core@1.48.0
68
+ - @mastra/schema-compat@1.3.2
69
+
3
70
  ## 1.22.0-alpha.3
4
71
 
5
72
  ### Minor 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.22.0-alpha.3"
6
+ version: "1.22.1-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.22.0-alpha.3",
2
+ "version": "1.22.1-alpha.0",
3
3
  "package": "@mastra/memory",
4
4
  "exports": {
5
5
  "Extractor": {
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Added in:** `@mastra/core@1.29.0`
4
4
 
5
- Background tasks let an agent dispatch a long-running tool call without blocking the agentic loop. The tool returns an immediate acknowledgement, the LLM continues responding, and the task runs to completion in the background. When it finishes, its result is written to memory and if you use `stream()` with the [`untilIdle`](https://mastra.ai/reference/agents/agent) option the agent is re-invoked automatically so the result is processed in the same call.
5
+ Background tasks let an agent dispatch a long-running tool call without blocking the agentic loop. The tool returns an immediate acknowledgement, the LLM continues responding, and the task runs to completion in the background. When it finishes, its result is written to memory and if you use `stream()` with the [`untilIdle`](https://mastra.ai/reference/streaming/agents/stream) option the agent is re-invoked automatically so the result is processed in the same call.
6
6
 
7
7
  ## When to use background tasks
8
8
 
@@ -166,7 +166,7 @@ const stream = await agent.stream('Research solana for me', {
166
166
  })
167
167
  ```
168
168
 
169
- > **Note:** Visit [`Agent.stream()`](https://mastra.ai/reference/agents/agent) for the full API.
169
+ > **Note:** Visit [`Agent.stream()`](https://mastra.ai/reference/streaming/agents/stream) for the full API.
170
170
 
171
171
  ### Aggregate properties
172
172
 
@@ -372,7 +372,7 @@ These read from storage rather than the pubsub stream, so they're suitable for p
372
372
 
373
373
  ## Related
374
374
 
375
- - [`Agent.stream()` reference](https://mastra.ai/reference/agents/agent)
375
+ - [`Agent.stream()` reference](https://mastra.ai/reference/streaming/agents/stream)
376
376
  - [backgroundTasks configuration reference](https://mastra.ai/reference/configuration)
377
377
  - [Durable agents](https://mastra.ai/docs/agents/durable-agents)
378
378
  - [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents)
@@ -26,6 +26,7 @@ Goals require a configured [storage](https://mastra.ai/docs/memory/storage) back
26
26
  import { Agent } from '@mastra/core/agent'
27
27
 
28
28
  const worker = new Agent({
29
+ id: 'worker',
29
30
  name: 'worker',
30
31
  instructions: 'You complete software tasks end to end.',
31
32
  model: 'openai/gpt-5.5',
@@ -66,6 +67,7 @@ By default the step uses a built-in LLM-as-judge scorer that returns `1` when th
66
67
 
67
68
  ```typescript
68
69
  const worker = new Agent({
70
+ id: 'worker',
69
71
  name: 'worker',
70
72
  instructions: 'You complete software tasks end to end.',
71
73
  model: 'openai/gpt-5.5',
@@ -351,6 +351,7 @@ Each subagent should have a clear `description` that explains what it does, what
351
351
 
352
352
  ```typescript
353
353
  const supervisor = new Agent({
354
+ id: 'supervisor',
354
355
  instructions: `You coordinate research and writing tasks.
355
356
 
356
357
  Available resources:
@@ -248,6 +248,7 @@ const contentBlocker = {
248
248
  }
249
249
 
250
250
  const agent = new Agent({
251
+ id: 'safe-agent',
251
252
  name: 'safe-agent',
252
253
  instructions: 'You are a helpful assistant',
253
254
  model: 'openai/gpt-5.5',
@@ -287,6 +288,7 @@ const inputValidator = {
287
288
  }
288
289
 
289
290
  const agent = new Agent({
291
+ id: 'validated-agent',
290
292
  name: 'validated-agent',
291
293
  instructions: 'You are a helpful assistant',
292
294
  model: 'openai/gpt-5.5',
@@ -13,6 +13,7 @@ import { Memory } from '@mastra/memory'
13
13
  import { Agent } from '@mastra/core/agent'
14
14
 
15
15
  export const agent = new Agent({
16
+ id: 'my-agent',
16
17
  name: 'my-agent',
17
18
  instructions: 'You are a helpful assistant.',
18
19
  model: 'openai/gpt-5-mini',
@@ -57,6 +58,7 @@ import { Memory } from '@mastra/memory'
57
58
  import { Agent } from '@mastra/core/agent'
58
59
 
59
60
  export const agent = new Agent({
61
+ id: 'my-agent',
60
62
  name: 'my-agent',
61
63
  instructions: 'You are a helpful assistant.',
62
64
  model: 'openai/gpt-5-mini',
@@ -196,6 +198,7 @@ const memory = new Memory({
196
198
  })
197
199
 
198
200
  export const agent = new Agent({
201
+ id: 'assistant',
199
202
  name: 'assistant',
200
203
  instructions: 'You are a helpful assistant.',
201
204
  model: 'openai/gpt-5-mini',
@@ -281,6 +284,7 @@ If your Observer model is text-only or its API rejects multimodal input, set `ob
281
284
 
282
285
  ```typescript
283
286
  new Agent({
287
+ id: 'assistant',
284
288
  name: 'assistant',
285
289
  instructions: 'You are a helpful assistant.',
286
290
  model: 'openai/gpt-5-mini',
@@ -130,6 +130,7 @@ The following options control semantic recall behavior:
130
130
 
131
131
  ```typescript
132
132
  const agent = new Agent({
133
+ id: 'agent',
133
134
  memory: new Memory({
134
135
  options: {
135
136
  semanticRecall: {
@@ -151,6 +152,7 @@ The `filter` option restricts semantic recall results to messages with matching
151
152
 
152
153
  ```typescript
153
154
  const agent = new Agent({
155
+ id: 'agent',
154
156
  memory: new Memory({
155
157
  options: {
156
158
  semanticRecall: {
@@ -217,6 +219,7 @@ import { Agent } from '@mastra/core/agent'
217
219
  import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
218
220
 
219
221
  const agent = new Agent({
222
+ id: 'agent',
220
223
  memory: new Memory({
221
224
  embedder: new ModelRouterEmbeddingModel('openai/text-embedding-3-small'),
222
225
  options: {
@@ -238,6 +241,7 @@ import { Memory } from '@mastra/memory'
238
241
  import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
239
242
 
240
243
  const agent = new Agent({
244
+ id: 'agent',
241
245
  memory: new Memory({
242
246
  embedder: new ModelRouterEmbeddingModel({
243
247
  providerId: 'openrouter',
@@ -259,6 +263,7 @@ import { Agent } from '@mastra/core/agent'
259
263
  import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
260
264
 
261
265
  const agent = new Agent({
266
+ id: 'agent',
262
267
  memory: new Memory({
263
268
  embedder: new ModelRouterEmbeddingModel('openai/text-embedding-3-small'),
264
269
  }),
@@ -301,6 +306,7 @@ import { Agent } from '@mastra/core/agent'
301
306
  import { fastembed } from '@mastra/fastembed'
302
307
 
303
308
  const agent = new Agent({
309
+ id: 'agent',
304
310
  memory: new Memory({
305
311
  embedder: fastembed,
306
312
  }),
@@ -9,6 +9,7 @@ import { Memory } from '@mastra/memory'
9
9
  import { Agent } from '@mastra/core/agent'
10
10
 
11
11
  export const agent = new Agent({
12
+ id: 'test-agent',
12
13
  name: 'test-agent',
13
14
  instructions: 'You are an agent with memory.',
14
15
  model: 'openai/gpt-5.5',
@@ -11,6 +11,7 @@ import { Memory } from '@mastra/memory'
11
11
  import { Agent } from '@mastra/core/agent'
12
12
 
13
13
  export const agent = new Agent({
14
+ id: 'my-agent',
14
15
  name: 'my-agent',
15
16
  instructions: 'You are a helpful assistant.',
16
17
  model: 'openai/gpt-5-mini',
@@ -203,6 +204,7 @@ import { Memory } from '@mastra/memory'
203
204
  import { Agent } from '@mastra/core/agent'
204
205
 
205
206
  export const agent = new Agent({
207
+ id: 'my-agent',
206
208
  name: 'my-agent',
207
209
  instructions: 'You are a helpful assistant.',
208
210
  model: 'openai/gpt-5-mini',
@@ -232,6 +234,7 @@ import { Memory } from '@mastra/memory'
232
234
  import { Agent } from '@mastra/core/agent'
233
235
 
234
236
  export const agent = new Agent({
237
+ id: 'my-agent',
235
238
  name: 'my-agent',
236
239
  instructions: 'You are a helpful assistant.',
237
240
  model: 'openai/gpt-5-mini',
@@ -261,6 +264,7 @@ import { Memory } from '@mastra/memory'
261
264
  import { Agent } from '@mastra/core/agent'
262
265
 
263
266
  export const agent = new Agent({
267
+ id: 'my-agent',
264
268
  name: 'my-agent',
265
269
  instructions: 'You are a helpful assistant.',
266
270
  model: 'openai/gpt-5.5',
@@ -281,6 +285,7 @@ import { Memory } from '@mastra/memory'
281
285
  import { Agent } from '@mastra/core/agent'
282
286
 
283
287
  export const agent = new Agent({
288
+ id: 'my-agent',
284
289
  name: 'my-agent',
285
290
  instructions: 'You are a helpful assistant.',
286
291
  model: 'openai/gpt-5.5',
@@ -308,6 +313,7 @@ import { Memory } from '@mastra/memory'
308
313
  import { Agent } from '@mastra/core/agent'
309
314
 
310
315
  export const agent = new Agent({
316
+ id: 'health-assistant',
311
317
  name: 'health-assistant',
312
318
  instructions: 'You are a health and wellness assistant.',
313
319
  model: 'openai/gpt-5.5',
@@ -351,6 +357,7 @@ import { Memory } from '@mastra/memory'
351
357
  import { Agent } from '@mastra/core/agent'
352
358
 
353
359
  export const agent = new Agent({
360
+ id: 'my-agent',
354
361
  name: 'my-agent',
355
362
  instructions: 'You are a helpful assistant.',
356
363
  model: 'openai/gpt-5-mini',
@@ -666,6 +673,7 @@ const om = new ObservationalMemory({
666
673
  })
667
674
 
668
675
  export const agent = new Agent({
676
+ id: 'my-agent',
669
677
  name: 'my-agent',
670
678
  instructions: 'You are a helpful assistant.',
671
679
  model: 'openai/gpt-5-mini',
@@ -79,6 +79,7 @@ import { Memory } from '@mastra/memory'
79
79
  import { TokenLimiterProcessor } from '@mastra/core/processors'
80
80
 
81
81
  export const agent = new Agent({
82
+ id: 'context-limited-agent',
82
83
  name: 'context-limited-agent',
83
84
  instructions: 'You are a helpful assistant',
84
85
  model: 'openai/gpt-5.5',
@@ -100,6 +101,7 @@ import { Agent } from '@mastra/core/agent'
100
101
  import { TokenLimiterProcessor } from '@mastra/core/processors'
101
102
 
102
103
  export const agent = new Agent({
104
+ id: 'multi-step-agent',
103
105
  name: 'multi-step-agent',
104
106
  instructions: 'You are a helpful research assistant with access to tools',
105
107
  model: 'openai/gpt-5.5',
@@ -123,6 +125,7 @@ import { Agent } from '@mastra/core/agent'
123
125
  import { TokenLimiterProcessor } from '@mastra/core/processors'
124
126
 
125
127
  export const agent = new Agent({
128
+ id: 'response-limited-agent',
126
129
  name: 'response-limited-agent',
127
130
  instructions: 'You are a helpful assistant',
128
131
  model: 'openai/gpt-5.5',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/memory",
3
- "version": "1.22.0-alpha.3",
3
+ "version": "1.22.1-alpha.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -45,7 +45,7 @@
45
45
  "tokenx": "^1.3.0",
46
46
  "xxhash-wasm": "^1.1.0",
47
47
  "zod": "^4.4.3",
48
- "@mastra/schema-compat": "1.3.2-alpha.1"
48
+ "@mastra/schema-compat": "1.3.3-alpha.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@ai-sdk/openai": "^1.3.24",
@@ -61,12 +61,12 @@
61
61
  "typescript": "^6.0.3",
62
62
  "typescript-eslint": "^8.57.0",
63
63
  "vitest": "4.1.8",
64
- "@internal/ai-sdk-v5": "0.0.56",
65
- "@internal/ai-v6": "0.0.56",
66
- "@internal/ai-sdk-v4": "0.0.56",
67
- "@internal/types-builder": "0.0.84",
68
- "@mastra/core": "1.48.0-alpha.10",
69
- "@internal/lint": "0.0.109"
64
+ "@internal/ai-sdk-v5": "0.0.57",
65
+ "@internal/ai-sdk-v4": "0.0.57",
66
+ "@internal/ai-v6": "0.0.57",
67
+ "@internal/lint": "0.0.110",
68
+ "@internal/types-builder": "0.0.85",
69
+ "@mastra/core": "1.49.0-alpha.1"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "@mastra/core": ">=1.4.1-0 <2.0.0-0"