@mastra/memory 1.41.2-alpha.2 → 1.41.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/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +94 -94
- package/dist/docs/references/docs-harness-background-tasks.md +53 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/processors/index.cjs +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/{src-Xhctgeae.js → src-BkElV36S.js} +762 -269
- package/dist/src-BkElV36S.js.map +1 -0
- package/dist/{src-BLniLryu.cjs → src-IZtKjicq.cjs} +762 -268
- package/dist/src-IZtKjicq.cjs.map +1 -0
- package/package.json +8 -8
- package/dist/src-BLniLryu.cjs.map +0 -1
- package/dist/src-Xhctgeae.js.map +0 -1
- /package/dist/_types/{@internal_ai-sdk-v4@0.0.96 → @internal_ai-sdk-v4@0.0.97}/dist/index.d.ts +0 -0
- /package/dist/_types/{@internal_ai-sdk-v4@0.0.96 → @internal_ai-sdk-v4@0.0.97}/package.json +0 -0
package/dist/docs/SKILL.md
CHANGED
|
@@ -1,243 +1,243 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.41.2
|
|
2
|
+
"version": "1.41.2",
|
|
3
3
|
"package": "@mastra/memory",
|
|
4
4
|
"exports": {
|
|
5
5
|
"AUTO_MODEL_BY_PROVIDER": {
|
|
6
6
|
"types": "dist/processors/observational-memory/auto-model.d.ts",
|
|
7
|
-
"implementation": "dist/src-
|
|
8
|
-
"line":
|
|
7
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
8
|
+
"line": 32706
|
|
9
9
|
},
|
|
10
10
|
"Extractor": {
|
|
11
11
|
"types": "dist/processors/observational-memory/extractor.d.ts",
|
|
12
|
-
"implementation": "dist/src-
|
|
13
|
-
"line":
|
|
12
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
13
|
+
"line": 24432
|
|
14
14
|
},
|
|
15
15
|
"ModelByInputTokens": {
|
|
16
16
|
"types": "dist/processors/observational-memory/model-by-input-tokens.d.ts",
|
|
17
|
-
"implementation": "dist/src-
|
|
18
|
-
"line":
|
|
17
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
18
|
+
"line": 32489
|
|
19
19
|
},
|
|
20
20
|
"OBSERVATIONAL_MEMORY_DEFAULTS": {
|
|
21
21
|
"types": "dist/processors/observational-memory/constants.d.ts",
|
|
22
|
-
"implementation": "dist/src-
|
|
23
|
-
"line":
|
|
22
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
23
|
+
"line": 24168
|
|
24
24
|
},
|
|
25
25
|
"OBSERVATION_CONTEXT_INSTRUCTIONS": {
|
|
26
26
|
"types": "dist/processors/observational-memory/constants.d.ts",
|
|
27
|
-
"implementation": "dist/src-
|
|
28
|
-
"line":
|
|
27
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
28
|
+
"line": 24229
|
|
29
29
|
},
|
|
30
30
|
"OBSERVATION_CONTEXT_PROMPT": {
|
|
31
31
|
"types": "dist/processors/observational-memory/constants.d.ts",
|
|
32
|
-
"implementation": "dist/src-
|
|
33
|
-
"line":
|
|
32
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
33
|
+
"line": 24211
|
|
34
34
|
},
|
|
35
35
|
"OBSERVATION_CONTEXT_PROMPT_THREAD": {
|
|
36
36
|
"types": "dist/processors/observational-memory/constants.d.ts",
|
|
37
|
-
"implementation": "dist/src-
|
|
38
|
-
"line":
|
|
37
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
38
|
+
"line": 24216
|
|
39
39
|
},
|
|
40
40
|
"OBSERVATION_CONTINUATION_HINT": {
|
|
41
41
|
"types": "dist/processors/observational-memory/constants.d.ts",
|
|
42
|
-
"implementation": "dist/src-
|
|
43
|
-
"line":
|
|
42
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
43
|
+
"line": 24198
|
|
44
44
|
},
|
|
45
45
|
"OBSERVER_SYSTEM_PROMPT": {
|
|
46
46
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
47
|
-
"implementation": "dist/src-
|
|
48
|
-
"line":
|
|
47
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
48
|
+
"line": 26793
|
|
49
49
|
},
|
|
50
50
|
"ObservationalMemory": {
|
|
51
51
|
"types": "dist/processors/observational-memory/observational-memory.d.ts",
|
|
52
|
-
"implementation": "dist/src-
|
|
53
|
-
"line":
|
|
52
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
53
|
+
"line": 37514
|
|
54
54
|
},
|
|
55
55
|
"ObservationalMemoryProcessor": {
|
|
56
56
|
"types": "dist/processors/observational-memory/processor.d.ts",
|
|
57
|
-
"implementation": "dist/src-
|
|
58
|
-
"line":
|
|
57
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
58
|
+
"line": 40262
|
|
59
59
|
},
|
|
60
60
|
"TokenCounter": {
|
|
61
61
|
"types": "dist/processors/observational-memory/token-counter.d.ts",
|
|
62
|
-
"implementation": "dist/src-
|
|
63
|
-
"line":
|
|
62
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
63
|
+
"line": 29311
|
|
64
64
|
},
|
|
65
65
|
"WorkingMemoryExtractor": {
|
|
66
66
|
"types": "dist/processors/observational-memory/working-memory-extractor.d.ts",
|
|
67
|
-
"implementation": "dist/src-
|
|
68
|
-
"line":
|
|
67
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
68
|
+
"line": 30330
|
|
69
69
|
},
|
|
70
70
|
"buildObserverPrompt": {
|
|
71
71
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
72
|
-
"implementation": "dist/src-
|
|
73
|
-
"line":
|
|
72
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
73
|
+
"line": 27477
|
|
74
74
|
},
|
|
75
75
|
"buildObserverSystemPrompt": {
|
|
76
76
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
77
|
-
"implementation": "dist/src-
|
|
78
|
-
"line":
|
|
77
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
78
|
+
"line": 26687
|
|
79
79
|
},
|
|
80
80
|
"combineObservationGroupRanges": {
|
|
81
81
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
82
|
-
"implementation": "dist/src-
|
|
83
|
-
"line":
|
|
82
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
83
|
+
"line": 30809
|
|
84
84
|
},
|
|
85
85
|
"deriveObservationGroupProvenance": {
|
|
86
86
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
87
|
-
"implementation": "dist/src-
|
|
88
|
-
"line":
|
|
87
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
88
|
+
"line": 30853
|
|
89
89
|
},
|
|
90
90
|
"extractCurrentTask": {
|
|
91
91
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
92
|
-
"implementation": "dist/src-
|
|
93
|
-
"line":
|
|
92
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
93
|
+
"line": 27790
|
|
94
94
|
},
|
|
95
95
|
"formatMessagesForObserver": {
|
|
96
96
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
97
|
-
"implementation": "dist/src-
|
|
98
|
-
"line":
|
|
97
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
98
|
+
"line": 27228
|
|
99
99
|
},
|
|
100
100
|
"getObservationContextPrompt": {
|
|
101
101
|
"types": "dist/processors/observational-memory/constants.d.ts",
|
|
102
|
-
"implementation": "dist/src-
|
|
103
|
-
"line":
|
|
102
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
103
|
+
"line": 24222
|
|
104
104
|
},
|
|
105
105
|
"getObservationsAsOf": {
|
|
106
106
|
"types": "dist/processors/observational-memory/observation-utils.d.ts",
|
|
107
|
-
"implementation": "dist/src-
|
|
108
|
-
"line":
|
|
107
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
108
|
+
"line": 40602
|
|
109
109
|
},
|
|
110
110
|
"hasCurrentTaskSection": {
|
|
111
111
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
112
|
-
"implementation": "dist/src-
|
|
113
|
-
"line":
|
|
112
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
113
|
+
"line": 27778
|
|
114
114
|
},
|
|
115
115
|
"injectAnchorIds": {
|
|
116
116
|
"types": "dist/processors/observational-memory/anchor-ids.d.ts",
|
|
117
|
-
"implementation": "dist/src-
|
|
118
|
-
"line":
|
|
117
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
118
|
+
"line": 25409
|
|
119
119
|
},
|
|
120
120
|
"optimizeObservationsForContext": {
|
|
121
121
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
122
|
-
"implementation": "dist/src-
|
|
123
|
-
"line":
|
|
122
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
123
|
+
"line": 27811
|
|
124
124
|
},
|
|
125
125
|
"parseAnchorId": {
|
|
126
126
|
"types": "dist/processors/observational-memory/anchor-ids.d.ts",
|
|
127
|
-
"implementation": "dist/src-
|
|
128
|
-
"line":
|
|
127
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
128
|
+
"line": 25393
|
|
129
129
|
},
|
|
130
130
|
"parseObservationGroups": {
|
|
131
131
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
132
|
-
"implementation": "dist/src-
|
|
133
|
-
"line":
|
|
132
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
133
|
+
"line": 30764
|
|
134
134
|
},
|
|
135
135
|
"parseObserverOutput": {
|
|
136
136
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
137
|
-
"implementation": "dist/src-
|
|
138
|
-
"line":
|
|
137
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
138
|
+
"line": 27488
|
|
139
139
|
},
|
|
140
140
|
"reconcileObservationGroupsFromReflection": {
|
|
141
141
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
142
|
-
"implementation": "dist/src-
|
|
143
|
-
"line":
|
|
142
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
143
|
+
"line": 30872
|
|
144
144
|
},
|
|
145
145
|
"renderObservationGroupsForReflection": {
|
|
146
146
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
147
|
-
"implementation": "dist/src-
|
|
148
|
-
"line":
|
|
147
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
148
|
+
"line": 30838
|
|
149
149
|
},
|
|
150
150
|
"resolveAutoModelId": {
|
|
151
151
|
"types": "dist/processors/observational-memory/auto-model.d.ts",
|
|
152
|
-
"implementation": "dist/src-
|
|
153
|
-
"line":
|
|
152
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
153
|
+
"line": 32726
|
|
154
154
|
},
|
|
155
155
|
"stripEphemeralAnchorIds": {
|
|
156
156
|
"types": "dist/processors/observational-memory/anchor-ids.d.ts",
|
|
157
|
-
"implementation": "dist/src-
|
|
158
|
-
"line":
|
|
157
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
158
|
+
"line": 25432
|
|
159
159
|
},
|
|
160
160
|
"stripObservationGroups": {
|
|
161
161
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
162
|
-
"implementation": "dist/src-
|
|
163
|
-
"line":
|
|
162
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
163
|
+
"line": 30781
|
|
164
164
|
},
|
|
165
165
|
"summarizeConversation": {
|
|
166
166
|
"types": "dist/processors/observational-memory/summarize.d.ts",
|
|
167
|
-
"implementation": "dist/src-
|
|
168
|
-
"line":
|
|
167
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
168
|
+
"line": 29942
|
|
169
169
|
},
|
|
170
170
|
"wrapInObservationGroup": {
|
|
171
171
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
172
|
-
"implementation": "dist/src-
|
|
173
|
-
"line":
|
|
172
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
173
|
+
"line": 30735
|
|
174
174
|
},
|
|
175
175
|
"KnowledgeSemanticIndexCoordinator": {
|
|
176
176
|
"types": "dist/removed-subconscious.d.ts",
|
|
177
|
-
"implementation": "dist/src-
|
|
178
|
-
"line":
|
|
177
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
178
|
+
"line": 30377
|
|
179
179
|
},
|
|
180
180
|
"Memory": {
|
|
181
181
|
"types": "dist/index.d.ts",
|
|
182
|
-
"implementation": "dist/src-
|
|
183
|
-
"line":
|
|
182
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
183
|
+
"line": 40813
|
|
184
184
|
},
|
|
185
185
|
"SUMMARIZE_THREAD_DEFAULTS": {
|
|
186
186
|
"types": "dist/processors/observational-memory/summarize.d.ts",
|
|
187
|
-
"implementation": "dist/src-
|
|
188
|
-
"line":
|
|
187
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
188
|
+
"line": 29898
|
|
189
189
|
},
|
|
190
190
|
"StaleKnowledgeSemanticIndexError": {
|
|
191
191
|
"types": "dist/removed-subconscious.d.ts",
|
|
192
|
-
"implementation": "dist/src-
|
|
193
|
-
"line":
|
|
192
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
193
|
+
"line": 30383
|
|
194
194
|
},
|
|
195
195
|
"Subconscious": {
|
|
196
196
|
"types": "dist/removed-subconscious.d.ts",
|
|
197
|
-
"implementation": "dist/src-
|
|
198
|
-
"line":
|
|
197
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
198
|
+
"line": 30371
|
|
199
199
|
},
|
|
200
200
|
"WORKING_MEMORY_STATE_ID": {
|
|
201
201
|
"types": "dist/processors/working-memory-state/processor.d.ts",
|
|
202
|
-
"implementation": "dist/src-
|
|
203
|
-
"line":
|
|
202
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
203
|
+
"line": 32535
|
|
204
204
|
},
|
|
205
205
|
"WORKING_MEMORY_STATE_PROCESSOR_ID": {
|
|
206
206
|
"types": "dist/processors/working-memory-state/processor.d.ts",
|
|
207
|
-
"implementation": "dist/src-
|
|
208
|
-
"line":
|
|
207
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
208
|
+
"line": 32536
|
|
209
209
|
},
|
|
210
210
|
"WorkingMemoryStateProcessor": {
|
|
211
211
|
"types": "dist/processors/working-memory-state/processor.d.ts",
|
|
212
|
-
"implementation": "dist/src-
|
|
213
|
-
"line":
|
|
212
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
213
|
+
"line": 32537
|
|
214
214
|
},
|
|
215
215
|
"deepMergeWorkingMemory": {
|
|
216
216
|
"types": "dist/tools/working-memory.d.ts",
|
|
217
|
-
"implementation": "dist/src-
|
|
218
|
-
"line":
|
|
217
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
218
|
+
"line": 30021
|
|
219
219
|
},
|
|
220
220
|
"extractWorkingMemoryContent": {
|
|
221
221
|
"types": "dist/index.d.ts",
|
|
222
|
-
"implementation": "dist/src-
|
|
223
|
-
"line":
|
|
222
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
223
|
+
"line": 40667
|
|
224
224
|
},
|
|
225
225
|
"extractWorkingMemoryTags": {
|
|
226
226
|
"types": "dist/index.d.ts",
|
|
227
|
-
"implementation": "dist/src-
|
|
228
|
-
"line":
|
|
227
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
228
|
+
"line": 40635
|
|
229
229
|
},
|
|
230
230
|
"removeWorkingMemoryTags": {
|
|
231
231
|
"types": "dist/index.d.ts",
|
|
232
|
-
"implementation": "dist/src-
|
|
233
|
-
"line":
|
|
232
|
+
"implementation": "dist/src-BkElV36S.js",
|
|
233
|
+
"line": 40648
|
|
234
234
|
}
|
|
235
235
|
},
|
|
236
236
|
"modules": {
|
|
237
237
|
"processors": {
|
|
238
238
|
"index": "dist/processors/index.js",
|
|
239
239
|
"chunks": [
|
|
240
|
-
"src-
|
|
240
|
+
"src-BkElV36S.js"
|
|
241
241
|
]
|
|
242
242
|
}
|
|
243
243
|
}
|
|
@@ -483,6 +483,59 @@ const { tasks, total } = await mastra.backgroundTaskManager?.listTasks({
|
|
|
483
483
|
|
|
484
484
|
These read from storage rather than the pubsub stream, so they're suitable for paginated lists and detail views.
|
|
485
485
|
|
|
486
|
+
## Execution ownership and recovery
|
|
487
|
+
|
|
488
|
+
Every Mastra process with background tasks enabled runs its own manager. You can run several processes or replicas against the same storage backend. The managers coordinate through an execution lease stored on each task record. A lease is a time-limited claim on a task that its owner must keep renewing. When the owner stops renewing it, another manager can take the task over.
|
|
489
|
+
|
|
490
|
+
### Deployment requirements
|
|
491
|
+
|
|
492
|
+
- Every manager must use the same storage backend, and its `updateTask` must apply the write conditions atomically. Mastra's storage adapters do. In-memory storage is only shared within one process.
|
|
493
|
+
- `leaseExpiresAt` is a timestamp written with the owner's clock and compared against the clock of the manager that reads it. Keep server clocks synchronized, for example with Network Time Protocol (NTP), to well under `leaseDurationMs`. If a reader's clock runs ahead by more than the lease, it can recover a task whose owner is still alive. If it runs behind, recovery is delayed. The startup scan recovers a task as soon as its lease has expired by the reader's clock. Follow-up scans wait about one second past the expiry to absorb small differences.
|
|
494
|
+
- A longer [`leaseDurationMs`](https://mastra.ai/reference/configuration) delays recovery after a crash. A shorter one adds storage writes and makes it more likely that a stalled owner loses its lease while still running. The default is 30 seconds and the minimum is 3000 ms.
|
|
495
|
+
|
|
496
|
+
### Lease guarantees and repeated tool calls
|
|
497
|
+
|
|
498
|
+
The lease guarantees that at most one manager can commit a task's state at a time. The tool itself can still run more than once when:
|
|
499
|
+
|
|
500
|
+
- The owner stalls, for example because its event loop is blocked or it can't reach storage, for longer than the lease. Another manager recovers the task while the first execution is still running.
|
|
501
|
+
- The owner crashes after the tool has acted on an external system but before the result is saved. The recovered task runs the tool again.
|
|
502
|
+
- A durable agent restarts the task with `restart()` while the previous execution is still running.
|
|
503
|
+
|
|
504
|
+
Make tools that change external systems safe to repeat, for example by passing the tool call ID as an idempotency key. See [make tools safe to repeat](https://mastra.ai/docs/harness/durable-agents).
|
|
505
|
+
|
|
506
|
+
A resume interrupted by shutdown is the one exception to the single-committer guarantee. It restores the previous `suspended` state with a write that checks only that the task is `running`, and that write can overwrite a manager that took the task over in the meantime.
|
|
507
|
+
|
|
508
|
+
### Claim and renew a lease
|
|
509
|
+
|
|
510
|
+
Each manager gets a random owner ID when it's created. A restarted process gets a new ID and counts as a new owner.
|
|
511
|
+
|
|
512
|
+
Before a manager runs a task, it claims the task with a conditional write. The write sets the status to `running`, records the manager's `ownerId`, and sets `leaseExpiresAt` to the current time plus `leaseDurationMs`. It only applies if the task still has the status, owner, and lease that the manager last read. When two managers race for the same task, one claim succeeds and the other manager skips the task without running it.
|
|
513
|
+
|
|
514
|
+
While the task runs, the owner renews the lease every `leaseDurationMs / 3`, with a minimum of one second. Each renewal is conditional on the task still being `running` under the same owner. The task's final writes, such as `completed`, `failed`, `timed_out`, or `suspended`, carry the same condition, so a manager that lost the task can't overwrite the result of the manager that replaced it.
|
|
515
|
+
|
|
516
|
+
The owner stops renewing when the task completes, fails, or suspends. On shutdown, the manager releases the leases it still holds, so other managers can recover those tasks without waiting for the lease to expire. A lease that isn't released, for example because the process crashed, expires on its own.
|
|
517
|
+
|
|
518
|
+
### Recover a task from a dead owner
|
|
519
|
+
|
|
520
|
+
A manager treats a `running` task as abandoned only after its lease expires.
|
|
521
|
+
|
|
522
|
+
When `recoverStaleTasksOnStart` is `true`, the default, each manager that runs tasks scans for abandoned tasks on startup. If the scan finds a lease that hasn't expired yet, the manager scans again shortly after that lease expires, and repeats until no live lease is left. A task that a manager starts after that and then abandons waits for the next startup scan. For each task the scan recovers:
|
|
523
|
+
|
|
524
|
+
- If the task has `maxRetries` above `0`, it returns to `pending` and is dispatched again.
|
|
525
|
+
- Otherwise, it fails with `Worker process terminated before task completed`.
|
|
526
|
+
|
|
527
|
+
The recovery write is conditional on the owner and lease that the scan read, so only one manager recovers each task.
|
|
528
|
+
|
|
529
|
+
If the pubsub redelivers the unacknowledged dispatch of an abandoned task, the redelivery claims the task once its lease expires and runs it again, even when `maxRetries` is `0`.
|
|
530
|
+
|
|
531
|
+
The manager that runs the recovered task needs an executor for it. See the known limitations under [non-agent owners](#non-agent-owners).
|
|
532
|
+
|
|
533
|
+
`manager.restart(taskId)` is an explicit takeover. It claims a `running` task even while another manager holds a live lease. Durable agents use it when a redelivered step finds the task for its tool call. The task's results then reach the new stream. A restart on the manager that already runs the task doesn't stop the earlier execution. Both executions share an owner ID, and the earlier one can commit first.
|
|
534
|
+
|
|
535
|
+
### Stop work after losing a lease
|
|
536
|
+
|
|
537
|
+
When a lease renewal fails because the task is now owned by another manager or was cancelled, the previous owner aborts the `abortSignal` passed to the tool. After a takeover, `abortSignal.reason` is an error with the message `Background task execution ownership was taken over by another worker`. The abort is best effort. If the manager can't read the task at that point, it doesn't retry the abort. The previous owner normally notices at its next renewal. A stalled event loop or slow storage can delay that renewal. A tool that ignores `abortSignal` keeps running until it returns, but its result is rejected.
|
|
538
|
+
|
|
486
539
|
## Non-agent owners
|
|
487
540
|
|
|
488
541
|
Code other than agents can run tasks through the manager. For example, an MCP server can run long tool calls as background tasks. The task's `agentId` is its owner key, and agent streams, `untilIdle`, and the end-of-step wait only see tasks whose `agentId` matches the agent. Use a namespaced owner key such as `mcp-server:<serverId>` so it can't collide with a real agent ID. Mastra doesn't enforce this.
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_src = require("./src-
|
|
2
|
+
const require_src = require("./src-IZtKjicq.cjs");
|
|
3
3
|
let _mastra_core_processors = require("@mastra/core/processors");
|
|
4
4
|
exports.AUTO_MODEL_BY_PROVIDER = require_src.AUTO_MODEL_BY_PROVIDER;
|
|
5
5
|
exports.Extractor = require_src.Extractor;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { embedMany } from './_types/@internal_ai-sdk-v4@0.0.
|
|
1
|
+
import { embedMany } from './_types/@internal_ai-sdk-v4@0.0.97/dist/index.js';
|
|
2
2
|
import type { MastraDBMessage } from '@mastra/core/agent';
|
|
3
3
|
import type { Mastra } from '@mastra/core/mastra';
|
|
4
4
|
import { MastraMemory } from '@mastra/core/memory';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { d as AUTO_MODEL_BY_PROVIDER, U as Extractor, w as KnowledgeSemanticIndexCoordinator, t as Memory, n as MessageHistory, g as ModelByInputTokens, k as SUMMARIZE_THREAD_DEFAULTS, r as SemanticRecall, T as StaleKnowledgeSemanticIndexError, E as Subconscious, p as WORKING_MEMORY_STATE_ID, m as WORKING_MEMORY_STATE_PROCESSOR_ID, i as WorkingMemory, D as WorkingMemoryExtractor, h as WorkingMemoryStateProcessor, O as deepMergeWorkingMemory, a as extractWorkingMemoryContent, o as extractWorkingMemoryTags, c as getObservationsAsOf, s as removeWorkingMemoryTags, f as resolveAutoModelId, A as summarizeConversation } from "./src-
|
|
1
|
+
export { d as AUTO_MODEL_BY_PROVIDER, U as Extractor, w as KnowledgeSemanticIndexCoordinator, t as Memory, n as MessageHistory, g as ModelByInputTokens, k as SUMMARIZE_THREAD_DEFAULTS, r as SemanticRecall, T as StaleKnowledgeSemanticIndexError, E as Subconscious, p as WORKING_MEMORY_STATE_ID, m as WORKING_MEMORY_STATE_PROCESSOR_ID, i as WorkingMemory, D as WorkingMemoryExtractor, h as WorkingMemoryStateProcessor, O as deepMergeWorkingMemory, a as extractWorkingMemoryContent, o as extractWorkingMemoryTags, c as getObservationsAsOf, s as removeWorkingMemoryTags, f as resolveAutoModelId, A as summarizeConversation } from "./src-BkElV36S.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_src = require("../src-
|
|
2
|
+
const require_src = require("../src-IZtKjicq.cjs");
|
|
3
3
|
exports.AUTO_MODEL_BY_PROVIDER = require_src.AUTO_MODEL_BY_PROVIDER;
|
|
4
4
|
exports.Extractor = require_src.Extractor;
|
|
5
5
|
exports.ModelByInputTokens = require_src.ModelByInputTokens;
|
package/dist/processors/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { d as AUTO_MODEL_BY_PROVIDER, U as Extractor, g as ModelByInputTokens, W as OBSERVATIONAL_MEMORY_DEFAULTS, G as OBSERVATION_CONTEXT_INSTRUCTIONS, K as OBSERVATION_CONTEXT_PROMPT, q as OBSERVATION_CONTEXT_PROMPT_THREAD, J as OBSERVATION_CONTINUATION_HINT, M as OBSERVER_SYSTEM_PROMPT, u as ObservationalMemory, l as ObservationalMemoryProcessor, j as TokenCounter, D as WorkingMemoryExtractor, N as buildObserverPrompt, P as buildObserverSystemPrompt, _ as combineObservationGroupRanges, v as deriveObservationGroupProvenance, F as extractCurrentTask, I as formatMessagesForObserver, Y as getObservationContextPrompt, c as getObservationsAsOf, L as hasCurrentTaskSection, B as injectAnchorIds, R as optimizeObservationsForContext, V as parseAnchorId, y as parseObservationGroups, z as parseObserverOutput, b as reconcileObservationGroupsFromReflection, x as renderObservationGroupsForReflection, f as resolveAutoModelId, H as stripEphemeralAnchorIds, S as stripObservationGroups, A as summarizeConversation, C as wrapInObservationGroup } from "../src-
|
|
1
|
+
export { d as AUTO_MODEL_BY_PROVIDER, U as Extractor, g as ModelByInputTokens, W as OBSERVATIONAL_MEMORY_DEFAULTS, G as OBSERVATION_CONTEXT_INSTRUCTIONS, K as OBSERVATION_CONTEXT_PROMPT, q as OBSERVATION_CONTEXT_PROMPT_THREAD, J as OBSERVATION_CONTINUATION_HINT, M as OBSERVER_SYSTEM_PROMPT, u as ObservationalMemory, l as ObservationalMemoryProcessor, j as TokenCounter, D as WorkingMemoryExtractor, N as buildObserverPrompt, P as buildObserverSystemPrompt, _ as combineObservationGroupRanges, v as deriveObservationGroupProvenance, F as extractCurrentTask, I as formatMessagesForObserver, Y as getObservationContextPrompt, c as getObservationsAsOf, L as hasCurrentTaskSection, B as injectAnchorIds, R as optimizeObservationsForContext, V as parseAnchorId, y as parseObservationGroups, z as parseObserverOutput, b as reconcileObservationGroupsFromReflection, x as renderObservationGroupsForReflection, f as resolveAutoModelId, H as stripEphemeralAnchorIds, S as stripObservationGroups, A as summarizeConversation, C as wrapInObservationGroup } from "../src-BkElV36S.js";
|