@mastra/memory 1.42.0-alpha.5 → 1.42.0-alpha.6
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
CHANGED
|
@@ -335,12 +335,14 @@ Which layer to use depends on where consistency matters: subagent-level configur
|
|
|
335
335
|
|
|
336
336
|
A background task can pause itself mid-execution and wait for an external signal before continuing. This is useful for human approvals, webhooks, or any flow where the next step depends on data that arrives later.
|
|
337
337
|
|
|
338
|
-
A tool calls `suspend(data)` from inside its `execute
|
|
338
|
+
A tool calls `suspend(data)` from inside its `execute`. Once `execute` returns, Mastra:
|
|
339
339
|
|
|
340
|
-
- Persists `status: 'suspended'` and the `data` payload on the task record.
|
|
341
340
|
- Saves the workflow snapshot so the run survives process restarts.
|
|
342
|
-
-
|
|
341
|
+
- Persists `status: 'suspended'` and the `data` payload on the task record.
|
|
343
342
|
- Releases the concurrency slot so other tasks can run.
|
|
343
|
+
- Emits a `background-task-suspended` chunk on the manager stream.
|
|
344
|
+
|
|
345
|
+
The task is stored as `suspended` only after its snapshot is saved, so a task stored as `suspended` can always be resumed, even after a crash. Until then the task reads as `running`.
|
|
344
346
|
|
|
345
347
|
Resume the task with `mastra.backgroundTaskManager.resume(taskId, resumeData)`. The `resumeData` arrives in the tool's `execute` options on the resumed run, and the task transitions back to `running`.
|
|
346
348
|
|
|
@@ -557,7 +559,7 @@ Before a manager runs a task, it claims the task with a conditional write. The w
|
|
|
557
559
|
|
|
558
560
|
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.
|
|
559
561
|
|
|
560
|
-
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 running task with `maxRetries: 0` can't run again, so shutdown fails it with `Worker process terminated before task completed`, the same ending as a crash, rather than cancelling it. A lease that isn't released, for example because the process crashed, expires on its own.
|
|
562
|
+
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 running task with `maxRetries: 0` can't run again, so shutdown fails it with `Worker process terminated before task completed`, the same ending as a crash, rather than cancelling it. A task whose tool already called `suspend()` is kept instead, so its snapshot can still be saved. Once the tool returns or stops on the abort signal, Mastra saves the snapshot and stores the task as `suspended`, so it can be answered after the restart. If the tool is still running when shutdown ends, nothing is saved and the task is recovered as if its worker crashed. Stale-task recovery uses a retry if one is left and fails the task otherwise, while a redelivered dispatch can run it again even with `maxRetries: 0`. See [Recover a task from a dead owner](#recover-a-task-from-a-dead-owner). A lease that isn't released, for example because the process crashed, expires on its own.
|
|
561
563
|
|
|
562
564
|
### Recover a task from a dead owner
|
|
563
565
|
|
|
@@ -565,6 +567,7 @@ A manager treats a `running` task as abandoned only after its lease expires.
|
|
|
565
567
|
|
|
566
568
|
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. After startup, the manager also checks for running tasks with an expired lease every `leaseDurationMs`, so a task whose worker dies later is recovered without a restart. Each check reads up to `globalConcurrency` running tasks (at least 100, at most 1,000), which normally covers all of them, so the task is recovered within about one `leaseDurationMs` after its lease expires. When more tasks are running than that, for example because other servers use a higher `globalConcurrency`, each further page of running tasks adds one `leaseDurationMs`. For each task the scan recovers:
|
|
567
569
|
|
|
570
|
+
- If the task's snapshot already holds a suspension from its current attempt, the task is stored as `suspended` without using a retry, and you can answer it with `resume()`.
|
|
568
571
|
- If the task's worker shut down gracefully, it returns to `pending` and is dispatched again without using a retry.
|
|
569
572
|
- If the worker died and the task's `retryCount` is below `maxRetries`, it uses a retry, returns to `pending`, and is dispatched again.
|
|
570
573
|
- Otherwise, it fails with `Worker process terminated before task completed`. The failure fires `task.failed` and `onTaskFailed` like any other failure.
|
|
@@ -573,7 +576,7 @@ Only a crash counts against `maxRetries`, so a task that keeps taking its worker
|
|
|
573
576
|
|
|
574
577
|
The recovery write is conditional on the owner and lease that the scan read, so only one manager recovers each task.
|
|
575
578
|
|
|
576
|
-
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`.
|
|
579
|
+
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`. If the task's snapshot already holds a suspension from its current attempt, the redelivery stores the task as `suspended` instead of running it again.
|
|
577
580
|
|
|
578
581
|
The manager that runs the recovered task needs an executor for it. See the known limitations under [non-agent owners](#non-agent-owners).
|
|
579
582
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/memory",
|
|
3
|
-
"version": "1.42.0-alpha.
|
|
3
|
+
"version": "1.42.0-alpha.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"probe-image-size": "^7.4.0",
|
|
54
54
|
"xxhash-wasm": "^1.1.0",
|
|
55
55
|
"zod": "^4.6.7",
|
|
56
|
-
"@mastra/schema-compat": "1.4.
|
|
56
|
+
"@mastra/schema-compat": "1.4.2-alpha.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@ai-sdk/openai-v5": "npm:@ai-sdk/openai@2.0.139",
|
|
@@ -67,13 +67,13 @@
|
|
|
67
67
|
"tsx": "^4.23.15",
|
|
68
68
|
"typescript": "^6.0.3",
|
|
69
69
|
"vitest": "5.1.0",
|
|
70
|
-
"@internal/ai-sdk-
|
|
71
|
-
"@internal/lint": "0.0.152",
|
|
72
|
-
"@internal/types-builder": "0.0.127",
|
|
73
|
-
"@mastra/core": "1.87.0-alpha.15",
|
|
70
|
+
"@internal/ai-sdk-v4": "0.0.99",
|
|
74
71
|
"@internal/ai-v6": "0.0.99",
|
|
75
72
|
"@internal/ai-v7": "0.0.99",
|
|
76
|
-
"@internal/
|
|
73
|
+
"@internal/lint": "0.0.152",
|
|
74
|
+
"@internal/types-builder": "0.0.127",
|
|
75
|
+
"@mastra/core": "1.87.0-alpha.19",
|
|
76
|
+
"@internal/ai-sdk-v5": "0.0.99"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"@mastra/core": ">=1.85.1-0 <2.0.0-0"
|