@mastra/memory 1.24.0-alpha.0 → 1.25.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.
Files changed (89) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/docs/SKILL.md +6 -6
  3. package/dist/docs/assets/SOURCE_MAP.json +3 -205
  4. package/dist/docs/references/docs-agents-agent-approval.md +85 -11
  5. package/dist/docs/references/docs-agents-networks.md +2 -2
  6. package/dist/docs/references/docs-agents-supervisor-agents.md +19 -13
  7. package/dist/docs/references/docs-evals-evals-with-memory.md +4 -4
  8. package/dist/docs/references/docs-long-running-agents-background-tasks.md +10 -10
  9. package/dist/docs/references/docs-long-running-agents-goals.md +15 -11
  10. package/dist/docs/references/docs-memory-memory-processors.md +10 -10
  11. package/dist/docs/references/docs-memory-message-history.md +11 -5
  12. package/dist/docs/references/docs-memory-multi-user-threads.md +6 -6
  13. package/dist/docs/references/docs-memory-observational-memory.md +57 -38
  14. package/dist/docs/references/docs-memory-overview.md +24 -10
  15. package/dist/docs/references/docs-memory-semantic-recall.md +3 -3
  16. package/dist/docs/references/docs-memory-working-memory.md +8 -8
  17. package/dist/docs/references/docs-storage-overview.md +2 -2
  18. package/dist/docs/references/reference-memory-clone-utilities.md +1 -1
  19. package/dist/docs/references/reference-memory-cloneThread.md +3 -3
  20. package/dist/docs/references/reference-memory-listThreads.md +1 -1
  21. package/dist/docs/references/reference-memory-memory-class.md +4 -4
  22. package/dist/docs/references/reference-memory-observational-memory.md +88 -38
  23. package/dist/docs/references/reference-memory-summarizeConversation.md +3 -3
  24. package/dist/docs/references/reference-memory-summarizeThread.md +3 -3
  25. package/dist/docs/references/reference-processors-token-limiter-processor.md +4 -4
  26. package/dist/docs/references/reference-storage-dsql.md +3 -3
  27. package/dist/docs/references/reference-storage-dynamodb.md +7 -7
  28. package/dist/docs/references/reference-storage-mongodb.md +2 -2
  29. package/dist/docs/references/reference-storage-postgresql.md +2 -2
  30. package/dist/docs/references/reference-storage-redis.md +1 -1
  31. package/dist/docs/references/reference-storage-upstash.md +1 -1
  32. package/dist/docs/references/reference-vectors-libsql.md +2 -2
  33. package/dist/docs/references/reference-vectors-mongodb.md +188 -7
  34. package/dist/docs/references/reference-vectors-pg.md +5 -5
  35. package/dist/docs/references/reference-vectors-upstash.md +1 -1
  36. package/dist/index.cjs +30 -72
  37. package/dist/index.d.ts +1 -0
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +2 -4
  40. package/dist/processors/index.cjs +32 -129
  41. package/dist/processors/index.js +2 -4
  42. package/dist/processors/observational-memory/index.d.ts +1 -1
  43. package/dist/processors/observational-memory/index.d.ts.map +1 -1
  44. package/dist/processors/observational-memory/observation-strategies/types.d.ts +6 -0
  45. package/dist/processors/observational-memory/observation-strategies/types.d.ts.map +1 -1
  46. package/dist/processors/observational-memory/observation-turn/step.d.ts.map +1 -1
  47. package/dist/processors/observational-memory/observational-memory.d.ts +30 -1
  48. package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
  49. package/dist/processors/observational-memory/processor.d.ts.map +1 -1
  50. package/dist/processors/observational-memory/reflector-runner.d.ts.map +1 -1
  51. package/dist/processors/observational-memory/types.d.ts +50 -6
  52. package/dist/processors/observational-memory/types.d.ts.map +1 -1
  53. package/dist/src-BYZh9IBv.js +28250 -0
  54. package/dist/src-BYZh9IBv.js.map +1 -0
  55. package/dist/src-naeQog_T.cjs +28504 -0
  56. package/dist/src-naeQog_T.cjs.map +1 -0
  57. package/package.json +9 -9
  58. package/dist/chunk-3UXBG7HA.js +0 -31429
  59. package/dist/chunk-3UXBG7HA.js.map +0 -1
  60. package/dist/chunk-43FJOLKM.cjs +0 -108
  61. package/dist/chunk-43FJOLKM.cjs.map +0 -1
  62. package/dist/chunk-D4J4XPGM.cjs +0 -111
  63. package/dist/chunk-D4J4XPGM.cjs.map +0 -1
  64. package/dist/chunk-EGRHWZRV.js +0 -3
  65. package/dist/chunk-EGRHWZRV.js.map +0 -1
  66. package/dist/chunk-LSJJAJAF.js +0 -105
  67. package/dist/chunk-LSJJAJAF.js.map +0 -1
  68. package/dist/chunk-NKIQRCOM.cjs +0 -4
  69. package/dist/chunk-NKIQRCOM.cjs.map +0 -1
  70. package/dist/chunk-RY3SV3BJ.cjs +0 -31496
  71. package/dist/chunk-RY3SV3BJ.cjs.map +0 -1
  72. package/dist/chunk-WCGXQIEN.js +0 -103
  73. package/dist/chunk-WCGXQIEN.js.map +0 -1
  74. package/dist/constants-RMCTOZE3.js +0 -3
  75. package/dist/constants-RMCTOZE3.js.map +0 -1
  76. package/dist/constants-ZEKSZ4UM.cjs +0 -28
  77. package/dist/constants-ZEKSZ4UM.cjs.map +0 -1
  78. package/dist/index.cjs.map +0 -1
  79. package/dist/index.js.map +0 -1
  80. package/dist/observational-memory-FF4AVBKG.cjs +0 -129
  81. package/dist/observational-memory-FF4AVBKG.cjs.map +0 -1
  82. package/dist/observational-memory-OSTBP4LB.js +0 -4
  83. package/dist/observational-memory-OSTBP4LB.js.map +0 -1
  84. package/dist/processors/index.cjs.map +0 -1
  85. package/dist/processors/index.js.map +0 -1
  86. package/dist/working-memory-state-LDPWYVCG.cjs +0 -24
  87. package/dist/working-memory-state-LDPWYVCG.cjs.map +0 -1
  88. package/dist/working-memory-state-OMSMSYAW.js +0 -3
  89. package/dist/working-memory-state-OMSMSYAW.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # @mastra/memory
2
2
 
3
+ ## 1.25.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added config-level `hooks` to Observational Memory so apps can track what OM's background model calls cost. Previously the `ObserveHooks` lifecycle callbacks only fired when calling `observe()` manually — the automatic pipeline (turn-driven observation and fire-and-forget async buffering) computed token `usage` and `providerMetadata` and dropped them. Hooks set on the OM config (including through `Memory`'s `observationalMemory` options) now fire for every observation and reflection cycle, with `threadId`/`resourceId`/`trigger` call context: ([#19058](https://github.com/mastra-ai/mastra/pull/19058))
8
+
9
+ ```ts
10
+ const memory = new Memory({
11
+ storage,
12
+ options: {
13
+ observationalMemory: {
14
+ hooks: {
15
+ onObservationEnd: ({ usage, providerMetadata, error, threadId, trigger }) => {
16
+ recordOmSpend({ usage, providerMetadata, threadId, trigger });
17
+ },
18
+ },
19
+ },
20
+ },
21
+ });
22
+ ```
23
+
24
+ Failed async-buffered cycles never throw (they are fire-and-forget), so they report through the end hook's `error` field instead. Errors thrown by config-level hooks are caught and logged, never failing the cycle. Per-call `observe()` hooks keep their existing payloads and semantics.
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies [[`594f7b2`](https://github.com/mastra-ai/mastra/commit/594f7b28f5263fb9982fd50d95c471fb971ea984), [`311f943`](https://github.com/mastra-ai/mastra/commit/311f943bee60e8fdf5c84499ea50e884276c936c), [`0c89896`](https://github.com/mastra-ai/mastra/commit/0c8989673fb7d106837098398131e570c6023b68), [`23b4238`](https://github.com/mastra-ai/mastra/commit/23b423844ad0bcf2a502a68dd62866d6160f9f6d), [`e320a76`](https://github.com/mastra-ai/mastra/commit/e320a763feaf65c6be3cebecf746defcbde161b3), [`03b4918`](https://github.com/mastra-ai/mastra/commit/03b4918c80d188ce375334c393e131c6e94bd7eb), [`14ef73a`](https://github.com/mastra-ai/mastra/commit/14ef73a4bbd73e7808414816eb0628ce1d80b5d7), [`1d677d5`](https://github.com/mastra-ai/mastra/commit/1d677d5f99d7db403f7828585e8c25f299f72628), [`93e28ec`](https://github.com/mastra-ai/mastra/commit/93e28ecce9031c02397e0ae8406593e5c7a95883), [`729dab4`](https://github.com/mastra-ai/mastra/commit/729dab408faccfaef0cbb048e5a4338f9172847e), [`484003d`](https://github.com/mastra-ai/mastra/commit/484003d33ff59330c86b19863e4a38732d7e4155), [`933d291`](https://github.com/mastra-ai/mastra/commit/933d291146b789c19442ad206f94da3e4be90c64)]:
29
+ - @mastra/core@1.56.0-alpha.3
30
+
31
+ ## 1.24.0
32
+
33
+ ### Minor Changes
34
+
35
+ - Added exact metadata filtering to message history queries across Memory APIs and supported storage providers. ([#19991](https://github.com/mastra-ai/mastra/pull/19991))
36
+
37
+ ```ts
38
+ const messages = await memory.recall({
39
+ threadId: 'thread-1',
40
+ filter: {
41
+ metadata: {
42
+ status: 'done',
43
+ priority: 'high',
44
+ },
45
+ },
46
+ });
47
+ ```
48
+
49
+ Multiple fields use AND semantics. Supported values are strings, finite numbers, booleans, and `null`.
50
+
51
+ ### Patch Changes
52
+
53
+ - Updated dependencies [[`ce93a3c`](https://github.com/mastra-ai/mastra/commit/ce93a3c114ea1cbfbd576f3db41d7c26c9844f5b), [`5718a22`](https://github.com/mastra-ai/mastra/commit/5718a229281dcfd36bcd1f42a242e3717e510a33), [`a211d09`](https://github.com/mastra-ai/mastra/commit/a211d09185dc65a746534914cf38b67f21ee9bac), [`0dca9d0`](https://github.com/mastra-ai/mastra/commit/0dca9d0b1356024a53b72ea6f040db528b126caa), [`6218217`](https://github.com/mastra-ai/mastra/commit/62182171b6cfca0b099f1c6a77a2e65e7639ab86), [`5807d3a`](https://github.com/mastra-ai/mastra/commit/5807d3ae1d259b8b7d6df7e5bf2b485c694af9c8), [`57661af`](https://github.com/mastra-ai/mastra/commit/57661afeca52ff9af4e72675ede2134fa503d5a5), [`05db566`](https://github.com/mastra-ai/mastra/commit/05db566fcbdcbf33d0bffca0c72ec30129e2e3ca), [`57661af`](https://github.com/mastra-ai/mastra/commit/57661afeca52ff9af4e72675ede2134fa503d5a5), [`57661af`](https://github.com/mastra-ai/mastra/commit/57661afeca52ff9af4e72675ede2134fa503d5a5), [`5718a22`](https://github.com/mastra-ai/mastra/commit/5718a229281dcfd36bcd1f42a242e3717e510a33), [`57661af`](https://github.com/mastra-ai/mastra/commit/57661afeca52ff9af4e72675ede2134fa503d5a5), [`d1b7e3a`](https://github.com/mastra-ai/mastra/commit/d1b7e3a978a309a5653eeaa490d2d6c7c53bd093), [`29c584a`](https://github.com/mastra-ai/mastra/commit/29c584a13a88831e5ed1fdeb0ff8e82eae180433), [`c093146`](https://github.com/mastra-ai/mastra/commit/c0931466404d3c521308ea119cb165bb7e695155), [`8124754`](https://github.com/mastra-ai/mastra/commit/8124754ae89fbc69f8136d1df4a91904d0f84c4e), [`d12b2e4`](https://github.com/mastra-ai/mastra/commit/d12b2e4023fd9e3d3e93a9169f5088bcee2a849c)]:
54
+ - @mastra/core@1.54.0
55
+
3
56
  ## 1.24.0-alpha.0
4
57
 
5
58
  ### 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.24.0-alpha.0"
6
+ version: "1.25.0-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -16,11 +16,11 @@ Read the individual reference documents for detailed explanations and code examp
16
16
 
17
17
  ### Docs
18
18
 
19
- - [Agent approval](references/docs-agents-agent-approval.md) - Learn how to require approvals, suspend tool execution, and automatically resume suspended tools while keeping humans in control of agent workflows.
19
+ - [Agent approval](references/docs-agents-agent-approval.md) - Learn how to require approvals and suspend tool execution, plus automatically resume suspended tools while keeping humans in control of agent workflows.
20
20
  - [Agent networks](references/docs-agents-networks.md) - Coordinate multiple agents, workflows, and tools using agent networks for complex, non-deterministic task execution.
21
21
  - [Supervisor agents](references/docs-agents-supervisor-agents.md) - Learn how to coordinate multiple agents with delegation hooks, iteration monitoring, message filtering, and task completion scoring.
22
- - [Evals with memory](references/docs-evals-evals-with-memory.md) - Run scorers against memory-enabled agents including observational memory in thread scope using runEvals and dataset experiments.
23
- - [Background tasks](references/docs-long-running-agents-background-tasks.md) - Learn how to dispatch long-running tool calls in the background, keep the stream open until they complete, and orchestrate subagents asynchronously.
22
+ - [Evals with memory](references/docs-evals-evals-with-memory.md) - Run scorers against memory-enabled agents, including observational memory in thread scope, using runEvals and dataset experiments.
23
+ - [Background tasks](references/docs-long-running-agents-background-tasks.md) - Learn how to dispatch long-running tool calls in the background and keep the stream open until they complete, plus orchestrate subagents asynchronously.
24
24
  - [Goals](references/docs-long-running-agents-goals.md) - Learn how to set a durable objective on an agent that's judged in the execution loop, so the agent keeps working until the goal is complete or the run budget is exhausted.
25
25
  - [Memory processors](references/docs-memory-memory-processors.md) - Learn how to use memory processors in Mastra to filter, trim, and transform messages before they're sent to the language model to manage context window limits.
26
26
  - [Message history](references/docs-memory-message-history.md) - Learn how to configure message history in Mastra to store recent messages from the current conversation.
@@ -41,8 +41,8 @@ Read the individual reference documents for detailed explanations and code examp
41
41
  - [Reference: Memory.createThread()](references/reference-memory-createThread.md) - Documentation for the `Memory.createThread()` method in Mastra, which creates a new conversation thread in the memory system.
42
42
  - [Reference: Memory.getThreadById()](references/reference-memory-getThreadById.md) - Documentation for the `Memory.getThreadById()` method in Mastra, which retrieves a specific thread by its ID.
43
43
  - [Reference: Memory.listThreads()](references/reference-memory-listThreads.md) - Documentation for the `Memory.listThreads()` method in Mastra, which retrieves threads with optional filtering by resourceId and/or metadata.
44
- - [Reference: Memory class](references/reference-memory-memory-class.md) - Documentation for the `Memory` class in Mastra, which provides a robust system for managing conversation history and thread-based message storage.
45
- - [Reference: Observational Memory](references/reference-memory-observational-memory.md) - API reference for Observational Memory in Mastra a three-tier memory system that uses Observer and Reflector agents to maintain long-term memory across conversations.
44
+ - [Reference: Memory class](references/reference-memory-memory-class.md) - Documentation for the `Memory` class in Mastra, which provides a reliable system for managing conversation history and thread-based message storage.
45
+ - [Reference: Observational Memory](references/reference-memory-observational-memory.md) - API reference for Observational Memory in Mastra: a three-tier memory system that uses Observer and Reflector agents to maintain long-term memory across conversations.
46
46
  - [Reference: summarizeConversation()](references/reference-memory-summarizeConversation.md) - Documentation for the standalone `summarizeConversation()` function in Mastra, which summarizes messages you pass in and extracts structured values from them.
47
47
  - [Reference: Memory.summarizeThread()](references/reference-memory-summarizeThread.md) - Documentation for the `Memory.summarizeThread()` method in Mastra, which summarizes a thread's conversation in one shot and extracts structured values from it.
48
48
  - [Reference: TokenLimiterProcessor](references/reference-processors-token-limiter-processor.md) - Documentation for the TokenLimiterProcessor in Mastra, which limits the number of tokens in messages.
@@ -1,213 +1,11 @@
1
1
  {
2
- "version": "1.24.0-alpha.0",
2
+ "version": "1.25.0-alpha.0",
3
3
  "package": "@mastra/memory",
4
- "exports": {
5
- "Extractor": {
6
- "types": "dist/processors/index.d.ts",
7
- "implementation": "dist/chunk-3UXBG7HA.js",
8
- "line": 316
9
- },
10
- "ModelByInputTokens": {
11
- "types": "dist/processors/index.d.ts",
12
- "implementation": "dist/chunk-3UXBG7HA.js",
13
- "line": 1354
14
- },
15
- "OBSERVER_SYSTEM_PROMPT": {
16
- "types": "dist/processors/index.d.ts",
17
- "implementation": "dist/chunk-3UXBG7HA.js"
18
- },
19
- "ObservationalMemory": {
20
- "types": "dist/processors/index.d.ts",
21
- "implementation": "dist/chunk-3UXBG7HA.js",
22
- "line": 28549
23
- },
24
- "ObservationalMemoryProcessor": {
25
- "types": "dist/processors/index.d.ts",
26
- "implementation": "dist/chunk-3UXBG7HA.js",
27
- "line": 31183
28
- },
29
- "TokenCounter": {
30
- "types": "dist/processors/index.d.ts",
31
- "implementation": "dist/chunk-3UXBG7HA.js",
32
- "line": 22331
33
- },
34
- "WorkingMemoryExtractor": {
35
- "types": "dist/processors/index.d.ts",
36
- "implementation": "dist/chunk-3UXBG7HA.js",
37
- "line": 22998
38
- },
39
- "buildObserverPrompt": {
40
- "types": "dist/processors/index.d.ts",
41
- "implementation": "dist/chunk-3UXBG7HA.js",
42
- "line": 4504
43
- },
44
- "buildObserverSystemPrompt": {
45
- "types": "dist/processors/index.d.ts",
46
- "implementation": "dist/chunk-3UXBG7HA.js",
47
- "line": 3771
48
- },
49
- "combineObservationGroupRanges": {
50
- "types": "dist/processors/index.d.ts",
51
- "implementation": "dist/chunk-3UXBG7HA.js",
52
- "line": 1446
53
- },
54
- "deriveObservationGroupProvenance": {
55
- "types": "dist/processors/index.d.ts",
56
- "implementation": "dist/chunk-3UXBG7HA.js",
57
- "line": 1480
58
- },
59
- "extractCurrentTask": {
60
- "types": "dist/processors/index.d.ts",
61
- "implementation": "dist/chunk-3UXBG7HA.js",
62
- "line": 4627
63
- },
64
- "formatMessagesForObserver": {
65
- "types": "dist/processors/index.d.ts",
66
- "implementation": "dist/chunk-3UXBG7HA.js",
67
- "line": 4226
68
- },
69
- "getObservationsAsOf": {
70
- "types": "dist/processors/index.d.ts",
71
- "implementation": "dist/chunk-3UXBG7HA.js",
72
- "line": 31405
73
- },
74
- "hasCurrentTaskSection": {
75
- "types": "dist/processors/index.d.ts",
76
- "implementation": "dist/chunk-3UXBG7HA.js",
77
- "line": 4615
78
- },
79
- "injectAnchorIds": {
80
- "types": "dist/processors/index.d.ts",
81
- "implementation": "dist/chunk-3UXBG7HA.js",
82
- "line": 3326
83
- },
84
- "optimizeObservationsForContext": {
85
- "types": "dist/processors/index.d.ts",
86
- "implementation": "dist/chunk-3UXBG7HA.js",
87
- "line": 4638
88
- },
89
- "parseAnchorId": {
90
- "types": "dist/processors/index.d.ts",
91
- "implementation": "dist/chunk-3UXBG7HA.js",
92
- "line": 3299
93
- },
94
- "parseObservationGroups": {
95
- "types": "dist/processors/index.d.ts",
96
- "implementation": "dist/chunk-3UXBG7HA.js",
97
- "line": 1415
98
- },
99
- "parseObserverOutput": {
100
- "types": "dist/processors/index.d.ts",
101
- "implementation": "dist/chunk-3UXBG7HA.js",
102
- "line": 4518
103
- },
104
- "reconcileObservationGroupsFromReflection": {
105
- "types": "dist/processors/index.d.ts",
106
- "implementation": "dist/chunk-3UXBG7HA.js",
107
- "line": 1504
108
- },
109
- "renderObservationGroupsForReflection": {
110
- "types": "dist/processors/index.d.ts",
111
- "implementation": "dist/chunk-3UXBG7HA.js",
112
- "line": 1460
113
- },
114
- "stripEphemeralAnchorIds": {
115
- "types": "dist/processors/index.d.ts",
116
- "implementation": "dist/chunk-3UXBG7HA.js",
117
- "line": 3356
118
- },
119
- "stripObservationGroups": {
120
- "types": "dist/processors/index.d.ts",
121
- "implementation": "dist/chunk-3UXBG7HA.js",
122
- "line": 1437
123
- },
124
- "summarizeConversation": {
125
- "types": "dist/processors/index.d.ts",
126
- "implementation": "dist/chunk-3UXBG7HA.js"
127
- },
128
- "wrapInObservationGroup": {
129
- "types": "dist/processors/index.d.ts",
130
- "implementation": "dist/chunk-3UXBG7HA.js",
131
- "line": 1408
132
- },
133
- "OBSERVATIONAL_MEMORY_DEFAULTS": {
134
- "types": "dist/processors/index.d.ts",
135
- "implementation": "dist/chunk-LSJJAJAF.js"
136
- },
137
- "OBSERVATION_CONTEXT_INSTRUCTIONS": {
138
- "types": "dist/processors/index.d.ts",
139
- "implementation": "dist/chunk-LSJJAJAF.js"
140
- },
141
- "OBSERVATION_CONTEXT_PROMPT": {
142
- "types": "dist/processors/index.d.ts",
143
- "implementation": "dist/chunk-LSJJAJAF.js"
144
- },
145
- "OBSERVATION_CONTINUATION_HINT": {
146
- "types": "dist/processors/index.d.ts",
147
- "implementation": "dist/chunk-LSJJAJAF.js"
148
- },
149
- "Memory": {
150
- "types": "dist/index.d.ts",
151
- "implementation": "dist/chunk-3UXBG7HA.js",
152
- "line": 24423
153
- },
154
- "MessageHistory": {
155
- "types": "dist/index.d.ts",
156
- "implementation": "dist/chunk-3UXBG7HA.js"
157
- },
158
- "SUMMARIZE_THREAD_DEFAULTS": {
159
- "types": "dist/index.d.ts",
160
- "implementation": "dist/chunk-3UXBG7HA.js"
161
- },
162
- "SemanticRecall": {
163
- "types": "dist/index.d.ts",
164
- "implementation": "dist/chunk-3UXBG7HA.js"
165
- },
166
- "WorkingMemory": {
167
- "types": "dist/index.d.ts",
168
- "implementation": "dist/chunk-3UXBG7HA.js"
169
- },
170
- "deepMergeWorkingMemory": {
171
- "types": "dist/index.d.ts",
172
- "implementation": "dist/chunk-3UXBG7HA.js",
173
- "line": 24062
174
- },
175
- "extractWorkingMemoryContent": {
176
- "types": "dist/index.d.ts",
177
- "implementation": "dist/chunk-3UXBG7HA.js",
178
- "line": 24378
179
- },
180
- "extractWorkingMemoryTags": {
181
- "types": "dist/index.d.ts",
182
- "implementation": "dist/chunk-3UXBG7HA.js",
183
- "line": 24346
184
- },
185
- "removeWorkingMemoryTags": {
186
- "types": "dist/index.d.ts",
187
- "implementation": "dist/chunk-3UXBG7HA.js",
188
- "line": 24359
189
- },
190
- "WORKING_MEMORY_STATE_ID": {
191
- "types": "dist/index.d.ts",
192
- "implementation": "dist/chunk-WCGXQIEN.js"
193
- },
194
- "WORKING_MEMORY_STATE_PROCESSOR_ID": {
195
- "types": "dist/index.d.ts",
196
- "implementation": "dist/chunk-WCGXQIEN.js"
197
- },
198
- "WorkingMemoryStateProcessor": {
199
- "types": "dist/index.d.ts",
200
- "implementation": "dist/chunk-WCGXQIEN.js",
201
- "line": 7
202
- }
203
- },
4
+ "exports": {},
204
5
  "modules": {
205
6
  "processors": {
206
7
  "index": "dist/processors/index.js",
207
- "chunks": [
208
- "chunk-3UXBG7HA.js",
209
- "chunk-LSJJAJAF.js"
210
- ]
8
+ "chunks": []
211
9
  }
212
10
  }
213
11
  }
@@ -6,7 +6,7 @@ Agents sometimes require the same [human-in-the-loop](https://mastra.ai/docs/wor
6
6
 
7
7
  ## When to use agent approval
8
8
 
9
- - **Destructive or irreversible actions** such as deleting records, sending emails, or processing payments.
9
+ - **Destructive or irreversible actions** such as deleting records or sending emails, or alternatively processing payments.
10
10
  - **Cost-heavy operations** like calling expensive third-party APIs where you want to verify arguments first.
11
11
  - **Conditional confirmation** where a tool starts executing and then discovers it needs the user to confirm or supply extra data before finishing.
12
12
 
@@ -60,7 +60,7 @@ Mastra offers two distinct mechanisms for pausing tool calls: **pre-execution ap
60
60
 
61
61
  Pre-execution approval pauses a tool call _before_ its `execute` function runs. The LLM still decides which tool to call and provides arguments, but `execute` doesn't run until you explicitly approve.
62
62
 
63
- Two flags control this, combined with OR logic. If _either_ is `true`, the call pauses:
63
+ The flags control this, combined with OR logic. If _either_ is `true`, the call pauses:
64
64
 
65
65
  | Flag | Where to set it | Scope |
66
66
  | --------------------------- | --------------------------------- | ------------------------------------------- |
@@ -92,7 +92,7 @@ for await (const chunk of stream.fullStream) {
92
92
 
93
93
  #### Conditional approval with a function
94
94
 
95
- Instead of a boolean, `requireToolApproval` accepts a function that decides per tool call. It receives the `toolName`, the `args` the model passed, the `requestContext`, and the `workspace`. Return `true` to require approval for that call, or `false` to allow it. This lets you gate approval dynamically for example, only for tools whose name matches a pattern:
95
+ Instead of a boolean, `requireToolApproval` accepts a function that decides per tool call. It receives the `toolName`, the `args` the model passed, the `requestContext`, and the `workspace`. Return `true` to require approval for that call, or `false` to allow it. This lets you gate approval at runtime, for example, only for tools whose name matches a pattern:
96
96
 
97
97
  ```typescript
98
98
  const stream = await agent.stream('Clean up old records', {
@@ -100,10 +100,82 @@ const stream = await agent.stream('Clean up old records', {
100
100
  })
101
101
  ```
102
102
 
103
- A tool's own `requireApproval` setting still takes precedence: if a tool defines its own approval rule, that rule decides for that tool and the function above doesn't override it. If the function throws, the call requires approval (fail-safe).
103
+ A tool's own `requireApproval` setting takes precedence over the function above. Its rule decides whether that tool needs approval. If the function throws, the call requires approval as a fail-safe.
104
104
 
105
105
  > **Note:** Function-based `requireToolApproval` is only available on regular `stream()` / `generate()` calls. Durable agents and stored agents persist their options, and a function can't be serialized, so they accept only a boolean. If you pass a function in those contexts it falls back to requiring approval for every tool call.
106
106
 
107
+ #### Bind approval to the exact tool arguments
108
+
109
+ For sensitive tools, bind the approval to the exact tool name and arguments that were shown to the reviewer. If those arguments drift before execution, the tool shouldn't run under the old approval.
110
+
111
+ The `tool-call-approval` chunk already includes `toolName`, `toolCallId`, and `args`. You can fingerprint those fields when the approval request is shown. The example below uses a simple JSON string as the fingerprint, but in production you should use a stable hash of the tool name and arguments:
112
+
113
+ ```typescript
114
+ import { Agent } from '@mastra/core/agent'
115
+
116
+ // For your production usecase, build a stable hash of the tool name and args
117
+ function actionFingerprint(toolName: string, args: unknown) {
118
+ const payload = JSON.stringify({ toolName, args })
119
+ return `fingerprint-${payload}`
120
+ }
121
+
122
+ const sensitiveTools = new Set(['issue_refund', 'delete_record'])
123
+ const approvedFingerprints = new Set<string>()
124
+
125
+ export const approvalBoundAgent = new Agent({
126
+ id: 'approval-bound-agent',
127
+ name: 'Approval Bound Agent',
128
+ model: 'openai/gpt-5.6-sol',
129
+ tools: { issueRefundTool, deleteRecordTool },
130
+ hooks: {
131
+ beforeToolCall: ({ toolName, input }) => {
132
+ if (!sensitiveTools.has(toolName)) return
133
+
134
+ const fingerprint = actionFingerprint(toolName, input)
135
+ if (!approvedFingerprints.delete(fingerprint)) {
136
+ return {
137
+ proceed: false,
138
+ output: `Tool call blocked: approval did not match ${toolName} arguments.`,
139
+ }
140
+ }
141
+ },
142
+ },
143
+ })
144
+ ```
145
+
146
+ ```typescript
147
+ const stream = await approvalBoundAgent.stream('Refund order ord-1042', {
148
+ requireToolApproval: ({ toolName }) => sensitiveTools.has(toolName),
149
+ })
150
+
151
+ async function consumeApprovalStream(currentStream: typeof stream) {
152
+ for await (const chunk of currentStream.fullStream) {
153
+ if (chunk.type === 'tool-call-approval') {
154
+ const { toolName, toolCallId, args } = chunk.payload
155
+ const fingerprint = actionFingerprint(toolName, args)
156
+
157
+ // Present toolName, args, and fingerprint to your approval UI.
158
+ const approved = await showApprovalDialog({ toolName, args, fingerprint })
159
+
160
+ const nextStream = approved
161
+ ? await approveReviewedToolCall(currentStream.runId, toolCallId, fingerprint)
162
+ : await approvalBoundAgent.declineToolCall({ runId: currentStream.runId, toolCallId })
163
+
164
+ await consumeApprovalStream(nextStream)
165
+ }
166
+ }
167
+ }
168
+
169
+ async function approveReviewedToolCall(runId: string, toolCallId: string, fingerprint: string) {
170
+ approvedFingerprints.add(fingerprint)
171
+ return approvalBoundAgent.approveToolCall({ runId, toolCallId })
172
+ }
173
+
174
+ await consumeApprovalStream(stream)
175
+ ```
176
+
177
+ In production, store the approved fingerprint in durable storage scoped to the user, run, tool call, and policy version. The `Set` above is intentionally small so the boundary is easy to see: the approval is consumed once, and only for the same canonical tool arguments that were reviewed.
178
+
107
179
  ### Runtime suspension with `suspend()`
108
180
 
109
181
  A tool can also pause _during_ its `execute` function by calling `suspend()`. This is useful when the tool starts running and then discovers it needs additional user input or confirmation before it can finish.
@@ -133,7 +205,7 @@ const weatherTool = createTool({
133
205
  })
134
206
  ```
135
207
 
136
- > **Note:** `suspend()` doesn't throw return immediately after calling it (e.g. `return await suspend({ ... })`). Code after `await suspend(...)` still runs before the tool pauses.
208
+ > **Note:** `suspend()` doesn't throw, return immediately after calling it (e.g. `return await suspend({ ... })`). Code after `await suspend(...)` still runs before the tool pauses.
137
209
 
138
210
  ## Tool approval with `generate()`
139
211
 
@@ -172,11 +244,11 @@ if (output.finishReason === 'suspended') {
172
244
  | Decline method | `declineToolCall({ runId })` | `declineToolCallGenerate({ runId, toolCallId })` |
173
245
  | Result | Stream to iterate | Full output object |
174
246
 
175
- > **Note:** `toolCallId` is optional on all four methods. Pass it when multiple tool calls may be pending at the same time (common in supervisor agents). When omitted, the agent resumes the most recent suspended tool call.
247
+ > **Note:** `toolCallId` is optional on all four methods. Pass it when multiple tool calls may be pending (common in supervisor agents). When omitted, the agent resumes the most recent suspended tool call.
176
248
 
177
249
  ## Tool-level approval
178
250
 
179
- Instead of pausing every tool call at the agent level, you can mark individual tools as requiring approval. This gives you granular control: only specific tools pause, while others execute immediately.
251
+ Instead of pausing every tool call at the agent level, you can mark individual tools as requiring approval. You get fine-grained control: only specific tools pause, while others execute immediately.
180
252
 
181
253
  ### Approval using `requireApproval`
182
254
 
@@ -303,7 +375,9 @@ const agent = new Agent({
303
375
  })
304
376
  ```
305
377
 
306
- When enabled, the agent detects suspended tools from message history on the next user message, extracts `resumeData` based on the tool's `resumeSchema`, and automatically resumes the tool. The following example shows a complete conversational flow:
378
+ When enabled, the agent detects suspended tools from message history on the next user message. It extracts `resumeData` based on the tool's `resumeSchema`, then automatically resumes the tool.
379
+
380
+ The following example shows a complete conversational flow:
307
381
 
308
382
  ```typescript
309
383
  import { createTool } from '@mastra/core/tools'
@@ -386,7 +460,7 @@ Both approaches work with the same tool definitions. Automatic resumption trigge
386
460
 
387
461
  ## Resuming after a restart
388
462
 
389
- The examples above hold on to `stream.runId` between suspension and approval. That works while the process stays alive, but in production the approval often arrives later after a page refresh, a server restart, or on a different server instance behind a load balancer.
463
+ The examples above hold on to `stream.runId` between suspension and approval. That works while the process stays alive, but in production the approval often arrives later, after a page refresh, a server restart, or on a different server instance behind a load balancer.
390
464
 
391
465
  Use [`listSuspendedRuns()`](https://mastra.ai/reference/agents/listSuspendedRuns) to rediscover the pending run for a conversation from storage:
392
466
 
@@ -414,7 +488,7 @@ if (run && toolCall) {
414
488
  }
415
489
  ```
416
490
 
417
- Each returned run includes the suspended tool calls (`toolCallId`, `toolName`, `args`, and `requiresApproval`). Approval suspensions (`requiresApproval: true`) are answered with `approveToolCall()` / `declineToolCall()`, while `suspend()`-based suspensions carry their `suspendPayload` and expect `resumeStream()` with resume data so you can rebuild the right UI for either flow without keeping any state in memory.
491
+ Each returned run includes the suspended tool calls (`toolCallId`, `toolName`, `args`, and `requiresApproval`). Approval suspensions (`requiresApproval: true`) are answered with `approveToolCall()` / `declineToolCall()`, while `suspend()`-based suspensions carry their `suspendPayload` and expect `resumeStream()` with resume data, so you can rebuild the right UI for either flow without keeping any state in memory.
418
492
 
419
493
  `sendToolApproval()` uses the same storage-backed discovery automatically: when no active run is found in memory for the thread, it looks up the suspended run in storage before failing. If several suspended runs match the thread, pass a `toolCallId` to disambiguate.
420
494
 
@@ -477,7 +551,7 @@ const supervisorAgent = new Agent({
477
551
  name: 'Supervisor Agent',
478
552
  instructions: `You coordinate data retrieval tasks.
479
553
  Delegate to data-agent for user lookups.`,
480
- model: 'openai/gpt-5.5',
554
+ model: 'openai/gpt-5.6-sol',
481
555
  agents: { dataAgent },
482
556
  memory: new Memory(),
483
557
  })
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Agent networks
4
4
 
5
- > **Deprecated — Use supervisor agents:** Agent networks are deprecated and will be removed in a future major release. [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents) using `agent.stream()` or `agent.generate()` are now the recommended approach. It provides the same multi-agent coordination with better control, a simpler API, and easier debugging.
5
+ > **Deprecated:** Agent networks are deprecated and will be removed in a future major release. [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents) using `agent.stream()` or `agent.generate()` are now the recommended approach. It provides the same multi-agent coordination with better control, a simpler API, and easier debugging.
6
6
  >
7
7
  > See the [migration guide](https://mastra.ai/guides/migrations/network-to-supervisor) to upgrade.
8
8
 
@@ -29,7 +29,7 @@ export const routingAgent = new Agent({
29
29
  name: 'Routing Agent',
30
30
  instructions: `
31
31
  You are a network of writers and researchers. The user will ask you to research a topic. Always respond with a complete report—no bullet points. Write in full paragraphs, like a blog post. Do not answer with incomplete or uncertain information.`,
32
- model: 'openai/gpt-5.5',
32
+ model: 'openai/gpt-5.6-sol',
33
33
  agents: {
34
34
  researchAgent,
35
35
  writingAgent,
@@ -8,7 +8,7 @@ A supervisor agent coordinates multiple subagents using [`Agent.stream()`](https
8
8
 
9
9
  ## When to use supervisor agents
10
10
 
11
- Use supervisor agents when a task requires multiple agents with different specializations to work together. The supervisor handles delegation decisions, context passing, and result synthesis.
11
+ Use supervisor agents when a task requires multiple agents with different specializations to work together. The supervisor handles delegation decisions and context passing, plus result synthesis.
12
12
 
13
13
  Common use cases:
14
14
 
@@ -43,7 +43,7 @@ const supervisor = new Agent({
43
43
  id: 'supervisor',
44
44
  instructions: `You coordinate research and writing using specialized agents.
45
45
  Delegate to research-agent for facts, then writing-agent for content.`,
46
- model: 'openai/gpt-5.5',
46
+ model: 'openai/gpt-5.6-sol',
47
47
  agents: { researchAgent, writingAgent },
48
48
  memory: new Memory({
49
49
  storage: new LibSQLStore({ id: 'storage', url: 'file:mastra.db' }),
@@ -112,7 +112,7 @@ The `context` object includes:
112
112
 
113
113
  ### `onDelegationComplete`
114
114
 
115
- Called after a delegation finishes. Use it to inspect results, provide feedback, or stop execution:
115
+ Called after a delegation finishes. Use it to inspect results or provide feedback, or alternatively stop execution:
116
116
 
117
117
  - `context.bail()`: Stop the supervisor loop immediately
118
118
  - Return `{ feedback: '...' }`: Add feedback that gets saved to the supervisor's memory and is visible to subsequent iterations
@@ -147,7 +147,7 @@ The `context` object includes:
147
147
 
148
148
  ## Message filtering
149
149
 
150
- By default, subagents receive the full conversation context from the supervisor. Use `messageFilter` to control what messages are shared for example, to remove sensitive data or limit context size.
150
+ By default, subagents receive the full conversation context from the supervisor. Use `messageFilter` to control what messages are shared, for example, to remove sensitive data or limit context size.
151
151
 
152
152
  ```typescript
153
153
  const stream = await supervisor.stream('Research AI trends', {
@@ -173,7 +173,9 @@ The callback receives `messages` (the full conversation history), `primitiveId`
173
173
 
174
174
  When a subagent completes, the supervisor model receives the subagent's text response in later iterations. Nested tool calls and subagent metadata, such as thread and resource IDs, aren't added to the supervisor model context.
175
175
 
176
- Application code and UI integrations can still inspect the raw delegation result, including `subAgentToolResults`, from the tool result payload. This keeps debugging and display data available without sending nested tool arguments or outputs back into the supervisor's next model call.
176
+ Application code and UI integrations can still inspect `subAgentToolResults` and the rest of the raw delegation result in the tool result payload.
177
+
178
+ This keeps debugging and display data available without sending nested tool arguments or outputs back into the supervisor's next model call.
177
179
 
178
180
  Set `includeSubAgentToolResultsInModelContext` to include the full subagent result, including nested tool results and subagent metadata, in the supervisor model context.
179
181
 
@@ -187,7 +189,7 @@ await supervisor.generate('Research AI trends', {
187
189
 
188
190
  ## Iteration monitoring
189
191
 
190
- `onIterationComplete` is called after each iteration of the supervisor loop. Use it to log progress, inject feedback, or stop execution early.
192
+ `onIterationComplete` is called after each iteration of the supervisor loop. Use it to log progress or inject feedback, or alternatively stop execution early.
191
193
 
192
194
  ```typescript
193
195
  const stream = await supervisor.stream('Research AI trends', {
@@ -214,7 +216,7 @@ const stream = await supervisor.stream('Research AI trends', {
214
216
  })
215
217
  ```
216
218
 
217
- Return `{ continue: true }` to keep iterating, or `{ continue: false }` to stop. Include optional `feedback` to inject guidance into the conversation. When `feedback` is combined with `continue: false`, the model may get one final turn to produce a text response incorporating the feedback, but only if the current iteration is still active (e.g., after tool calls) otherwise no extra turn is granted.
219
+ Return `{ continue: true }` to keep iterating, or `{ continue: false }` to stop. Include optional `feedback` to inject guidance into the conversation. When `feedback` is combined with `continue: false`, the model may get one final turn to produce a text response incorporating the feedback, but only if the current iteration is still active (e.g., after tool calls), otherwise no extra turn is granted.
218
220
 
219
221
  ## Memory isolation
220
222
 
@@ -226,7 +228,7 @@ How it works:
226
228
  2. **Scoped memory saves**: Only the delegation prompt and the subagent's response are saved to the subagent's memory
227
229
  3. **Fresh thread per invocation**: Each delegation uses a unique thread ID, ensuring clean separation
228
230
 
229
- This ensures subagents have the context they need without cluttering their memory with the entire supervisor conversation. Visit [memory in multi-agent systems](https://mastra.ai/docs/memory/overview) for more details.
231
+ As a result, subagents have the context they need without cluttering their memory with the entire supervisor conversation. Visit [memory in multi-agent systems](https://mastra.ai/docs/memory/overview) for more details.
230
232
 
231
233
  ## Tool approval propagation
232
234
 
@@ -309,7 +311,7 @@ const stream = await supervisor.stream('Research AI in education', {
309
311
 
310
312
  The built-in rubric scorer lets you define what "correct" looks like as a checklist and have the agent self-evaluate and iterate until every criterion is satisfied or `maxSteps` is reached.
311
313
 
312
- It works as an **LLM-as-judge** scorer: a separate grader model reviews the agent's output against the rubric after each iteration. If every required criterion passes, the loop ends. If anything falls short, per-criterion feedback is injected back into the conversation and the agent tries again.
314
+ It works as an **LLM-as-judge** scorer. After each iteration, a separate grader model reviews the agent's output against the rubric. The loop ends when every required criterion passes. A failed criterion adds its feedback to the conversation so the agent can try again.
313
315
 
314
316
  This is most effective for tasks with clear, verifiable success criteria. You can use it like so:
315
317
 
@@ -320,7 +322,7 @@ import { createRubricScorer } from '@mastra/evals/scorers/prebuilt'
320
322
  const supervisor = new Agent({
321
323
  id: 'supervisor',
322
324
  instructions: 'You coordinate research and writing using specialized agents.',
323
- model: 'openai/gpt-5.5',
325
+ model: 'openai/gpt-5.6-sol',
324
326
  agents: { researchAgent, writingAgent },
325
327
  })
326
328
 
@@ -345,9 +347,13 @@ For full API details, see the [rubric scorer reference](https://mastra.ai/refere
345
347
 
346
348
  ## Writing effective instructions
347
349
 
348
- Clear instructions are essential for effective delegation. Your supervisor's `instructions` should specify available resources, when to use each one, how to coordinate them, and success criteria.
350
+ Clear instructions are essential for effective delegation.
351
+
352
+ Your supervisor's `instructions` should specify the available resources and when to use each one. They should also define coordination behavior and success criteria.
353
+
354
+ Each subagent should have a clear `description` that explains its purpose and return format, including when the supervisor should use it.
349
355
 
350
- Each subagent should have a clear `description` that explains what it does, what format it returns, and when to use it. The supervisor uses these descriptions to make delegation decisions.
356
+ The supervisor uses these descriptions to make delegation decisions.
351
357
 
352
358
  ```typescript
353
359
  const supervisor = new Agent({
@@ -380,7 +386,7 @@ Enable the [backgroundTasks manager](https://mastra.ai/reference/configuration)
380
386
  const supervisor = new Agent({
381
387
  id: 'supervisor',
382
388
  instructions: 'Coordinate research and writing using the available agents.',
383
- model: 'openai/gpt-5.5',
389
+ model: 'openai/gpt-5.6-sol',
384
390
  agents: { researchAgent, writingAgent },
385
391
  backgroundTasks: {
386
392
  tools: {