You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make the task tools (`task_write`, `task_update`, `task_complete`, `task_check`) agent-agnostic.
6
+
7
+
The task tools no longer depend on the Harness request context. The task list is now held in a generic, thread-scoped **`threadState` storage domain** (`ThreadStateStorage`) — the source of truth — and projected onto the agent **state-signal** lane (`stateId: "tasks"`) by the new `TaskStateProcessor`, so they work on any `Agent` and not only inside the Harness.
8
+
9
+
A new storage domain `threadState` is registered on `MastraStorage` (accessible via `storage.getStore("threadState")`). It is keyed by `(threadId, type)` so it can hold any per-thread state; the task list lives under `type: "task"` and the domain is intentionally generic so other agent-scoped state (e.g. `"goal"`) can reuse it. The composite store always wires an `InMemoryThreadStateStorage` by default, so task tracking works out of the box without configuring a backend, and a durable backend (`@mastra/libsql`'s `ThreadStateLibSQL`) persists the list across process restarts. The tools read/write it within a run via `context.mastra.getStorage().getStore("threadState")`, scoped by the run's `threadId`.
10
+
11
+
The state-signal projection is delta-first (modelled on working memory), cache-aware, and observational-memory-aware:
12
+
13
+
- The first projection of a populated list (and every compaction) is a full `<current-task-list>`**snapshot**; each later mutation emits a small `<task-list-update>`**delta** carrying only that turn's add/remove/update ops, so a large task list is not re-sent in full on every change.
14
+
- The task list is carried on the state-signal lane instead of being injected into the cached system prompt, so task updates no longer invalidate the prompt-cache prefix.
15
+
- The base snapshot and its deltas accumulate in the window; the processor re-snapshots once enough deltas accumulate (compaction) to bound window growth, and whenever observational-memory truncation drops the base snapshot from the window (deltas are meaningless without their base), reading the `threadState` store so the agent never loses track of its tasks.
16
+
17
+
The task tools and the processor require a memory-backed thread. On a run that is not memory backed (no `threadId`/`resourceId`), the task tools no-op and return a result explaining that task tracking requires agent memory.
18
+
19
+
For the simplest setup, register `TaskSignalProvider` via the agent's `signals` array — it bundles the task tools and the `TaskStateProcessor` so they cannot get out of sync:
The Agent merges the tools into its toolset and registers the processor automatically.
29
+
30
+
New exports from `@mastra/core/storage`: `ThreadStateStorage`, `InMemoryThreadStateStorage`, and the `TaskRecord` type. New exports from `@mastra/core/tools`: `taskWriteTool`, `taskUpdateTool`, `taskCompleteTool`, `taskCheckTool`, `TaskStateProcessor`, and the task helpers/types (`assignTaskIds`, `summarizeTaskCheck`, `TaskItem`, `TaskItemSnapshot`, `TaskCheckSummary`, `TaskCheckResult`, etc.). New export from `@mastra/core/signals`: `TaskSignalProvider`, alongside the other signal providers. The Harness continues to re-export the task tools, so existing imports and toolset identity are unchanged.
31
+
32
+
Internal behavior change: the Harness no longer stores the task list in session state. Task mutations still emit the `task_updated` display event, so the Harness display snapshot and any pinned task UI are unaffected. To adopt the new behavior on a plain agent (with `Memory` and a Mastra `storage`), register `new TaskSignalProvider()` in `signals` — or, for manual control, add `new TaskStateProcessor()` to `inputProcessors` alongside the task tools.
Add `ThreadStateLibSQL`, the LibSQL implementation of the new `ThreadStateStorage` domain. It persists per-thread, per-type state (e.g. the agent task list under `type: "task"`) in the `mastra_thread_state` table, keyed by `(threadId, type)`. Composing a LibSQL store wires this domain automatically, so an agent's task list now survives a process restart.
Restore the task portion of `HarnessDisplayState` after a UI replays persisted task tool history. This emits `display_state_changed` without emitting a live `task_updated` event.
363
363
364
-
If later task tools should read the replayed tasks, persist the same task list with `setState({ tasks })` before calling `restoreDisplayTasks(tasks)`.
364
+
The task list itself is held in the thread-scoped `tasks` storage domain (the task store) and projected onto the agent state-signal lane (`stateId: "tasks"`), not in Harness state, so this method only updates the display snapshot. Task tools read and write the task store directly; you no longer need to seed `setState({ tasks })`.
description: "API reference for TaskSignalProvider, a signal provider that bundles the built-in task tools and the task state-signal processor behind a single agent registration."
4
+
packages:
5
+
- "@mastra/core"
6
+
---
7
+
8
+
# TaskSignalProvider
9
+
10
+
Bundles the built-in task tools (`task_write`, `task_update`, `task_complete`, `task_check`) and the `TaskStateProcessor` behind a single agent registration. Use it to add a structured, durable task list to an agent without wiring the tools and processor separately.
11
+
12
+
Extends [`SignalProvider`](/reference/signals/signal-provider). The task list is stored in the thread-scoped `tasks` storage domain (the source of truth) and projected onto the agent state-signal lane by the processor, so it survives observational-memory truncation without invalidating the prompt cache.
13
+
14
+
## Usage example
15
+
16
+
Register the provider on an agent that has `Memory` and a Mastra `storage`:
The Agent automatically merges the four task tools into its toolset and registers the processor on its input-processor chain. No other wiring is required.
32
+
33
+
Task tracking requires a memory-backed thread (`threadId` + `resourceId`). Without memory the task tools no-op and return a result explaining that task tracking requires agent memory. The `tasks` storage domain is wired in-memory by default, so task tracking works without configuring a storage backend.
34
+
35
+
## Constructor parameters
36
+
37
+
`TaskSignalProvider` takes no constructor arguments.
38
+
39
+
## Properties
40
+
41
+
<PropertiesTable
42
+
content={[
43
+
{
44
+
name: 'id',
45
+
type: "'task-signals'",
46
+
description: 'Stable identifier for the provider instance.',
47
+
},
48
+
]}
49
+
/>
50
+
51
+
## Methods
52
+
53
+
### Agent integration
54
+
55
+
These methods are called automatically by the Agent when the provider is passed to `signals`. You normally do not call them directly.
56
+
57
+
#### `getTools()`
58
+
59
+
Returns the four task tools keyed by their tool ids (`task_write`, `task_update`, `task_complete`, `task_check`). The Agent merges these into its toolset.
Returns the provider's `TaskStateProcessor` instance. The Agent registers it on the input-processor chain, which propagates the Mastra instance so the processor can resolve the `tasks` store.
Copy file name to clipboardExpand all lines: docs/src/mastra-code/tools.mdx
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -176,6 +176,8 @@ Extract the full content of one or more web pages. Requires a Tavily API key (`T
176
176
177
177
## Task management
178
178
179
+
The task tools are agent-agnostic built-ins. They store the task list in a thread-scoped task store (the `tasks` storage domain) and project it onto the agent state-signal lane, which keeps it out of the cached system prompt (preserving prompt caching) while surviving observational-memory truncation. They require a memory-backed thread; on an agent without memory the task tools no-op and report that task tracking requires agent memory.
180
+
179
181
### `task_write`
180
182
181
183
Create or replace a structured task list for tracking progress on complex, multi-step work.
@@ -202,7 +204,7 @@ Check the completion status of the current task list. The agent uses this before
202
204
-`tasks`: The structured task list snapshot with task IDs.
203
205
-`summary`: Counts for `total`, `completed`, `inProgress`, `pending`, and `incomplete`, plus `hasTasks` and `allCompleted`.
204
206
-`incompleteTasks`: The `in_progress` and `pending` tasks that still need work.
205
-
-`isError`: `true` when the tool could not read harness task state.
207
+
-`isError`: `true` when the tool could not read the task list (for example, on an agent without memory).
206
208
207
209
`summary.allCompleted` is `true` only when at least one tracked task exists and every tracked task is completed. If no tasks exist, `summary.hasTasks` is `false` and `summary.allCompleted` is `false`.
0 commit comments