@mastra/mcp-docs-server 1.2.7-alpha.1 → 1.2.7-alpha.12
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/.docs/docs/agent-builder/integrations.md +45 -3
- package/.docs/docs/agent-builder/overview.md +4 -3
- package/.docs/docs/agent-builder/skill-registries.md +1 -3
- package/.docs/docs/agent-controller/modes.md +1 -1
- package/.docs/docs/agent-controller/overview.md +4 -3
- package/.docs/docs/agent-controller/session.md +3 -5
- package/.docs/docs/agents/a2a.md +2 -1
- package/.docs/docs/agents/agent-approval.md +2 -2
- package/.docs/docs/agents/code-mode.md +1 -1
- package/.docs/docs/agents/guardrails.md +10 -9
- package/.docs/docs/agents/networks.md +1 -1
- package/.docs/docs/agents/overview.md +5 -5
- package/.docs/docs/agents/skills.md +3 -5
- package/.docs/docs/agents/structured-output.md +1 -1
- package/.docs/docs/agents/supervisor-agents.md +3 -4
- package/.docs/docs/agents/using-tools.md +2 -4
- package/.docs/docs/browser/agent-browser.md +1 -3
- package/.docs/docs/browser/browser-viewer.md +1 -3
- package/.docs/docs/browser/overview.md +2 -1
- package/.docs/docs/browser/recording.md +1 -1
- package/.docs/docs/browser/stagehand.md +1 -1
- package/.docs/docs/capabilities/channels/discord.md +98 -0
- package/.docs/docs/capabilities/channels/other-adapters.md +68 -0
- package/.docs/docs/capabilities/channels/overview.md +255 -0
- package/.docs/docs/capabilities/channels/slack.md +225 -0
- package/.docs/docs/capabilities/channels/teams.md +100 -0
- package/.docs/docs/capabilities/channels/telegram.md +98 -0
- package/.docs/docs/capabilities/channels/whatsapp.md +99 -0
- package/.docs/docs/deployment/mastra-server.md +2 -4
- package/.docs/docs/editor/overview.md +2 -6
- package/.docs/docs/editor/prompts.md +1 -1
- package/.docs/docs/editor/tools.md +3 -5
- package/.docs/docs/evals/built-in-scorers.md +2 -2
- package/.docs/docs/evals/custom-scorers.md +1 -3
- package/.docs/docs/evals/datasets/overview.md +4 -5
- package/.docs/docs/evals/datasets/running-experiments.md +10 -8
- package/.docs/docs/evals/evals-with-memory.md +1 -3
- package/.docs/docs/evals/gates-and-verdicts.md +2 -4
- package/.docs/docs/evals/overview.md +4 -1
- package/.docs/docs/evals/quick-checks.md +3 -5
- package/.docs/docs/getting-started/file-based-agents.md +116 -0
- package/.docs/docs/getting-started/manual-install.md +17 -4
- package/.docs/docs/index.md +1 -1
- package/.docs/docs/long-running-agents/background-tasks.md +3 -3
- package/.docs/docs/long-running-agents/durable-agents.md +5 -7
- package/.docs/docs/long-running-agents/goals.md +5 -7
- package/.docs/docs/long-running-agents/schedules.md +1 -1
- package/.docs/docs/long-running-agents/signal-providers.md +1 -3
- package/.docs/docs/long-running-agents/signals.md +12 -23
- package/.docs/docs/mastra-platform/database.md +2 -2
- package/.docs/docs/mastra-platform/github.md +1 -1
- package/.docs/docs/mastra-platform/observability.md +5 -1
- package/.docs/docs/mcp/mcp-apps.md +3 -3
- package/.docs/docs/mcp/overview.md +6 -10
- package/.docs/docs/memory/memory-processors.md +67 -0
- package/.docs/docs/memory/message-history.md +56 -2
- package/.docs/docs/memory/observational-memory.md +5 -4
- package/.docs/docs/memory/overview.md +8 -6
- package/.docs/docs/memory/semantic-recall.md +36 -2
- package/.docs/docs/memory/working-memory.md +3 -3
- package/.docs/docs/observability/integrations/exporters/mastra-platform.md +1 -3
- package/.docs/docs/observability/integrations/exporters/mastra-storage.md +1 -1
- package/.docs/docs/observability/logging.md +1 -1
- package/.docs/docs/observability/tracing/overview.md +1 -1
- package/.docs/docs/rag/vector-databases.md +7 -2
- package/.docs/docs/server/auth/auth0.md +1 -1
- package/.docs/docs/server/auth/better-auth.md +2 -2
- package/.docs/docs/server/auth/clerk.md +1 -1
- package/.docs/docs/server/auth/firebase.md +1 -1
- package/.docs/docs/server/auth/google.md +3 -3
- package/.docs/docs/server/auth/jwt.md +2 -2
- package/.docs/docs/server/auth/okta.md +2 -2
- package/.docs/docs/server/auth/workos.md +1 -1
- package/.docs/docs/server/mastra-client.md +1 -1
- package/.docs/docs/server/mastra-server.md +1 -1
- package/.docs/docs/server/pubsub.md +1 -1
- package/.docs/docs/server/request-context.md +4 -4
- package/.docs/docs/server/server-adapters.md +8 -8
- package/.docs/docs/storage/overview.md +214 -0
- package/.docs/docs/studio/auth.md +1 -3
- package/.docs/docs/studio/overview.md +1 -1
- package/.docs/docs/voice/livekit.md +101 -4
- package/.docs/docs/workflows/agents-and-tools.md +3 -5
- package/.docs/docs/workflows/control-flow.md +1 -3
- package/.docs/docs/workflows/overview.md +6 -7
- package/.docs/docs/workflows/snapshots.md +1 -1
- package/.docs/docs/workspace/overview.md +2 -1
- package/.docs/docs/workspace/sandbox.md +2 -0
- package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
- package/.docs/guides/build-your-ui/copilotkit/channels.md +1 -1
- package/.docs/guides/build-your-ui/copilotkit/generative-ui.md +2 -2
- package/.docs/guides/build-your-ui/copilotkit/overview.md +1 -1
- package/.docs/guides/concepts/streaming.md +3 -3
- package/.docs/guides/getting-started/quickstart.md +4 -2
- package/.docs/guides/guide/chef-michel.md +0 -2
- package/.docs/guides/guide/slack-assistant.md +2 -2
- package/.docs/guides/guide/stock-agent.md +0 -2
- package/.docs/models/embeddings.md +119 -0
- package/.docs/models/environment-variables.md +7 -0
- package/.docs/models/gateways/netlify.md +4 -1
- package/.docs/models/gateways/openrouter.md +10 -7
- package/.docs/models/gateways/vercel.md +8 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/abacus.md +44 -14
- package/.docs/models/providers/crossmodel.md +109 -0
- package/.docs/models/providers/empiriolabs.md +106 -0
- package/.docs/models/providers/google.md +2 -1
- package/.docs/models/providers/llmgateway.md +185 -181
- package/.docs/models/providers/meta.md +101 -0
- package/.docs/models/providers/model-oracle-ai.md +87 -0
- package/.docs/models/providers/nano-gpt.md +2 -2
- package/.docs/models/providers/neon.md +40 -29
- package/.docs/models/providers/nvidia.md +1 -3
- package/.docs/models/providers/openai.md +6 -1
- package/.docs/models/providers/opencode.md +6 -2
- package/.docs/models/providers/pioneer.md +148 -0
- package/.docs/models/providers/poolside.md +6 -5
- package/.docs/models/providers/routing-run.md +23 -34
- package/.docs/models/providers/the-grid-ai.md +3 -3
- package/.docs/models/providers/unorouter.md +95 -0
- package/.docs/models/providers/wandb.md +21 -14
- package/.docs/models/providers/xai.md +2 -1
- package/.docs/models/providers/zenifra.md +73 -0
- package/.docs/models/providers.md +7 -0
- package/.docs/reference/agent-controller/agent-controller-class.md +3 -3
- package/.docs/reference/agent-controller/session.md +4 -4
- package/.docs/reference/agents/agent.md +1 -1
- package/.docs/reference/agents/channels.md +2 -2
- package/.docs/reference/agents/inngest-agent.md +1 -1
- package/.docs/reference/agents/listSkills.md +1 -1
- package/.docs/reference/agents/listSuspendedRuns.md +3 -3
- package/.docs/reference/auth/google.md +5 -5
- package/.docs/reference/channels/channel-provider.md +1 -1
- package/.docs/reference/channels/slack-provider.md +3 -3
- package/.docs/reference/cli/mastra.md +119 -12
- package/.docs/reference/code-sdk/mount-agent-controller.md +76 -0
- package/.docs/reference/coding-agent/create-coding-agent.md +1 -1
- package/.docs/reference/configuration.md +1 -1
- package/.docs/reference/evals/checks.md +4 -4
- package/.docs/reference/evals/create-scorer.md +8 -0
- package/.docs/reference/file-based-agents/config.md +97 -0
- package/.docs/reference/file-based-agents/instructions.md +54 -0
- package/.docs/reference/file-based-agents/logger.md +26 -0
- package/.docs/reference/file-based-agents/memory.md +58 -0
- package/.docs/reference/file-based-agents/observability.md +32 -0
- package/.docs/reference/file-based-agents/processors.md +56 -0
- package/.docs/reference/file-based-agents/scorers.md +54 -0
- package/.docs/reference/file-based-agents/server.md +37 -0
- package/.docs/reference/file-based-agents/skills.md +56 -0
- package/.docs/reference/file-based-agents/storage.md +30 -0
- package/.docs/reference/file-based-agents/studio.md +56 -0
- package/.docs/reference/file-based-agents/subagents.md +123 -0
- package/.docs/reference/file-based-agents/tools.md +63 -0
- package/.docs/reference/file-based-agents/workflows.md +52 -0
- package/.docs/reference/file-based-agents/workspace.md +74 -0
- package/.docs/reference/index.md +18 -0
- package/.docs/reference/memory/memory-class.md +1 -1
- package/.docs/reference/memory/observational-memory.md +1 -1
- package/.docs/reference/memory/serialized-memory-config.md +1 -1
- package/.docs/reference/memory/summarizeConversation.md +99 -0
- package/.docs/reference/memory/summarizeThread.md +93 -0
- package/.docs/{docs/getting-started → reference}/project-structure.md +3 -10
- package/.docs/reference/pubsub/lease-provider.md +5 -5
- package/.docs/reference/server/express-adapter.md +1 -3
- package/.docs/reference/server/fastify-adapter.md +1 -3
- package/.docs/reference/server/hono-adapter.md +1 -3
- package/.docs/reference/server/koa-adapter.md +1 -3
- package/.docs/reference/server/nestjs-adapter.md +1 -3
- package/.docs/reference/signals/task-signal-provider.md +1 -1
- package/.docs/reference/storage/clickhouse.md +34 -2
- package/.docs/reference/storage/cloudflare-d1.md +1 -1
- package/.docs/reference/storage/composite.md +64 -6
- package/.docs/reference/storage/convex.md +1 -1
- package/.docs/reference/storage/dynamodb.md +1 -1
- package/.docs/reference/storage/mongodb.md +46 -46
- package/.docs/reference/storage/retention.md +74 -6
- package/.docs/reference/tools/create-tool.md +2 -2
- package/.docs/reference/tools/mcp-client.md +22 -0
- package/.docs/reference/tools/mcp-server.md +161 -4
- package/.docs/reference/vectors/mongodb.md +93 -4
- package/.docs/reference/voice/livekit.md +272 -8
- package/.docs/reference/workspace/agentcore-runtime-sandbox.md +1 -3
- package/.docs/reference/workspace/agentfs-filesystem.md +1 -3
- package/.docs/reference/workspace/apple-container-sandbox.md +6 -8
- package/.docs/reference/workspace/archil-filesystem.md +1 -3
- package/.docs/reference/workspace/azure-blob-filesystem.md +1 -3
- package/.docs/reference/workspace/blaxel-sandbox.md +1 -3
- package/.docs/reference/workspace/daytona-sandbox.md +1 -3
- package/.docs/reference/workspace/docker-sandbox.md +1 -3
- package/.docs/reference/workspace/e2b-sandbox.md +1 -3
- package/.docs/reference/workspace/files-sdk-filesystem.md +1 -3
- package/.docs/reference/workspace/gcs-filesystem.md +1 -3
- package/.docs/reference/workspace/google-drive-filesystem.md +1 -3
- package/.docs/reference/workspace/local-filesystem.md +1 -3
- package/.docs/reference/workspace/local-sandbox.md +1 -3
- package/.docs/reference/workspace/mesa-filesystem.md +4 -4
- package/.docs/reference/workspace/modal-sandbox.md +1 -3
- package/.docs/reference/workspace/railway-sandbox.md +2 -4
- package/.docs/reference/workspace/s3-filesystem.md +1 -3
- package/.docs/reference/workspace/vercel-sandbox.md +5 -7
- package/.docs/reference/workspace/vercel-serverless.md +2 -4
- package/CHANGELOG.md +36 -0
- package/package.json +5 -5
- package/.docs/docs/agents/channels.md +0 -225
- package/.docs/docs/agents/file-based-agents.md +0 -297
- package/.docs/docs/memory/storage.md +0 -267
package/.docs/docs/index.md
CHANGED
|
@@ -54,7 +54,7 @@ export const weatherTool = createTool({
|
|
|
54
54
|
})
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
If you need to create an agent, create a new file and use `import { Agent } from "@mastra/core/agent"`. The constructor takes `{ id, name, instructions, model }`. The `model` property is a string in Mastra's model router format: `provider/model`, for example `openai/gpt-5.5`. For OpenAI models, use `openai/<model>`, not `openai:<model>`, and don't pass a provider object. No provider import is needed for this format.
|
|
57
|
+
If you need to create an agent, create a new file and use `import { Agent } from "@mastra/core/agent"`. The constructor takes `{ id, name, instructions, model }`. The `model` property is a string in Mastra's model router format: `provider/model`, for example `openai/gpt-5.5`. For OpenAI models, use `openai/<model>`, not `openai:<model>`, and don't pass a provider object. No provider import is needed for this format. Don't install any AI SDK package unless Mastra's documentation says otherwise.
|
|
58
58
|
|
|
59
59
|
Add a tool an agent by importing the tool and passing it to the agent constructor as a tools object.
|
|
60
60
|
|
|
@@ -16,7 +16,7 @@ Use background tasks when a tool call may take long enough that the user shouldn
|
|
|
16
16
|
|
|
17
17
|
For tool calls that return quickly, foreground execution using `agent.stream()` and `agent.generate()` is simpler.
|
|
18
18
|
|
|
19
|
-
> **Note:** Background tasks require a configured [storage](https://mastra.ai/docs/
|
|
19
|
+
> **Note:** Background tasks require a configured [storage](https://mastra.ai/docs/storage/overview) backend on the Mastra instance. Tasks are persisted so they survive process restarts.
|
|
20
20
|
|
|
21
21
|
## Quickstart
|
|
22
22
|
|
|
@@ -168,7 +168,7 @@ const stream = await agent.stream('Research solana for me', {
|
|
|
168
168
|
})
|
|
169
169
|
```
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
Visit [`Agent.stream()`](https://mastra.ai/reference/streaming/agents/stream) for the full API.
|
|
172
172
|
|
|
173
173
|
### Aggregate properties
|
|
174
174
|
|
|
@@ -379,4 +379,4 @@ These read from storage rather than the pubsub stream, so they're suitable for p
|
|
|
379
379
|
- [Durable agents](https://mastra.ai/docs/long-running-agents/durable-agents)
|
|
380
380
|
- [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents)
|
|
381
381
|
- [Stream chunk types](https://mastra.ai/reference/streaming/ChunkType)
|
|
382
|
-
- [Storage](https://mastra.ai/docs/
|
|
382
|
+
- [Storage](https://mastra.ai/docs/storage/overview)
|
|
@@ -60,9 +60,7 @@ for await (const chunk of output.fullStream) {
|
|
|
60
60
|
cleanup()
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
The returned `runId` identifies the execution. Pass it to `observe()` to reconnect from a different client.
|
|
64
|
-
|
|
65
|
-
> **Note:** Visit the [DurableAgent reference](https://mastra.ai/reference/agents/durable-agent) for the full configuration and method API.
|
|
63
|
+
The returned `runId` identifies the execution. Pass it to `observe()` to reconnect from a different client. Visit the [DurableAgent reference](https://mastra.ai/reference/agents/durable-agent) for the full configuration and method API.
|
|
66
64
|
|
|
67
65
|
## How it works
|
|
68
66
|
|
|
@@ -105,7 +103,7 @@ export const durableHelper = createDurableAgent({ agent })
|
|
|
105
103
|
|
|
106
104
|
### Fire-and-forget with `createEventedAgent()`
|
|
107
105
|
|
|
108
|
-
The workflow starts in the background without blocking the caller. You still receive chunks through PubSub, so `stream()` returns a result you can consume. The HTTP handler that triggered the run
|
|
106
|
+
The workflow starts in the background without blocking the caller. You still receive chunks through PubSub, so `stream()` returns a result you can consume. The HTTP handler that triggered the run doesn't need to wait for the workflow to finish:
|
|
109
107
|
|
|
110
108
|
```typescript
|
|
111
109
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -140,7 +138,7 @@ const agent = new Agent({
|
|
|
140
138
|
export const inngestAnalyst = createInngestAgent({ agent, inngest })
|
|
141
139
|
```
|
|
142
140
|
|
|
143
|
-
|
|
141
|
+
Visit the [`createInngestAgent()` reference](https://mastra.ai/reference/agents/inngest-agent) for the full API, including Inngest-specific options like PubSub and cache configuration.
|
|
144
142
|
|
|
145
143
|
## Resumable streams
|
|
146
144
|
|
|
@@ -170,7 +168,7 @@ export const durableAgent = createDurableAgent({
|
|
|
170
168
|
})
|
|
171
169
|
```
|
|
172
170
|
|
|
173
|
-
`createInngestAgent()`
|
|
171
|
+
`createInngestAgent()` doesn't enable caching by default. Pass a `cache` option or register the agent with a `Mastra` instance that has a `serverCache` configured to enable resumable streams.
|
|
174
172
|
|
|
175
173
|
## Streaming with background tasks
|
|
176
174
|
|
|
@@ -199,7 +197,7 @@ await durableAgent.stream('Research topic', {
|
|
|
199
197
|
})
|
|
200
198
|
```
|
|
201
199
|
|
|
202
|
-
|
|
200
|
+
Visit [Background tasks](https://mastra.ai/docs/long-running-agents/background-tasks) for the full background task guide, including configuration, subagents, and suspend/resume.
|
|
203
201
|
|
|
204
202
|
## Cleanup
|
|
205
203
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
> **Beta:** The Goals feature is in beta stage and subject to breaking changes in minor versions until it graduates from its beta status.
|
|
8
8
|
|
|
9
|
-
A goal is a durable, thread-scoped objective: a standing instruction the agent keeps working toward across loop iterations until a judge model decides it
|
|
9
|
+
A goal is a durable, thread-scoped objective: a standing instruction the agent keeps working toward across loop iterations until a judge model decides it's satisfied or a run budget is exhausted. The objective is persisted in thread state, so it survives reloads and is evaluated in-loop — even when a new message arrives in the middle of an already-running turn.
|
|
10
10
|
|
|
11
11
|
Goals build on the same machinery as [`isTaskComplete`](https://mastra.ai/docs/agents/supervisor-agents): an LLM-as-judge scores the agent's output each iteration and gates the loop. The difference is that a goal is **durable** (stored in thread state, not passed per call) and is set and updated through `Agent` methods rather than per-`stream()` options.
|
|
12
12
|
|
|
@@ -22,7 +22,7 @@ For a one-off completion check within a single `stream()` call, use [`isTaskComp
|
|
|
22
22
|
|
|
23
23
|
## Quickstart
|
|
24
24
|
|
|
25
|
-
Goals require a configured [storage](https://mastra.ai/docs/
|
|
25
|
+
Goals require a configured [storage](https://mastra.ai/docs/storage/overview) backend and a memory-backed thread. Add a `goal` config to the agent — a judge model is required for the goal to do anything — then set an objective for a thread:
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
28
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -89,7 +89,7 @@ Each evaluation emits a typed `goal` stream chunk (`GoalEvaluationPayload`: `obj
|
|
|
89
89
|
|
|
90
90
|
## Managing the objective
|
|
91
91
|
|
|
92
|
-
Control the objective for a thread with `Agent` methods. All of them no-op when the run
|
|
92
|
+
Control the objective for a thread with `Agent` methods. All of them no-op when the run isn't memory-backed (they require storage and a `threadId`):
|
|
93
93
|
|
|
94
94
|
```typescript
|
|
95
95
|
// Read the current objective record.
|
|
@@ -103,12 +103,10 @@ await worker.updateObjectiveOptions({ threadId, maxRuns: 100 })
|
|
|
103
103
|
await worker.clearObjective({ threadId })
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
Per-objective values written by `setObjective` / `updateObjectiveOptions` take precedence over the agent's `goal` config, and that precedence is remembered in thread state.
|
|
107
|
-
|
|
108
|
-
> **Note:** See the [`GoalEvaluationPayload` in the ChunkType reference](https://mastra.ai/reference/streaming/ChunkType) for the full goal chunk shape.
|
|
106
|
+
Per-objective values written by `setObjective` / `updateObjectiveOptions` take precedence over the agent's `goal` config, and that precedence is remembered in thread state. See the [`GoalEvaluationPayload` in the ChunkType reference](https://mastra.ai/reference/streaming/ChunkType) for the full goal chunk shape.
|
|
109
107
|
|
|
110
108
|
## Related
|
|
111
109
|
|
|
112
110
|
- [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents) — `isTaskComplete` and the rubric scorer
|
|
113
111
|
- [Signal providers](https://mastra.ai/docs/long-running-agents/signal-providers) — how the objective is projected into context
|
|
114
|
-
- [Memory storage](https://mastra.ai/docs/
|
|
112
|
+
- [Memory storage](https://mastra.ai/docs/storage/overview) — the storage backend goals require
|
|
@@ -10,7 +10,7 @@ A schedule runs an agent on a cron cadence. On each fire, Mastra sends a prompt
|
|
|
10
10
|
|
|
11
11
|
Schedules are persisted, so they survive restarts and redeploys. Manage them at runtime through [`mastra.schedules`](https://mastra.ai/reference/schedules/overview), the canonical create, read, update, and delete (CRUD) surface. The same surface also manages [workflow schedules](https://mastra.ai/docs/workflows/scheduled-workflows) (pass `workflowId` instead of `agentId` to schedule a workflow).
|
|
12
12
|
|
|
13
|
-
> **Note:** Schedules require a [storage](https://mastra.ai/docs/
|
|
13
|
+
> **Note:** Schedules require a [storage](https://mastra.ai/docs/storage/overview) adapter that implements the schedules domain. See the [`mastra.schedules` reference](https://mastra.ai/reference/schedules/overview) for supported adapters and API behavior.
|
|
14
14
|
|
|
15
15
|
## Quickstart
|
|
16
16
|
|
|
@@ -157,9 +157,7 @@ export class CiSignals extends SignalProvider<'ci-signals'> {
|
|
|
157
157
|
}
|
|
158
158
|
```
|
|
159
159
|
|
|
160
|
-
`handleWebhook()` is a provider method, not an auto-mounted HTTP route. Invoke it from your own endpoint, passing the request body, headers, and any route params.
|
|
161
|
-
|
|
162
|
-
> **Note:** Visit [`SignalProvider` reference](https://mastra.ai/reference/signals/signal-provider) for subscription, polling, lifecycle, and `notify()` details. For the complete notification payload shape, including deduplication and coalescing fields, visit [`Agent.sendNotificationSignal()` reference](https://mastra.ai/reference/agents/agent).
|
|
160
|
+
`handleWebhook()` is a provider method, not an auto-mounted HTTP route. Invoke it from your own endpoint, passing the request body, headers, and any route params. Visit [`SignalProvider` reference](https://mastra.ai/reference/signals/signal-provider) for subscription, polling, lifecycle, and `notify()` details. For the complete notification payload shape, including deduplication and coalescing fields, visit [`Agent.sendNotificationSignal()` reference](https://mastra.ai/reference/agents/agent).
|
|
163
161
|
|
|
164
162
|
## Built-in webhook provider
|
|
165
163
|
|
|
@@ -10,6 +10,8 @@ Signals are a way to interact with an agent through a thread. Instead of startin
|
|
|
10
10
|
|
|
11
11
|
Use message APIs for user-authored input. Use `sendSignal()` for lower-level system context, such as background task notifications, policy reminders, or processor-generated context.
|
|
12
12
|
|
|
13
|
+
> **📹 Watch:** Watch [Mastra signals overview](https://www.youtube.com/watch?v=7It2y89TVP4) to see how signals wake and steer long-running agents.
|
|
14
|
+
|
|
13
15
|
## When to use signals
|
|
14
16
|
|
|
15
17
|
Use signals when an agent thread needs new input or context outside the original `stream()` call. Signals are useful when users send follow-up messages while a run is active, when background systems need to add context to a thread, or when external events should wake, update, or notify the agent.
|
|
@@ -110,9 +112,7 @@ const result = agent.sendSignal(
|
|
|
110
112
|
await result.persisted
|
|
111
113
|
```
|
|
112
114
|
|
|
113
|
-
Pass `ifIdle.streamOptions` when the idle wake-up stream needs options such as model settings, tools, or runtime context.
|
|
114
|
-
|
|
115
|
-
> **Note:** Visit [`Agent.sendSignal()` reference](https://mastra.ai/reference/agents/agent) for `ifActive`, `ifIdle`, branch attributes, and `streamOptions`.
|
|
115
|
+
Pass `ifIdle.streamOptions` when the idle wake-up stream needs options such as model settings, tools, or runtime context. Visit [`Agent.sendSignal()` reference](https://mastra.ai/reference/agents/agent) for `ifActive`, `ifIdle`, branch attributes, and `streamOptions`.
|
|
116
116
|
|
|
117
117
|
### Send notification context
|
|
118
118
|
|
|
@@ -197,9 +197,7 @@ Awaiting `sendSignal()` preserves stream echo ordering when a subscribed thread
|
|
|
197
197
|
|
|
198
198
|
### Conditional attributes
|
|
199
199
|
|
|
200
|
-
Use `ifActive.attributes` and `ifIdle.attributes` to tag input with context that depends on whether the agent is active or idle at delivery time. Top-level `attributes` always apply, and Mastra merges the selected branch's `attributes` into them when the input is accepted.
|
|
201
|
-
|
|
202
|
-
> **Note:** Visit [`Agent.sendMessage()` reference](https://mastra.ai/reference/agents/agent) and [`Agent.sendSignal()` reference](https://mastra.ai/reference/agents/agent) for branch-specific attributes.
|
|
200
|
+
Use `ifActive.attributes` and `ifIdle.attributes` to tag input with context that depends on whether the agent is active or idle at delivery time. Top-level `attributes` always apply, and Mastra merges the selected branch's `attributes` into them when the input is accepted. Visit [`Agent.sendMessage()` reference](https://mastra.ai/reference/agents/agent) and [`Agent.sendSignal()` reference](https://mastra.ai/reference/agents/agent) for branch-specific attributes.
|
|
203
201
|
|
|
204
202
|
## State and notification signals
|
|
205
203
|
|
|
@@ -274,9 +272,7 @@ Notification signals represent external events such as GitHub activity, email, S
|
|
|
274
272
|
|
|
275
273
|
Notification delivery has two phases. During ingress, `agent.sendNotificationSignal()` stores a notification record and resolves the agent's delivery policy. During dispatch, Mastra consumes due records and emits full notification or summary signals.
|
|
276
274
|
|
|
277
|
-
The default delivery policy is priority-aware. Urgent notifications deliver immediately, while lower-priority notifications may be batched into summaries or wait until the thread is idle.
|
|
278
|
-
|
|
279
|
-
> **Note:** Visit [`Agent.sendNotificationSignal()` reference](https://mastra.ai/reference/agents/agent) for notification fields, [`Agent` constructor reference](https://mastra.ai/reference/agents/agent) for `notifications.deliveryPolicy` configuration, and [`createNotificationInboxTool()` reference](https://mastra.ai/reference/signals/create-notification-inbox-tool) for inbox tool actions.
|
|
275
|
+
The default delivery policy is priority-aware. Urgent notifications deliver immediately, while lower-priority notifications may be batched into summaries or wait until the thread is idle. Visit [`Agent.sendNotificationSignal()` reference](https://mastra.ai/reference/agents/agent) for notification fields, [`Agent` constructor reference](https://mastra.ai/reference/agents/agent) for `notifications.deliveryPolicy` configuration, and [`createNotificationInboxTool()` reference](https://mastra.ai/reference/signals/create-notification-inbox-tool) for inbox tool actions.
|
|
280
276
|
|
|
281
277
|
```typescript
|
|
282
278
|
await agent.sendNotificationSignal(
|
|
@@ -312,15 +308,11 @@ Notification summaries tell the model that inbox records are waiting:
|
|
|
312
308
|
|
|
313
309
|
When Mastra emits a summary, it clears `summaryAt` and sets `summarySignalId` on each summarized record. The records stay pending and readable. When Mastra emits a full notification, it sets `deliveredSignalId` and marks the record `delivered`. If the inbox tool reads a notification first, it can inject the full notification signal and mark the record `seen`, which prevents duplicate full delivery.
|
|
314
310
|
|
|
315
|
-
Configure a delivery policy on the agent when some notifications should wait for a different dispatch window or summary rollup. Enable scheduled dispatch at the Mastra level when deferred notifications and summary rollups should be delivered automatically.
|
|
316
|
-
|
|
317
|
-
> **Note:** Visit [`Agent` constructor reference](https://mastra.ai/reference/agents/agent) for `notifications.deliveryPolicy` and [`Mastra` class reference](https://mastra.ai/reference/core/mastra-class) for runtime notification dispatch configuration.
|
|
311
|
+
Configure a delivery policy on the agent when some notifications should wait for a different dispatch window or summary rollup. Enable scheduled dispatch at the Mastra level when deferred notifications and summary rollups should be delivered automatically. Visit [`Agent` constructor reference](https://mastra.ai/reference/agents/agent) for `notifications.deliveryPolicy` and [`Mastra` class reference](https://mastra.ai/reference/core/mastra-class) for runtime notification dispatch configuration.
|
|
318
312
|
|
|
319
313
|
#### Notification inbox tool
|
|
320
314
|
|
|
321
|
-
Use `createNotificationInboxTool()` to give agents one tool for inbox actions instead of many CRUD tools. Use `read` after a `<notification-summary>` signal when the agent needs the full records behind the summary. The notification contents are delivered as signals, not as normal tool output.
|
|
322
|
-
|
|
323
|
-
> **Note:** Visit [`createNotificationInboxTool()` reference](https://mastra.ai/reference/signals/create-notification-inbox-tool) for the setup example, input schema, and action behavior.
|
|
315
|
+
Use `createNotificationInboxTool()` to give agents one tool for inbox actions instead of many CRUD tools. Use `read` after a `<notification-summary>` signal when the agent needs the full records behind the summary. The notification contents are delivered as signals, not as normal tool output. Visit [`createNotificationInboxTool()` reference](https://mastra.ai/reference/signals/create-notification-inbox-tool) for the setup example, input schema, and action behavior.
|
|
324
316
|
|
|
325
317
|
`sendNotificationSignal()` requires a storage domain with `notifications` support. Use `sendSignal({ type: 'notification' })` only for lower-level notification-shaped context that should bypass inbox storage.
|
|
326
318
|
|
|
@@ -345,7 +337,7 @@ export const mastra = new Mastra({
|
|
|
345
337
|
})
|
|
346
338
|
```
|
|
347
339
|
|
|
348
|
-
`RedisStreamsPubSub` implements both the event delivery contract and distributed leasing, so a single backend handles cross-instance signal delivery and lease ownership. Vercel's
|
|
340
|
+
`RedisStreamsPubSub` implements both the event delivery contract and distributed leasing, so a single backend handles cross-instance signal delivery and lease ownership. Vercel's managed Redis integration and Upstash Redis both work well. For more on when a distributed pub/sub is needed, see the [PubSub guide](https://mastra.ai/docs/server/pubsub) and the [`RedisStreamsPubSub` reference](https://mastra.ai/reference/pubsub/redis-streams).
|
|
349
341
|
|
|
350
342
|
## Compatibility and APIs
|
|
351
343
|
|
|
@@ -356,15 +348,11 @@ Mastra still accepts legacy signal payloads such as `type: 'user-message'` and `
|
|
|
356
348
|
- `type: 'user-message'`: Normalizes to `type: 'user'` and `tagName: 'user'`
|
|
357
349
|
- `type: 'system-reminder'`: Normalizes to `type: 'reactive'` and `tagName: 'system-reminder'`
|
|
358
350
|
|
|
359
|
-
Existing stored signal rows and older clients continue to load through the compatibility layer. New clients call the message routes when the server supports them; React's thread signal path falls back to the legacy `/signals` route when it detects an older server.
|
|
360
|
-
|
|
361
|
-
> **Note:** Visit [Agent signals reference](https://mastra.ai/reference/agents/agent) for the full message, signal, and subscription types.
|
|
351
|
+
Existing stored signal rows and older clients continue to load through the compatibility layer. New clients call the message routes when the server supports them; React's thread signal path falls back to the legacy `/signals` route when it detects an older server. Visit [Agent signals reference](https://mastra.ai/reference/agents/agent) for the full message, signal, and subscription types.
|
|
362
352
|
|
|
363
353
|
### Approve tool calls
|
|
364
354
|
|
|
365
|
-
When a subscribed run pauses for tool approval, approve or decline the tool call with the subscription-native methods. The resumed chunks arrive through the existing thread subscription.
|
|
366
|
-
|
|
367
|
-
> **Note:** Visit [`client.getAgent().sendToolApproval()` reference](https://mastra.ai/reference/client-js/agents) and [server agent routes](https://mastra.ai/reference/server/routes) for request and response shapes.
|
|
355
|
+
When a subscribed run pauses for tool approval, approve or decline the tool call with the subscription-native methods. The resumed chunks arrive through the existing thread subscription. Visit [`client.getAgent().sendToolApproval()` reference](https://mastra.ai/reference/client-js/agents) and [server agent routes](https://mastra.ai/reference/server/routes) for request and response shapes.
|
|
368
356
|
|
|
369
357
|
### Use HTTP routes
|
|
370
358
|
|
|
@@ -430,4 +418,5 @@ Use heartbeats together with client-side reconnect logic. Heartbeats reduce idle
|
|
|
430
418
|
- [Server agent routes](https://mastra.ai/reference/server/routes)
|
|
431
419
|
- [`client.getAgent().subscribeToThread()`](https://mastra.ai/reference/client-js/agents)
|
|
432
420
|
- [`client.getAgent().sendToolApproval()`](https://mastra.ai/reference/client-js/agents)
|
|
433
|
-
- [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams)
|
|
421
|
+
- [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams)
|
|
422
|
+
- 📹 [Mastra signals workshop](https://www.youtube.com/watch?v=KLg6uFKz9aw\&t=3020s)
|
|
@@ -10,7 +10,7 @@ Use a hosted database when your project needs durable storage that's managed by
|
|
|
10
10
|
|
|
11
11
|
- **Agent memory**: Persist conversation history, working memory, and semantic recall across sessions.
|
|
12
12
|
- **Application data**: Store and retrieve relational or structured data your project needs at runtime.
|
|
13
|
-
- **Vector search**: Store embeddings for
|
|
13
|
+
- **Vector search**: Store embeddings for Retrieval-Augmented Generation and semantic search.
|
|
14
14
|
|
|
15
15
|
## Providers
|
|
16
16
|
|
|
@@ -41,7 +41,7 @@ For most agent-focused projects, **Turso** is the simplest starting point. It pr
|
|
|
41
41
|
|
|
42
42
|
5. Select **Attach database**. Provisioning runs in the background. The database starts in a `provisioning` state and moves to `ready` once the provider finishes setup. Connection details are injected into your project as server runtime environment variables automatically.
|
|
43
43
|
|
|
44
|
-
> **Note:** Hosted databases are created from your platform project settings.
|
|
44
|
+
> **Note:** Hosted databases are created from your platform project settings. No CLI or public API currently provisions them.
|
|
45
45
|
|
|
46
46
|
## Connect from your code
|
|
47
47
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
The GitHub integration links a Mastra platform project to a GitHub repository. When you push changes to your repository Studio and Server will automatically be deployed.
|
|
6
6
|
|
|
7
|
-
> **Note:** The integration only works with repositories hosted on GitHub.com. Self-hosted GitHub Enterprise instances
|
|
7
|
+
> **Note:** The integration only works with repositories hosted on GitHub.com. Self-hosted GitHub Enterprise instances aren't currently supported.
|
|
8
8
|
|
|
9
9
|
After a repository is linked, the platform:
|
|
10
10
|
|
|
@@ -128,4 +128,8 @@ yarn dlx mastra api trace list
|
|
|
128
128
|
bun x mastra api trace list
|
|
129
129
|
```
|
|
130
130
|
|
|
131
|
-
For observability commands, the CLI targets the hosted observability API and can infer credentials from your project environment. See the [`mastra api` CLI reference](https://mastra.ai/reference/cli/mastra) for available observability commands, filtering, pagination, credential resolution, and direct `curl` examples.
|
|
131
|
+
For observability commands, the CLI targets the hosted observability API and can infer credentials from your project environment. See the [`mastra api` CLI reference](https://mastra.ai/reference/cli/mastra) for available observability commands, filtering, pagination, credential resolution, and direct `curl` examples.
|
|
132
|
+
|
|
133
|
+
## Related
|
|
134
|
+
|
|
135
|
+
- 📹 [Mastra observability and Studio workshop](https://www.youtube.com/watch?v=dKO_a3RPra0)
|
|
@@ -81,7 +81,7 @@ calculatorTool._meta = {
|
|
|
81
81
|
}
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
Visit [MCPServer reference](https://mastra.ai/reference/tools/mcp-server) for the full `appResources` configuration.
|
|
85
85
|
|
|
86
86
|
## Connecting MCP Apps to agents
|
|
87
87
|
|
|
@@ -249,7 +249,7 @@ Establishes the connection to the host. Call this after registering all event ha
|
|
|
249
249
|
await app.connect()
|
|
250
250
|
```
|
|
251
251
|
|
|
252
|
-
|
|
252
|
+
See the [`App` class API reference](https://apps.extensions.modelcontextprotocol.io/api/classes/app.App.html) for the full list of methods, callbacks, and lifecycle hooks.
|
|
253
253
|
|
|
254
254
|
## Using external MCP servers with apps
|
|
255
255
|
|
|
@@ -284,7 +284,7 @@ export const mastra = new Mastra({
|
|
|
284
284
|
})
|
|
285
285
|
```
|
|
286
286
|
|
|
287
|
-
|
|
287
|
+
Visit [MCPClient reference](https://mastra.ai/reference/tools/mcp-client) for more details on proxying external servers.
|
|
288
288
|
|
|
289
289
|
## Sandbox security
|
|
290
290
|
|
|
@@ -62,7 +62,7 @@ export const testMcpClient = new MCPClient({
|
|
|
62
62
|
})
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
Visit [MCPClient](https://mastra.ai/reference/tools/mcp-client) for a full list of configuration options.
|
|
66
66
|
|
|
67
67
|
> **Authentication:** For connecting to OAuth-protected MCP servers, see the [OAuth Authentication](https://mastra.ai/reference/tools/mcp-client) section.
|
|
68
68
|
|
|
@@ -89,7 +89,7 @@ export const testAgent = new Agent({
|
|
|
89
89
|
})
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
Visit [Agent Class](https://mastra.ai/reference/agents/agent) for a full list of configuration options.
|
|
93
93
|
|
|
94
94
|
## Tool approval
|
|
95
95
|
|
|
@@ -129,7 +129,7 @@ export const testMcpServer = new MCPServer({
|
|
|
129
129
|
})
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
Visit [MCPServer](https://mastra.ai/reference/tools/mcp-server) for a full list of configuration options.
|
|
133
133
|
|
|
134
134
|
> **Authentication:** To protect your MCP server with OAuth, see the [OAuth Protection](https://mastra.ai/reference/tools/mcp-server) section.
|
|
135
135
|
|
|
@@ -160,9 +160,7 @@ export const mastra = new Mastra({
|
|
|
160
160
|
|
|
161
161
|
### Static tools
|
|
162
162
|
|
|
163
|
-
Use the `.listTools()` method to fetch tools from all configured MCP servers. This is suitable when configuration (such as API keys) is static and consistent across users or requests. Call it once and pass the result to the `tools` property when defining your agent.
|
|
164
|
-
|
|
165
|
-
> **Info:** Visit [listTools()](https://mastra.ai/reference/tools/mcp-client) for more information.
|
|
163
|
+
Use the `.listTools()` method to fetch tools from all configured MCP servers. This is suitable when configuration (such as API keys) is static and consistent across users or requests. Call it once and pass the result to the `tools` property when defining your agent. Visit [listTools()](https://mastra.ai/reference/tools/mcp-client) for more information.
|
|
166
164
|
|
|
167
165
|
```typescript
|
|
168
166
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -211,7 +209,7 @@ async function handleRequest(userPrompt: string, userApiKey: string) {
|
|
|
211
209
|
}
|
|
212
210
|
```
|
|
213
211
|
|
|
214
|
-
|
|
212
|
+
Visit [listToolsets()](https://mastra.ai/reference/tools/mcp-client) for more information.
|
|
215
213
|
|
|
216
214
|
## Connecting to an MCP registry
|
|
217
215
|
|
|
@@ -412,9 +410,7 @@ As an alternative to MCP, Ampersand's AI SDK also has an adapter for Mastra, so
|
|
|
412
410
|
|
|
413
411
|
## MCP Apps
|
|
414
412
|
|
|
415
|
-
MCP servers can serve interactive HTML UIs via the MCP Apps extension. Tools with associated `ui://` resources render sandboxed iframes in Studio — both on tool detail pages and inline in agent chat. The app iframe can call server tools and inject messages into the conversation.
|
|
416
|
-
|
|
417
|
-
> **Note:** Visit [MCP Apps](https://mastra.ai/docs/mcp/mcp-apps) for setup instructions and the app bridge API.
|
|
413
|
+
MCP servers can serve interactive HTML UIs via the MCP Apps extension. Tools with associated `ui://` resources render sandboxed iframes in Studio — both on tool detail pages and inline in agent chat. The app iframe can call server tools and inject messages into the conversation. Visit [MCP Apps](https://mastra.ai/docs/mcp/mcp-apps) for setup instructions and the app bridge API.
|
|
418
414
|
|
|
419
415
|
## Related
|
|
420
416
|
|
|
@@ -309,6 +309,73 @@ const agent = new Agent({
|
|
|
309
309
|
|
|
310
310
|
Both scenarios are safe - guardrails prevent inappropriate content from being persisted to memory
|
|
311
311
|
|
|
312
|
+
## Handling large attachments
|
|
313
|
+
|
|
314
|
+
Some storage providers enforce record size limits that base64-encoded file attachments can exceed:
|
|
315
|
+
|
|
316
|
+
| Provider | Record size limit |
|
|
317
|
+
| ------------------------------------------------------------------ | ----------------- |
|
|
318
|
+
| [DynamoDB](https://mastra.ai/reference/storage/dynamodb) | 400 KB |
|
|
319
|
+
| [Convex](https://mastra.ai/reference/storage/convex) | 1 MiB |
|
|
320
|
+
| [Cloudflare D1](https://mastra.ai/reference/storage/cloudflare-d1) | 1 MiB |
|
|
321
|
+
|
|
322
|
+
PostgreSQL, MongoDB, and libSQL have higher limits and are usually unaffected.
|
|
323
|
+
|
|
324
|
+
Use an input processor to upload attachments to external storage, then replace them with URL references before messages are persisted.
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
import type { Processor } from '@mastra/core/processors'
|
|
328
|
+
import type { MastraDBMessage } from '@mastra/core/memory'
|
|
329
|
+
|
|
330
|
+
export class AttachmentUploader implements Processor {
|
|
331
|
+
id = 'attachment-uploader'
|
|
332
|
+
|
|
333
|
+
async processInput({ messages }: { messages: MastraDBMessage[] }) {
|
|
334
|
+
return Promise.all(messages.map(message => this.processMessage(message)))
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
async processMessage(message: MastraDBMessage) {
|
|
338
|
+
const attachments = message.content.experimental_attachments
|
|
339
|
+
if (!attachments?.length) return message
|
|
340
|
+
|
|
341
|
+
const uploaded = await Promise.all(
|
|
342
|
+
attachments.map(async attachment => {
|
|
343
|
+
if (!attachment.url?.startsWith('data:')) return attachment
|
|
344
|
+
|
|
345
|
+
const url = await this.upload(attachment.url, attachment.contentType)
|
|
346
|
+
return { ...attachment, url }
|
|
347
|
+
}),
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
return { ...message, content: { ...message.content, experimental_attachments: uploaded } }
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
async upload(dataUri: string, contentType?: string): Promise<string> {
|
|
354
|
+
const base64 = dataUri.split(',')[1]
|
|
355
|
+
const buffer = Buffer.from(base64, 'base64')
|
|
356
|
+
|
|
357
|
+
throw new Error('Implement upload() with your storage provider')
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Use the processor with your agent:
|
|
363
|
+
|
|
364
|
+
```typescript
|
|
365
|
+
import { Agent } from '@mastra/core/agent'
|
|
366
|
+
import { Memory } from '@mastra/memory'
|
|
367
|
+
import { AttachmentUploader } from '../processors/attachment-uploader'
|
|
368
|
+
|
|
369
|
+
export const supportAgent = new Agent({
|
|
370
|
+
id: 'support-agent',
|
|
371
|
+
name: 'Support agent',
|
|
372
|
+
instructions: 'Answer customer support questions.',
|
|
373
|
+
model: 'openai/gpt-5.5',
|
|
374
|
+
memory: new Memory({ lastMessages: 10 }),
|
|
375
|
+
inputProcessors: [new AttachmentUploader()],
|
|
376
|
+
})
|
|
377
|
+
```
|
|
378
|
+
|
|
312
379
|
## Related documentation
|
|
313
380
|
|
|
314
381
|
- [Processors](https://mastra.ai/docs/agents/processors): General processor concepts and custom processor creation
|
|
@@ -6,7 +6,7 @@ Message history is the most basic and important form of memory. It gives the LLM
|
|
|
6
6
|
|
|
7
7
|
You can also retrieve message history to display past conversations in your UI.
|
|
8
8
|
|
|
9
|
-
> **Info:** Each message belongs to a thread (the conversation) and a resource (the user or entity it's associated with). See [Threads and resources](
|
|
9
|
+
> **Info:** Each message belongs to a thread (the conversation) and a resource (the user or entity it's associated with). See [Threads and resources](#threads-and-resources) for more detail.
|
|
10
10
|
|
|
11
11
|
> **Warning:** When you use memory with a client application, send **only the new message** from the client instead of the full conversation history.
|
|
12
12
|
>
|
|
@@ -14,9 +14,18 @@ You can also retrieve message history to display past conversations in your UI.
|
|
|
14
14
|
>
|
|
15
15
|
> For an AI SDK example, see [Using Mastra Memory](https://mastra.ai/guides/build-your-ui/ai-sdk-ui).
|
|
16
16
|
|
|
17
|
+
## Threads and resources
|
|
18
|
+
|
|
19
|
+
Mastra organizes conversations using two identifiers:
|
|
20
|
+
|
|
21
|
+
- **Thread**: A conversation session containing a sequence of messages.
|
|
22
|
+
- **Resource**: The entity that owns the thread, such as a user, organization, project, or another domain entity in your application.
|
|
23
|
+
|
|
24
|
+
Studio automatically generates a thread and resource ID for you. When calling `stream()` or `generate()` yourself, provide these identifiers explicitly.
|
|
25
|
+
|
|
17
26
|
## Getting started
|
|
18
27
|
|
|
19
|
-
Install the Mastra memory module along with a [storage adapter](https://mastra.ai/docs/
|
|
28
|
+
Install the Mastra memory module along with a [storage adapter](https://mastra.ai/docs/storage/overview) for your database. The examples below use `@mastra/libsql`, which stores data locally in a `mastra.db` file.
|
|
20
29
|
|
|
21
30
|
**npm**:
|
|
22
31
|
|
|
@@ -113,6 +122,51 @@ You can use this history in two ways:
|
|
|
113
122
|
|
|
114
123
|
> **Tip:** When memory is enabled, [Studio](https://mastra.ai/docs/studio/overview) uses message history to display past conversations in the chat sidebar.
|
|
115
124
|
|
|
125
|
+
## Thread title generation
|
|
126
|
+
|
|
127
|
+
Mastra can automatically generate descriptive thread titles based on the user's first message when `generateTitle` is enabled. Use this option when you build a chat interface that renders conversation titles in a thread list or sidebar.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import { Agent } from '@mastra/core/agent'
|
|
131
|
+
import { Memory } from '@mastra/memory'
|
|
132
|
+
|
|
133
|
+
export const supportAgent = new Agent({
|
|
134
|
+
id: 'support-agent',
|
|
135
|
+
name: 'Support agent',
|
|
136
|
+
instructions: 'Answer customer support questions.',
|
|
137
|
+
model: 'openai/gpt-5.5',
|
|
138
|
+
memory: new Memory({
|
|
139
|
+
options: {
|
|
140
|
+
generateTitle: true,
|
|
141
|
+
},
|
|
142
|
+
}),
|
|
143
|
+
})
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Title generation runs asynchronously after the agent responds and doesn't affect response time.
|
|
147
|
+
|
|
148
|
+
To optimize cost or behavior, provide a smaller [`model`](https://mastra.ai/models) and custom `instructions`:
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { Agent } from '@mastra/core/agent'
|
|
152
|
+
import { Memory } from '@mastra/memory'
|
|
153
|
+
|
|
154
|
+
export const supportAgent = new Agent({
|
|
155
|
+
id: 'support-agent',
|
|
156
|
+
name: 'Support agent',
|
|
157
|
+
instructions: 'Answer customer support questions.',
|
|
158
|
+
model: 'openai/gpt-5.5',
|
|
159
|
+
memory: new Memory({
|
|
160
|
+
options: {
|
|
161
|
+
generateTitle: {
|
|
162
|
+
model: 'openai/gpt-5-mini',
|
|
163
|
+
instructions: 'Generate a one-word title.',
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
}),
|
|
167
|
+
})
|
|
168
|
+
```
|
|
169
|
+
|
|
116
170
|
## Accessing memory
|
|
117
171
|
|
|
118
172
|
To access memory functions for querying, cloning, or deleting threads and messages, call `getMemory()` on an agent:
|
|
@@ -217,7 +217,7 @@ new Extractor({
|
|
|
217
217
|
})
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
-
By default, OM shows the last extracted value to the extractor on later runs. Set `includePreviousExtraction: false` when the Observer
|
|
220
|
+
By default, OM shows the last extracted value to the extractor on later runs. Set `includePreviousExtraction: false` when the Observer shouldn't see the previous value.
|
|
221
221
|
|
|
222
222
|
```typescript
|
|
223
223
|
new Extractor({
|
|
@@ -263,7 +263,7 @@ const memory = new Memory({
|
|
|
263
263
|
|
|
264
264
|
This setting adds `WorkingMemoryExtractor`, defaults `workingMemory.agentManaged` to `false`, and defaults `workingMemory.useStateSignals` to `true`. Set `workingMemory.agentManaged: true` if the main agent should still receive working memory tool and instruction injection.
|
|
265
265
|
|
|
266
|
-
Use `onExtracted` to normalize or react to custom extracted values before they
|
|
266
|
+
Use `onExtracted` to normalize or react to custom extracted values before they're persisted:
|
|
267
267
|
|
|
268
268
|
```typescript
|
|
269
269
|
new Extractor({
|
|
@@ -280,7 +280,7 @@ new Extractor({
|
|
|
280
280
|
})
|
|
281
281
|
```
|
|
282
282
|
|
|
283
|
-
Extractor failures are reported in OM markers and
|
|
283
|
+
Extractor failures are reported in OM markers and don't block other successful extractor values. See [the API reference](https://mastra.ai/reference/memory/observational-memory) for the full `Extractor` shape.
|
|
284
284
|
|
|
285
285
|
If your Observer model is text-only or its API rejects multimodal input, set `observation.observeAttachments` to `false` to drop attachments before they reach the Observer. The readable placeholders (`[Image #1: ...]`, `[File #1: ...]`) are kept in the transcript so the Observer can still reason about what was shared without receiving the binary payload. The same filter applies to tool results that contain image or file parts:
|
|
286
286
|
|
|
@@ -714,4 +714,5 @@ In practical terms, OM replaces both working memory and message history, and has
|
|
|
714
714
|
- [Memory Overview](https://mastra.ai/docs/memory/overview)
|
|
715
715
|
- [Message History](https://mastra.ai/docs/memory/message-history)
|
|
716
716
|
- [Memory Processors](https://mastra.ai/docs/memory/memory-processors)
|
|
717
|
-
- [Mastra Code](https://code.mastra.ai/): A coding agent using Observational Memory
|
|
717
|
+
- [Mastra Code](https://code.mastra.ai/): A coding agent using Observational Memory
|
|
718
|
+
- 📹 [Mastra processors and Observational Memory workshop](https://www.youtube.com/watch?v=4Vpp7xQYvl0)
|
|
@@ -13,7 +13,9 @@ Mastra agents can be configured to store [message history](https://mastra.ai/doc
|
|
|
13
13
|
|
|
14
14
|
If the combined memory exceeds the model's context limit, [memory processors](https://mastra.ai/docs/memory/memory-processors) can filter, trim, or prioritize content so the most relevant information is preserved.
|
|
15
15
|
|
|
16
|
-
Memory results will be stored in one or more of your configured [storage providers](https://mastra.ai/docs/
|
|
16
|
+
Memory results will be stored in one or more of your configured [storage providers](https://mastra.ai/docs/storage/overview).
|
|
17
|
+
|
|
18
|
+
> **📹 Watch:** Watch [Mastra memory concepts](https://www.youtube.com/watch?v=18iIHQtIPmc) for a conceptual overview of the memory layers agents can use.
|
|
17
19
|
|
|
18
20
|
## When to use memory
|
|
19
21
|
|
|
@@ -75,7 +77,7 @@ Use memory when your agent needs to maintain multi-turn conversations that refer
|
|
|
75
77
|
bun add @mastra/libsql@latest
|
|
76
78
|
```
|
|
77
79
|
|
|
78
|
-
|
|
80
|
+
For more details on available providers and how storage works in Mastra, visit the [storage](https://mastra.ai/docs/storage/overview) documentation.
|
|
79
81
|
|
|
80
82
|
3. Add the storage provider to your main Mastra instance to enable memory across all configured agents.
|
|
81
83
|
|
|
@@ -108,7 +110,7 @@ Use memory when your agent needs to maintain multi-turn conversations that refer
|
|
|
108
110
|
})
|
|
109
111
|
```
|
|
110
112
|
|
|
111
|
-
|
|
113
|
+
Visit [Memory Class](https://mastra.ai/reference/memory/memory-class) for a full list of configuration options.
|
|
112
114
|
|
|
113
115
|
5. Call your agent, for example in [Studio](https://mastra.ai/docs/studio/overview). Inside Studio, start a new chat with your agent and take a look at the right sidebar. It'll now display various memory-related information.
|
|
114
116
|
|
|
@@ -164,7 +166,7 @@ export const memoryAgent = new Agent({
|
|
|
164
166
|
})
|
|
165
167
|
```
|
|
166
168
|
|
|
167
|
-
|
|
169
|
+
See [Observational Memory](https://mastra.ai/docs/memory/observational-memory) for details on how observations and reflections work, and [the reference](https://mastra.ai/reference/memory/observational-memory) for all configuration options.
|
|
168
170
|
|
|
169
171
|
## Memory in multi-agent systems
|
|
170
172
|
|
|
@@ -178,7 +180,7 @@ Each delegation creates a fresh `threadId` and a deterministic `resourceId` for
|
|
|
178
180
|
- **Resource ID**: Derived as `{parentResourceId}-{agentName}`. Because the resource ID is stable across delegations, resource-scoped memory persists between calls. A subagent remembers facts from previous delegations by the same user.
|
|
179
181
|
- **Memory instance**: If a subagent has no memory configured, it inherits the supervisor's `Memory` instance, including all of its options. If the subagent defines its own, that takes precedence.
|
|
180
182
|
|
|
181
|
-
> **Note:** Title generation (`generateTitle`) is a top-level thread concern and
|
|
183
|
+
> **Note:** Title generation (`generateTitle`) is a top-level thread concern and **isn't** applied to inherited subagent threads. Because each delegation creates an ephemeral thread that no one sees, running title generation for it would waste an LLM call per delegation. To generate titles for a subagent's own threads, give that subagent its own memory configuration.
|
|
182
184
|
|
|
183
185
|
The supervisor forwards its conversation context to the subagent so it has enough background to complete the task. Only the delegation prompt and the subagent's response are saved — the full parent conversation isn't stored. You can control which messages reach the subagent with the [`messageFilter`](https://mastra.ai/docs/agents/supervisor-agents) callback.
|
|
184
186
|
|
|
@@ -236,7 +238,7 @@ export const memoryAgent = new Agent({
|
|
|
236
238
|
})
|
|
237
239
|
```
|
|
238
240
|
|
|
239
|
-
|
|
241
|
+
Visit [Request Context](https://mastra.ai/docs/server/request-context) for more information.
|
|
240
242
|
|
|
241
243
|
## Related
|
|
242
244
|
|