@mastra/mcp-docs-server 1.3.2-alpha.6 → 1.3.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/.docs/docs/agents/code-mode.md +1 -1
- package/.docs/docs/agents/human-in-the-loop.md +4 -2
- package/.docs/docs/agents/processors.md +3 -3
- package/.docs/docs/agents/tools.md +3 -1
- package/.docs/docs/connections/acp.md +3 -3
- package/.docs/docs/connections/mcp.md +1 -1
- package/.docs/docs/deployment/workers.md +7 -2
- package/.docs/docs/develop.md +4 -4
- package/.docs/docs/evals/datasets.md +1 -1
- package/.docs/docs/evals/evals-with-memory.md +7 -6
- package/.docs/docs/evals/experiments.md +4 -4
- package/.docs/docs/evals/multi-turn.md +2 -2
- package/.docs/docs/evals/vitest-integration.md +1 -1
- package/.docs/docs/harness/agent-controller.md +6 -4
- package/.docs/docs/harness/background-tasks.md +2 -2
- package/.docs/docs/harness/durable-agents.md +2 -2
- package/.docs/docs/harness/goals.md +27 -4
- package/.docs/docs/harness/schedules.md +28 -1
- package/.docs/docs/harness/signals.md +2 -2
- package/.docs/docs/mastra-platform/deploy.md +1 -1
- package/.docs/docs/mastra-platform/environments.md +1 -1
- package/.docs/docs/mastra-platform/observability.md +1 -1
- package/.docs/docs/mastra-platform/workspaces.md +1 -1
- package/.docs/docs/memory/observational-memory.md +3 -3
- package/.docs/docs/memory/overview.md +1 -1
- package/.docs/docs/sandbox/skills.md +1 -1
- package/.docs/docs/server/pubsub.md +1 -1
- package/.docs/docs/server/server-adapters.md +1 -1
- package/.docs/docs/studio/auth.md +1 -1
- package/.docs/docs/workflows/control-flow.md +4 -1
- package/.docs/docs/workflows/dynamic-workflows.md +1 -1
- package/.docs/docs/workflows/overview.md +1 -1
- package/.docs/docs/workflows/scheduled-workflows.md +11 -7
- package/.docs/integrations/frameworks/nestjs.md +34 -1
- package/.docs/models/environment-variables.md +2 -0
- package/.docs/models/gateways/merge-gateway.md +2 -1
- package/.docs/models/gateways/netlify.md +3 -6
- package/.docs/models/gateways/openrouter.md +5 -4
- package/.docs/models/gateways/vercel.md +7 -4
- package/.docs/models/index.md +212 -2
- package/.docs/models/providers/302ai.md +5 -1
- package/.docs/models/providers/alibaba-cn.md +2 -1
- package/.docs/models/providers/alibaba-coding-plan-cn.md +1 -3
- package/.docs/models/providers/alibaba-coding-plan.md +1 -3
- package/.docs/models/providers/alibaba.md +5 -2
- package/.docs/models/providers/ambient.md +3 -1
- package/.docs/models/providers/anthropic.md +3 -2
- package/.docs/models/providers/bailing.md +1 -1
- package/.docs/models/providers/bee.md +82 -0
- package/.docs/models/providers/cloudflare-workers-ai.md +3 -3
- package/.docs/models/providers/coralbricks.md +2 -3
- package/.docs/models/providers/cortecs.md +1 -1
- package/.docs/models/providers/crossmodel.md +2 -1
- package/.docs/models/providers/deepinfra.md +2 -1
- package/.docs/models/providers/digitalocean.md +2 -1
- package/.docs/models/providers/edenai.md +287 -287
- package/.docs/models/providers/fireworks-ai.md +4 -7
- package/.docs/models/providers/kilo.md +25 -25
- package/.docs/models/providers/llmgateway-providers.md +24 -13
- package/.docs/models/providers/llmgateway.md +16 -8
- package/.docs/models/providers/minimax-cn-coding-plan.md +12 -11
- package/.docs/models/providers/minimax-coding-plan.md +12 -11
- package/.docs/models/providers/mistral.md +1 -2
- package/.docs/models/providers/nan.md +3 -2
- package/.docs/models/providers/nano-gpt.md +8 -6
- package/.docs/models/providers/nebius.md +2 -1
- package/.docs/models/providers/nvidia.md +1 -47
- package/.docs/models/providers/ofox.md +3 -1
- package/.docs/models/providers/openai.md +44 -41
- package/.docs/models/providers/opencode-go.md +2 -5
- package/.docs/models/providers/opencode.md +4 -2
- package/.docs/models/providers/pareto.md +77 -0
- package/.docs/models/providers/pioneer.md +4 -2
- package/.docs/models/providers/privatemode-ai.md +2 -2
- package/.docs/models/providers/requesty.md +7 -3
- package/.docs/models/providers/scaleway.md +2 -1
- package/.docs/models/providers/tempr.md +26 -2
- package/.docs/models/providers/togetherai.md +1 -3
- package/.docs/models/providers/umans-ai-coding-plan.md +1 -1
- package/.docs/models/providers/umans-ai.md +1 -1
- package/.docs/models/providers.md +2 -0
- package/.docs/reference/agent-controller/session.md +5 -5
- package/.docs/reference/agents/channels.md +3 -1
- package/.docs/reference/agents/durable-agent.md +3 -1
- package/.docs/reference/channels/teams-provider.md +189 -0
- package/.docs/reference/classifier/classifier.md +47 -5
- package/.docs/reference/client-js/agent-controller.md +1 -1
- package/.docs/reference/code-sdk/acp-server.md +101 -0
- package/.docs/reference/configuration.md +4 -1
- package/.docs/reference/datasets/finalizeExperiment.md +1 -1
- package/.docs/reference/evals/create-classifier-scorer.md +4 -1
- package/.docs/reference/file-based-agents/logger.md +1 -1
- package/.docs/reference/file-based-agents/schedules.md +3 -3
- package/.docs/reference/file-based-agents/workspace.md +1 -1
- package/.docs/reference/index.md +2 -0
- package/.docs/reference/migrations/mcp-v2.md +1 -1
- package/.docs/reference/observability/tracing/interfaces.md +1 -1
- package/.docs/reference/observability/tracing/trace-query.md +37 -16
- package/.docs/reference/processors/classifier-processor.md +14 -4
- package/.docs/reference/processors/model-selection-processor.md +15 -6
- package/.docs/reference/processors/tool-search-processor.md +1 -1
- package/.docs/reference/pubsub/google-cloud-pubsub.md +1 -1
- package/.docs/reference/pubsub/redis-streams.md +3 -3
- package/.docs/reference/rag/graph-rag.md +1 -1
- package/.docs/reference/storage/retention.md +1 -1
- package/.docs/reference/workers/overview.md +3 -1
- package/.docs/reference/workflows/step.md +4 -1
- package/.docs/reference/workflows/workflow.md +1 -1
- package/.docs/reference/workspace/local-sandbox.md +2 -0
- package/.docs/reference/workspace/platform-sandbox.md +1 -1
- package/.docs/reference/workspace/sandbox.md +1 -1
- package/.docs/reference/workspace/workspace-class.md +1 -1
- package/package.json +6 -6
|
@@ -106,7 +106,7 @@ Visit the [`createCodeMode()` reference](https://mastra.ai/reference/tools/creat
|
|
|
106
106
|
|
|
107
107
|
## Scoping tools across multiple code tools
|
|
108
108
|
|
|
109
|
-
`createCodeMode()` captures its own allow-list. Call it more than once to give an agent several code tools, each scoped to a different subset of tools.
|
|
109
|
+
`createCodeMode()` captures its own allow-list. Call it more than once to give an agent several code tools, each scoped to a different subset of tools. Each instance can only call the `external_*` functions for the tools passed to its own `createCodeMode()` call. The subsets stay isolated.
|
|
110
110
|
|
|
111
111
|
Give each tool a distinct `id` so their ids don't collide, and add each tool's instructions to the agent:
|
|
112
112
|
|
|
@@ -120,12 +120,14 @@ The function can be asynchronous. For decisions that depend on the tool name and
|
|
|
120
120
|
|
|
121
121
|
```typescript
|
|
122
122
|
import { Classifier } from '@mastra/core/classifier'
|
|
123
|
-
import {
|
|
123
|
+
import { createTypeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
124
124
|
import { agent } from './agent'
|
|
125
125
|
|
|
126
126
|
const approvalClassifier = new Classifier({
|
|
127
127
|
id: 'tool-approval-classifier',
|
|
128
|
-
model
|
|
128
|
+
model: createTypeSafeAi({ apiKey: process.env.TYPESAFE_AI_API_KEY }).evaluationModel(
|
|
129
|
+
'jev-latest',
|
|
130
|
+
),
|
|
129
131
|
questions: {
|
|
130
132
|
requiresApproval: {
|
|
131
133
|
type: 'boolean',
|
|
@@ -349,7 +349,7 @@ For more on retry behavior, see [Retry mechanism](#retry-mechanism) in Advanced
|
|
|
349
349
|
|
|
350
350
|
### Persist data across chunks and steps
|
|
351
351
|
|
|
352
|
-
Output methods receive a `state` object that persists for the lifetime of one request. State is keyed by the processor's `id
|
|
352
|
+
Output methods receive a `state` object that persists for the lifetime of one request. State is keyed by the processor's `id`. Each processor sees only its own data, and it's shared between `processOutputStream`, `processOutputStep`, and `processOutputResult`. A new state object is created for every new `agent.generate()` or `agent.stream()` call.
|
|
353
353
|
|
|
354
354
|
```typescript
|
|
355
355
|
import type { Processor } from '@mastra/core/processors'
|
|
@@ -577,7 +577,7 @@ If the function throws, the processor falls back to the default key derivation s
|
|
|
577
577
|
|
|
578
578
|
When the processor finds a cache hit, it short-circuits the LLM call by returning the cached chunks from `processLLMRequest`. The agentic loop synthesizes a stream from those chunks instead of calling the model. `agent.generate()` collects them into a `FullOutput`; `agent.stream()` returns a `MastraModelOutput` whose chunks come from the cached buffer, so consumers iterating `fullStream` or awaiting `text`, `usage`, and `finishReason` see the cached values.
|
|
579
579
|
|
|
580
|
-
Cache writes happen after the response completes. Failed runs (errors, tripwire activations) aren't cached
|
|
580
|
+
Cache writes happen after the response completes. Failed runs (errors, tripwire activations) aren't cached. The next call retries cleanly.
|
|
581
581
|
|
|
582
582
|
## Advanced patterns
|
|
583
583
|
|
|
@@ -666,7 +666,7 @@ export class SteeringReminderProcessor implements Processor {
|
|
|
666
666
|
}
|
|
667
667
|
```
|
|
668
668
|
|
|
669
|
-
A transient signal is still in the prompt for the current call
|
|
669
|
+
A transient signal is still in the prompt for the current call. The model sees it near the latest turn. It's not retained, so re-sending it each turn keeps a single fresh copy in context instead of an accumulating history, and stored thread history never includes it. Because nothing is written, it also keeps a stable prompt cache prefix across turns.
|
|
670
670
|
|
|
671
671
|
### Emit custom stream events
|
|
672
672
|
|
|
@@ -281,7 +281,7 @@ export const weatherTool = createTool({
|
|
|
281
281
|
})
|
|
282
282
|
```
|
|
283
283
|
|
|
284
|
-
`toModelOutput` also works with client-side tools. For tools passed through `clientTools`, the mapping runs on the client after the tool executes, and the transformed output is sent back to the server alongside the raw result. For tools defined on the server without an `execute` function (the browser runs the tool and sends the result back on the next request), the server definition's `toModelOutput` is applied to the incoming result
|
|
284
|
+
`toModelOutput` also works with client-side tools. For tools passed through `clientTools`, the mapping runs on the client after the tool executes, and the transformed output is sent back to the server alongside the raw result. For tools defined on the server without an `execute` function (the browser runs the tool and sends the result back on the next request), the server definition's `toModelOutput` is applied to the incoming result. The model receives the transformed content instead of the raw tool result.
|
|
285
285
|
|
|
286
286
|
## Transform tool payloads for UI and transcripts
|
|
287
287
|
|
|
@@ -324,6 +324,8 @@ export const customerTool = createTool({
|
|
|
324
324
|
|
|
325
325
|
Your application code still receives the raw `ssn` from the tool. Browser-facing streams get the `display` output, and user-visible transcript messages get the `transcript` output.
|
|
326
326
|
|
|
327
|
+
When a DurableAgent can finish a tool call after a process restart, declare required transcript redaction in the tool's `transform.transcript` configuration. A per-invocation transform passed to the DurableAgent lives in the in-process run registry and can't be recovered in a fresh process. The durable worker re-resolves the tool-level transform from the registered tool.
|
|
328
|
+
|
|
327
329
|
For more phases, including `input`, `inputDelta`, `error`, `approval`, `suspend`, and `resume`, see the [`createTool()` reference](https://mastra.ai/reference/tools/create-tool). For shared rules across several tools, configure the agent-level `transform` policy in the [`Agent` constructor](https://mastra.ai/reference/agents/agent).
|
|
328
330
|
|
|
329
331
|
## Run logic around tool calls
|
|
@@ -30,7 +30,7 @@ The flow is:
|
|
|
30
30
|
6. Mastra returns the buffered output or emits streaming chunks, or alternatively handles permission input.
|
|
31
31
|
7. The ACP connection stops the process after the prompt when `persistSession` is `false`. `AcpAgent` can keep a reusable process alive across calls by default.
|
|
32
32
|
|
|
33
|
-
During execution, the ACP client also handles permission requests and file operations. File reads and writes go through Mastra's `Workspace
|
|
33
|
+
During execution, the ACP client also handles permission requests and file operations. File reads and writes that the agent requests through the protocol go through Mastra's `Workspace`. The workspace covers only those requests: the agent process runs with the configured `cwd` and isn't sandboxed or isolated, and it can still reach files through its own tools and shell commands.
|
|
34
34
|
|
|
35
35
|
## Compatible agents
|
|
36
36
|
|
|
@@ -144,7 +144,7 @@ See the [AcpAgent model management methods](https://mastra.ai/reference/acp/acp-
|
|
|
144
144
|
|
|
145
145
|
## Session lifecycle
|
|
146
146
|
|
|
147
|
-
`AcpAgent` starts the configured command on first use and creates an ACP session. By default, `persistSession` is `true
|
|
147
|
+
`AcpAgent` starts the configured command on first use and creates an ACP session. By default, `persistSession` is `true`. The child process stays alive across calls. Set `persistSession: false` when each prompt should run in an isolated process.
|
|
148
148
|
|
|
149
149
|
See the [AcpAgent session lifecycle](https://mastra.ai/reference/acp/acp-agent) section for details.
|
|
150
150
|
|
|
@@ -156,7 +156,7 @@ See the [createACPTool() permission handling](https://mastra.ai/reference/acp/cr
|
|
|
156
156
|
|
|
157
157
|
## Workspace integration
|
|
158
158
|
|
|
159
|
-
ACP file
|
|
159
|
+
ACP file requests go through Mastra's workspace abstraction. `AcpAgent` can use a `workspace` option, and `createACPTool()` uses the current Mastra workspace from the tool execution context when one is available. Without a workspace, `@mastra/acp` falls back to a `Workspace` backed by `LocalFilesystem` at `cwd` or `process.cwd()`.
|
|
160
160
|
|
|
161
161
|
See the [AcpAgent workspace integration](https://mastra.ai/reference/acp/acp-agent) section for custom workspace examples.
|
|
162
162
|
|
|
@@ -204,7 +204,7 @@ export const mastra = new Mastra({
|
|
|
204
204
|
|
|
205
205
|
> **Authentication:** Protect HTTP MCP servers with OAuth middleware. Visit [OAuth protection](https://mastra.ai/reference/tools/mcp-server) for setup instructions.
|
|
206
206
|
|
|
207
|
-
Registered servers are served at `/api/mcp/:serverId/mcp` over Streamable HTTP.
|
|
207
|
+
Registered servers are served at `/api/mcp/:serverId/mcp` over Streamable HTTP. Because every request is self-contained, the same server runs unchanged on long-lived hosts and serverless platforms.
|
|
208
208
|
|
|
209
209
|
A tool that needs something from the user before it can finish calls `context.suspend()` with a payload and declares a `resumeSchema`. The server turns that into an `input_required` round and runs the tool again with the answer in `context.resumeData`. Clients answer those rounds with the `inputRequests` handler on their server definition. Visit [Asking the caller for input](https://mastra.ai/reference/tools/mcp-server) and [Answering input requests](https://mastra.ai/reference/tools/mcp-client).
|
|
210
210
|
|
|
@@ -35,7 +35,10 @@ The orchestration worker requires a PubSub backend that supports pull mode (e.g.
|
|
|
35
35
|
|
|
36
36
|
### Scheduler worker
|
|
37
37
|
|
|
38
|
-
Polls storage for due cron schedules and publishes `workflow.start`
|
|
38
|
+
Polls storage for due cron schedules and publishes a `workflow.start` event for each fire. It's a producer only, meaning it creates work for the orchestration worker to pick up:
|
|
39
|
+
|
|
40
|
+
- **Split processes**: Scheduled workflows run on the evented engine, and the orchestration worker runs each fire step by step.
|
|
41
|
+
- **In-process mode**: Scheduled workflows run on the default engine. The orchestration worker in the same process runs each fire in-process, the same way a direct `run.start()` does.
|
|
39
42
|
|
|
40
43
|
The scheduler reads declarative `schedule` fields from your workflow definitions automatically. See [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows) for how to declare schedules.
|
|
41
44
|
|
|
@@ -132,6 +135,8 @@ You can also pass a worker name to the CLI. The command sets `MASTRA_WORKERS` in
|
|
|
132
135
|
mastra worker start orchestration
|
|
133
136
|
```
|
|
134
137
|
|
|
138
|
+
Set `MASTRA_WORKERS` on every process in a split deployment, including `false` on the API process. Any value switches workflows that declare `schedule` to the evented engine, and every process must run those workflows on the same engine. See [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows). `mastra worker start` without a worker name doesn't set `MASTRA_WORKERS`, so pass a name or set the variable in the process environment.
|
|
139
|
+
|
|
135
140
|
## Network architecture
|
|
136
141
|
|
|
137
142
|
Workers are internal infrastructure. They're not exposed to end users and don't need their own subdomain or public URL, including an inbound HTTP route.
|
|
@@ -142,7 +147,7 @@ In a split deployment:
|
|
|
142
147
|
- **Workers connect outbound only**: They pull events from the distributed PubSub backend and read/write to the shared storage database. They don't accept inbound traffic from clients.
|
|
143
148
|
- **The orchestration worker calls the API internally**: It sends step execution requests to the API over the container network using `MASTRA_STEP_EXECUTION_URL`. This is internal service-to-service communication, not a public endpoint.
|
|
144
149
|
|
|
145
|
-
All three worker types (orchestration, scheduler, background task) sit behind the API on a private network. They share access to the PubSub backend and storage database but never receive traffic directly from clients. HTTP routes for worker-related features run on the API server rather than the worker process. One example is token
|
|
150
|
+
All three worker types (orchestration, scheduler, background task) sit behind the API on a private network. They share access to the PubSub backend and storage database but never receive traffic directly from clients. HTTP routes for worker-related features run on the API server rather than the worker process. One example is creating a token for a voice integration.
|
|
146
151
|
|
|
147
152
|
## Deploy split workers
|
|
148
153
|
|
package/.docs/docs/develop.md
CHANGED
|
@@ -44,9 +44,9 @@ Changes in your `src/mastra/` directory automatically restart the development se
|
|
|
44
44
|
|
|
45
45
|
Mastra provides a skill and a CLI to help your coding agent write high-quality Mastra code.
|
|
46
46
|
|
|
47
|
-
### Mastra
|
|
47
|
+
### Mastra skills
|
|
48
48
|
|
|
49
|
-
AI models may not have up-to-date knowledge of Mastra's APIs. Use the [Mastra
|
|
49
|
+
AI models may not have up-to-date knowledge of Mastra's APIs. Use the [Mastra skills](https://github.com/mastra-ai/skills) to give your coding agent implementation guidance and best practices, including instructions for fetching the latest Mastra documentation. Your coding agent will also be able to interact with [Mastra Factory](https://factory.mastra.ai).
|
|
50
50
|
|
|
51
51
|
Install the skill manually with:
|
|
52
52
|
|
|
@@ -100,7 +100,7 @@ yarn dlx skills update mastra
|
|
|
100
100
|
bun x skills update mastra
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
-
> **Note:** When you create a project with [create mastra](https://mastra.ai/docs), the command automatically installs the Mastra
|
|
103
|
+
> **Note:** When you create a project with [create mastra](https://mastra.ai/docs), the command automatically installs the Mastra skills so your coding agent can discover and use them.
|
|
104
104
|
|
|
105
105
|
### Mastra CLI
|
|
106
106
|
|
|
@@ -113,7 +113,7 @@ npx mastra api --url http://localhost:4111 agent run agent '{"messages":"Hello"}
|
|
|
113
113
|
npx mastra api --url http://localhost:4111 trace list
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
Remember to install the [Mastra
|
|
116
|
+
Remember to install the [Mastra skills](#mastra-skills) to teach your coding agent how to use the CLI.
|
|
117
117
|
|
|
118
118
|
## Project structure
|
|
119
119
|
|
|
@@ -133,7 +133,7 @@ Retries with the same `externalId` retain the original item's representation. Fo
|
|
|
133
133
|
|
|
134
134
|
Unset configuration now reads as `undefined` where some adapters previously returned `null`, so serialized responses omit those properties. Use nullish checks such as `value ?? fallback` rather than relying on an explicit `null` property. LibSQL also returns an omitted dataset description as `undefined`, matching its declared type.
|
|
135
135
|
|
|
136
|
-
Older LibSQL, PostgreSQL, MySQL, and Spanner writes stored optional JSON `null` values as SQL `NULL
|
|
136
|
+
Older LibSQL, PostgreSQL, MySQL, and Spanner writes stored optional JSON `null` values as SQL `NULL`. Those values remain indistinguishable from omitted fields. Older MongoDB writes stored omitted optional payload fields as BSON `null`. The storage fixes preserve new writes but don't reconstruct previously lost distinctions.
|
|
137
137
|
|
|
138
138
|
## Validate snapshot artifacts
|
|
139
139
|
|
|
@@ -10,15 +10,16 @@ Agents that use memory in `thread` scope, including observational memory, requir
|
|
|
10
10
|
ObservationalMemory (scope: 'thread') requires a threadId, but none was found in RequestContext or MessageList.
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Choose an approach based on how you want to share memory across eval items. For runnable examples, see [`examples/evals-with-memory`](https://github.com/mastra-ai/mastra/tree/main/examples/evals-with-memory).
|
|
14
14
|
|
|
15
15
|
## When to use which approach
|
|
16
16
|
|
|
17
|
-
| Goal
|
|
18
|
-
|
|
|
19
|
-
| One shared conversation across every item
|
|
20
|
-
| One independent thread per item, focused CI loop
|
|
21
|
-
|
|
|
17
|
+
| Goal | Approach |
|
|
18
|
+
| -------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
|
|
19
|
+
| One shared conversation across every item | [`runEvals` with global `targetOptions.memory`](#shared-thread-with-runevals) |
|
|
20
|
+
| One independent thread per item, focused CI loop | [`runEvals` per item](#per-item-threads-with-runevals) |
|
|
21
|
+
| Fresh thread per item in a stored `Dataset` | [`dataset.startExperiment` with a registered agent](https://mastra.ai/docs/evals/experiments) |
|
|
22
|
+
| Explicit thread selection per item in a stored `Dataset` | [`dataset.startExperiment` with an inline task](#dataset-experiments-with-an-inline-task) |
|
|
22
23
|
|
|
23
24
|
Pre-seeding `RequestContext` with `MastraMemory` **isn't** a supported way to drive memory into an agent. Thread resolution reads `args.memory.thread`, `RequestContext.MastraMemory` is populated by `prepare-memory-step` after the agent has already resolved its thread.
|
|
24
25
|
|
|
@@ -394,7 +394,7 @@ const subAgentMock = {
|
|
|
394
394
|
}
|
|
395
395
|
```
|
|
396
396
|
|
|
397
|
-
This is useful when a tool's arguments are noisy or generated by the model. The most common case is mocking a **sub-agent's response
|
|
397
|
+
This is useful when a tool's arguments are noisy or generated by the model. The most common case is mocking a **sub-agent's response**. The parent sees a delegated sub-agent as an `agent-<name>` tool, and its arguments include an LLM-authored `prompt` plus runtime-injected fields. Mocking `agent-<name>` returns the canned response in place of running the sub-agent and its inner tools. When you create a mock from a trace, sub-agent delegation calls are derived with `matchArgs: 'ignore'` automatically. You can change it to `'strict'` to pin the exact arguments.
|
|
398
398
|
|
|
399
399
|
### Failures
|
|
400
400
|
|
|
@@ -406,7 +406,7 @@ A tool call fails the item when it violates the mock configuration:
|
|
|
406
406
|
|
|
407
407
|
On any of these failures, the agent run is aborted immediately, so the model can't go on to call any further tools, including unmocked, side-effecting tools that would otherwise run live. These failures are deterministic, so they're not retried. Mocks that are declared but never used don't fail the item, they're reported as unconsumed.
|
|
408
408
|
|
|
409
|
-
|
|
409
|
+
The agent's tools execute sequentially while mock interception is active, so repeated `(toolName, args)` mocks are consumed in the provider's call order. Interception is active when the item declares mocks or its effective `unmockedToolPolicy` is `'deny'`.
|
|
410
410
|
|
|
411
411
|
### Diagnostics
|
|
412
412
|
|
|
@@ -484,7 +484,7 @@ const { experimentId, totalItems, datasetVersion } = await dataset.createExperim
|
|
|
484
484
|
})
|
|
485
485
|
```
|
|
486
486
|
|
|
487
|
-
Then run each item from your orchestrator. Mastra resolves the item at the pinned dataset version and executes the target with the resolved scorers. The result upserts keyed by `(experimentId, itemId, attempt)
|
|
487
|
+
Then run each item from your orchestrator. Mastra resolves the item at the pinned dataset version and executes the target with the resolved scorers. The result upserts are keyed by `(experimentId, itemId, attempt)`. A retried activity converges on a single row:
|
|
488
488
|
|
|
489
489
|
```typescript
|
|
490
490
|
const { result, scores } = await dataset.runExperimentItem({
|
|
@@ -506,7 +506,7 @@ const { experimentId } = await dataset.createExperiment({
|
|
|
506
506
|
})
|
|
507
507
|
```
|
|
508
508
|
|
|
509
|
-
Submit one result per item with [`submitExperimentResult()`](https://mastra.ai/reference/datasets/submitExperimentResult). Submissions are upserts keyed by `(experimentId, itemId, attempt)
|
|
509
|
+
Submit one result per item with [`submitExperimentResult()`](https://mastra.ai/reference/datasets/submitExperimentResult). Submissions are upserts keyed by `(experimentId, itemId, attempt)`. A retried worker converges on a single row instead of duplicating results:
|
|
510
510
|
|
|
511
511
|
```typescript
|
|
512
512
|
await dataset.submitExperimentResult({
|
|
@@ -35,7 +35,7 @@ const result = await runEvals({
|
|
|
35
35
|
})
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
Each turn runs `agent.generate()` with the same thread ID
|
|
38
|
+
Each turn runs `agent.generate()` with the same thread ID. The agent sees the full conversation history. Scorers receive the accumulated output messages from all turns.
|
|
39
39
|
|
|
40
40
|
> **Prebuilt LLM judges grade one turn:** Prebuilt LLM-judge scorers (rubric, answer relevancy, faithfulness, and the others listed in [Scorer compatibility](#scorer-compatibility)) read a single assistant message, so with `inputs` they grade only the last turn's response. For semantic grading across a conversation, use [`createMultiTurnJudgeScorer()`](https://mastra.ai/reference/evals/multi-turn-judge), which grades every assistant turn against one criterion, or per-turn [`turns[].scorers`](#per-turn-assertions-with-turns), where each turn grades its own output.
|
|
41
41
|
|
|
@@ -193,7 +193,7 @@ Semantics:
|
|
|
193
193
|
|
|
194
194
|
- A per-turn gate or scorer receives **only that turn's** `run.input` and `run.output`, rather than the accumulated conversation. A different turn's output can't satisfy the check, and `run.input` contains the input for the turn being evaluated.
|
|
195
195
|
- Per-turn outcomes fold into the [verdict](https://mastra.ai/docs/evals/gates-and-verdicts): a failing turn gate makes the verdict `failed`. A missed turn threshold (with gates passing) makes it `scored`.
|
|
196
|
-
- `result.turnResults[i]` reports each turn's `gateResults`, `thresholdResults`, and `scores
|
|
196
|
+
- `result.turnResults[i]` reports each turn's `gateResults`, `thresholdResults`, and `scores`. A failure points at the exact turn. Across multiple conversations, turn results are averaged by turn index.
|
|
197
197
|
- A turn with no `gates` or `scorers` advances the conversation.
|
|
198
198
|
- Top-level `scorers`/`gates` still run as a whole over the accumulated output, so you can combine "this turn must call the tool" with "the answer mentions Brooklyn."
|
|
199
199
|
- When the agent has storage configured, each per-turn scorer/gate result is persisted like top-level scores, so per-turn outcomes appear in your scores store. Each stored per-turn score uses its turn index as a label (`metadata.turnIndex`) and shares the conversation's `threadId`. It also includes a link to that turn's trace span.
|
|
@@ -77,7 +77,7 @@ test.for([
|
|
|
77
77
|
})
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
Each item passes or fails independently
|
|
80
|
+
Each item passes or fails independently. A single regression shows up as one failing test instead of a lowered aggregate pass rate.
|
|
81
81
|
|
|
82
82
|
## Asserting on results with matchers
|
|
83
83
|
|
|
@@ -270,7 +270,7 @@ session.subscribe(event => {
|
|
|
270
270
|
})
|
|
271
271
|
```
|
|
272
272
|
|
|
273
|
-
The `always_allow_category` decision grants the tool category for the
|
|
273
|
+
The `always_allow_category` decision grants the tool category for the gate's thread. Grants aren't durable process-level permissions.
|
|
274
274
|
|
|
275
275
|
Interactive tools such as [`ask_user`](https://mastra.ai/reference/tools/ask-user-tool) and [`submit_plan`](https://mastra.ai/reference/tools/submit-plan-tool) use resumable tool suspensions instead. Resume them with [`session.respondToToolSuspension()`](https://mastra.ai/reference/agent-controller/session):
|
|
276
276
|
|
|
@@ -401,7 +401,7 @@ Create the session under `thread.resourceId`. Because a session can bind only th
|
|
|
401
401
|
|
|
402
402
|
Failures that aren't refusals (a storage outage, a bug in your resolver's dependencies) still post an error to the thread, so a broken bot doesn't look like a silent one. If you need to tell them apart in your own code, a refusal is a `ChannelSessionRejectedError` with the original error as its `cause`.
|
|
403
403
|
|
|
404
|
-
`resolveSession` also runs when a user answers an approval card, with that action's request context
|
|
404
|
+
`resolveSession` also runs when a user answers an approval card, with that action's request context. A shared install revalidates the person approving rather than trusting the person who sent the original message.
|
|
405
405
|
|
|
406
406
|
### Handle stale approvals
|
|
407
407
|
|
|
@@ -470,7 +470,7 @@ const subscription = await session.subscribe({
|
|
|
470
470
|
subscription.unsubscribe()
|
|
471
471
|
```
|
|
472
472
|
|
|
473
|
-
`subscribe()` takes an options object and is async, unlike the in-process listener. Its promise resolves once the stream is established and rejects when it can't connect
|
|
473
|
+
`subscribe()` takes an options object and is async, unlike the in-process listener. Its promise resolves once the stream is established and rejects when it can't connect. A rejected call leaves nothing running in the background. `reconnect: true` re-establishes a stream that drops after it was established, with exponential backoff.
|
|
474
474
|
|
|
475
475
|
The server doesn't replay events missed while the stream was down, so read `session.state()` from `onReconnect` for the current mode, model, and thread. The client surface has no `session.displayState.get()`.
|
|
476
476
|
|
|
@@ -483,4 +483,6 @@ Send work with `session.sendMessage(content)`, or `session.sendMessage({ content
|
|
|
483
483
|
- [Agents](https://mastra.ai/docs/agents/overview)
|
|
484
484
|
- [Workspace](https://mastra.ai/docs/sandbox/overview)
|
|
485
485
|
- [Observational memory](https://mastra.ai/docs/memory/observational-memory)
|
|
486
|
-
- [Channels](https://mastra.ai/docs/channels)
|
|
486
|
+
- [Channels](https://mastra.ai/docs/channels)
|
|
487
|
+
- [Mastra Code](https://code.mastra.ai)
|
|
488
|
+
- [Mastra Factory](https://factory.mastra.ai)
|
|
@@ -231,7 +231,7 @@ When this `researchAgent` is delegated to from a supervisor that has no backgrou
|
|
|
231
231
|
|
|
232
232
|
Mastra supports one nested background-tool level inside a delegated run: a root agent can delegate to a subagent, and that subagent can dispatch an eligible ordinary tool in the background. A second delegated-agent edge runs in the foreground and doesn't receive nested background guidance. This limit is execution-scoped and doesn't mutate the shared subagent configuration.
|
|
233
233
|
|
|
234
|
-
Which layer to use depends on where consistency matters: subagent-level configuration travels with the agent,
|
|
234
|
+
Which layer to use depends on where consistency matters: subagent-level configuration travels with the agent, which keeps its background behavior the same under every supervisor, whereas the supervisor-side opt-in above centralizes that tuning in one place. This boundary stops at a single nested delegation level and has no workflow integration.
|
|
235
235
|
|
|
236
236
|
## Suspending and resuming
|
|
237
237
|
|
|
@@ -268,7 +268,7 @@ export const reviewTool = createTool({
|
|
|
268
268
|
})
|
|
269
269
|
```
|
|
270
270
|
|
|
271
|
-
The first invocation of `execute` sees `resumeData === undefined` and calls `suspend`. After the task is resumed, the runtime restarts the tool with `resumeData` populated. The `if` condition is false
|
|
271
|
+
The first invocation of `execute` sees `resumeData === undefined` and calls `suspend`. After the task is resumed, the runtime restarts the tool with `resumeData` populated. The `if` condition is false. The tool returns its real result.
|
|
272
272
|
|
|
273
273
|
To resume the task once an approval arrives:
|
|
274
274
|
|
|
@@ -278,6 +278,8 @@ Under the default persistence policy, these `running` checkpoints are only writt
|
|
|
278
278
|
|
|
279
279
|
Durable agent runs are excluded from the generic boot-time restart of active workflow runs. The only automatic recovery path for durable agent runs is `recovery.durableAgents: 'auto'`, which holds a recovery lease and registers thread runtimes before re-driving each run.
|
|
280
280
|
|
|
281
|
+
> **Warning:** Automatic and manual recovery re-run the agentic loop from the last persisted snapshot, which can reissue LLM calls (with real cost) and re-execute tool calls. A sub-agent delegation is one generated `agent-<name>` tool call, and recovery doesn't checkpoint the LLM or tool calls inside that delegation independently. If recovery replays the delegation step, the entire sub-agent run starts again and can repeat inner LLM calls and already-completed tool side effects. Make tools, including tools used by sub-agents, idempotent, or deduplicate their external side effects.
|
|
282
|
+
|
|
281
283
|
### Snapshot persistence
|
|
282
284
|
|
|
283
285
|
The `shouldPersistSnapshot` option on `createDurableAgent()` (also accepted in the agent-level `durable` config) controls which workflow snapshots a durable agent writes. The default policy:
|
|
@@ -313,8 +315,6 @@ export const mastra = new Mastra({
|
|
|
313
315
|
|
|
314
316
|
On startup, this discovers every registered durable agent with runs stuck in `running` status and re-drives them from the last persisted snapshot.
|
|
315
317
|
|
|
316
|
-
> **Warning:** Recovery re-runs the agentic loop from the last snapshot, which re-issues LLM calls (real cost) and re-executes tool calls. Make sure your tools are idempotent before enabling automatic recovery.
|
|
317
|
-
|
|
318
318
|
### Manual recovery
|
|
319
319
|
|
|
320
320
|
If you need finer control, such as gating recovery behind a leader election or running it on a schedule, call the methods directly:
|
|
@@ -67,11 +67,26 @@ A goal step runs inside the agentic execution loop, right after `isTaskComplete`
|
|
|
67
67
|
|
|
68
68
|
The step is a no-op for background-task, mid-tool-loop, and working-memory-only iterations, the same gating as `isTaskComplete`.
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
Each evaluation emits a typed `goal` stream chunk (`GoalEvaluationPayload`: `objective`, `iteration`, `maxRuns`, `passed`, `status`, `results`, `reason`, `duration`, `timedOut`, `maxRunsReached`, `suppressFeedback`) so a UI can show goal progress mid-run.
|
|
71
|
+
|
|
72
|
+
**The judge model is the activation switch.** If no judge resolves, from either the per-objective override or the agent's `goal.judge`, the goal step performs no scoring or budget consumption and emits no `goal` chunk. The gate covers every scorer: Mastra checks it before selecting a scorer, so a custom `goal.scorer` still needs a judge to resolve.
|
|
73
|
+
|
|
74
|
+
Effective settings resolve as per-objective record value, then agent `goal` config, then a built-in default (`maxRuns` `50` and the default judge prompt).
|
|
75
|
+
|
|
76
|
+
### Judge and scorer
|
|
77
|
+
|
|
78
|
+
`goal.judge` and `goal.scorer` work at different levels. `goal.scorer` is the evaluation pipeline that produces the score the loop gates on. `goal.judge` is the model the default pipeline calls to reach that score.
|
|
79
|
+
|
|
80
|
+
Omit `scorer` and Mastra builds a default LLM-as-judge scorer, which returns `1` when the objective is achieved and `0` otherwise. Configure it with these settings:
|
|
71
81
|
|
|
72
|
-
|
|
82
|
+
- `goal.judge`: The model that decides whether the objective is met.
|
|
83
|
+
- `goal.prompt`: Extra instructions for the judge. Defaults to the built-in goal judge prompt.
|
|
84
|
+
- `goal.tools`: Read-only verification tools the judge can call before deciding, so it can confirm the work instead of grading the agent's text alone.
|
|
85
|
+
- `goal.maxSteps`: Step budget for the judge's own agentic loop. Defaults to `5`.
|
|
73
86
|
|
|
74
|
-
|
|
87
|
+
Pass `goal.scorer` to replace the pipeline with your own [scorer](https://mastra.ai/reference/evals/create-scorer), either a scorer instance or a registered scorer id. The custom scorer brings its own judging, so `goal.prompt`, `goal.tools`, and `goal.maxSteps` no longer apply, and Mastra stops resolving the judge model for judging. A `goal.judge` resolver function still runs, and its return value is discarded.
|
|
88
|
+
|
|
89
|
+
Configure the default scorer with `judge`, `maxRuns`, and `prompt`:
|
|
75
90
|
|
|
76
91
|
```typescript
|
|
77
92
|
const worker = new Agent({
|
|
@@ -91,7 +106,15 @@ const worker = new Agent({
|
|
|
91
106
|
})
|
|
92
107
|
```
|
|
93
108
|
|
|
94
|
-
|
|
109
|
+
To hand the decision to your own scorer, pass it as `scorer` and keep `judge` set, because the activation gate still applies:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
goal: {
|
|
113
|
+
judge: 'openai/gpt-5-mini',
|
|
114
|
+
// Replaces the built-in judge pipeline. `prompt`, `tools`, and `maxSteps` no longer apply.
|
|
115
|
+
scorer: 'tests-pass',
|
|
116
|
+
}
|
|
117
|
+
```
|
|
95
118
|
|
|
96
119
|
## Managing the objective
|
|
97
120
|
|
|
@@ -73,7 +73,7 @@ Without a `threadId`, each fire is an isolated `agent.generate()` run. Nothing i
|
|
|
73
73
|
|
|
74
74
|
### Threaded
|
|
75
75
|
|
|
76
|
-
With a `threadId`, the schedule sends a [signal](https://mastra.ai/docs/harness/signals) into that thread
|
|
76
|
+
With a `threadId`, the schedule sends a [signal](https://mastra.ai/docs/harness/signals) into that thread. The prompt joins the agent's conversation. Threaded schedules require a `resourceId` alongside the `threadId`.
|
|
77
77
|
|
|
78
78
|
```typescript
|
|
79
79
|
await mastra.schedules.create({
|
|
@@ -196,6 +196,33 @@ Every hook context includes `agentId` (the agent the schedule fired for) alongsi
|
|
|
196
196
|
|
|
197
197
|
Hook exceptions are caught and logged. They never re-route the worker or trigger another hook.
|
|
198
198
|
|
|
199
|
+
## Recurring prompts in Mastra Code
|
|
200
|
+
|
|
201
|
+
Mastra Code offers the `/schedules` command, which attaches a recurring prompt to the current conversation thread. Unlike `mastra.schedules`, these schedules live only in the Mastra Code process that created them: nothing is written to storage, and each fire is sent to the thread with `agent.sendSignal()` directly.
|
|
202
|
+
|
|
203
|
+
Run `/schedules` to open a menu with **Create schedule** and one row per schedule on the current thread. Creating a schedule walks through these steps:
|
|
204
|
+
|
|
205
|
+
1. Choose what each fire sends: a **Prompt**, a **Prompt file** that's re-read on every fire, or a **Script** that runs on every fire.
|
|
206
|
+
2. Enter the prompt text or the file path. Paths resolve from the project root. For a script, you can add a prompt that's sent after the script output.
|
|
207
|
+
3. Pick a cadence from `1m` to `1d`, or type one such as `20m` or `3h`. Minute steps must divide an hour and hour steps must divide a day.
|
|
208
|
+
4. Confirm.
|
|
209
|
+
|
|
210
|
+
Scripts run from the project root with a 60-second timeout, and their stdout, stderr, and exit code become the prompt. The extra prompt is never passed to the script.
|
|
211
|
+
|
|
212
|
+
Selecting an existing schedule offers **Run now**, **Pause** or **Resume**, and **Delete**. **Run now** fires the schedule once without changing its cadence, works on paused schedules, and is skipped while a fire of the same schedule is still running.
|
|
213
|
+
|
|
214
|
+
Each fire arrives on the thread as a `user`-type signal and shows in the transcript as a `schedule` entry with the schedule's id, cadence, source, and script exit status. If the thread is busy, the running agent receives the prompt as its next input, the same way a message you type mid-run does. If the thread is idle, it wakes and runs. Schedules fire on any thread in the process, not only the one focused in the terminal. After `/new`, a new schedule binds to the new thread.
|
|
215
|
+
|
|
216
|
+
Things to know:
|
|
217
|
+
|
|
218
|
+
- **Session scoped.** Schedules exist only in the Mastra Code process that created them and stop when it exits. Other Mastra Code processes sharing the same database never see or fire them.
|
|
219
|
+
- **Clock boundaries.** `5m` fires at :00, :05, :10 and so on, not five minutes after creation, and `1d` fires at local midnight. Hour and day cadences follow wall-clock time across daylight saving changes, like cron. A fire missed while the machine slept, or one whose timer runs more than a minute late, is skipped, and the schedule resumes at the next boundary.
|
|
220
|
+
- **Overlapping fires are skipped.** If a script is still running when the next boundary arrives, that fire doesn't run.
|
|
221
|
+
|
|
222
|
+
### Agent schedule tools
|
|
223
|
+
|
|
224
|
+
Turning on **Experimental schedule tools** in `/settings` (restart required) gives the agent tools that manage the same schedules: `schedule_create`, `schedule_list`, `schedule_update` (pause or delete), `schedule_resume`, and `schedule_run`. The tools only see and change schedules on the thread of the run that calls them. Because a schedule can run a script on every fire, `schedule_create`, `schedule_resume`, and `schedule_run` need the same approval as running a shell command unless YOLO mode is on. Schedules the agent creates are marked `created by agent` in the transcript.
|
|
225
|
+
|
|
199
226
|
## Related
|
|
200
227
|
|
|
201
228
|
- [`mastra.schedules`](https://mastra.ai/reference/schedules/overview): API reference for creating and managing schedules.
|
|
@@ -218,7 +218,7 @@ export const agentsMdReminderProcessor: Processor = {
|
|
|
218
218
|
}
|
|
219
219
|
```
|
|
220
220
|
|
|
221
|
-
Reactive signals default to `tagName: 'system-reminder'
|
|
221
|
+
Reactive signals default to `tagName: 'system-reminder'`. The model receives this context as
|
|
222
222
|
|
|
223
223
|
```xml
|
|
224
224
|
<system-reminder type="dynamic-agents-md" path="packages/ui/AGENTS.md">
|
|
@@ -411,7 +411,7 @@ export const mastra = new Mastra({
|
|
|
411
411
|
})
|
|
412
412
|
```
|
|
413
413
|
|
|
414
|
-
`RedisStreamsPubSub` implements both the event delivery contract and distributed leasing
|
|
414
|
+
`RedisStreamsPubSub` implements both the event delivery contract and distributed leasing. 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).
|
|
415
415
|
|
|
416
416
|
## Compatibility and APIs
|
|
417
417
|
|
|
@@ -165,7 +165,7 @@ Projects that depend on packages from a private registry install them during the
|
|
|
165
165
|
|
|
166
166
|
In a monorepo, a `.npmrc` in your project directory takes precedence over one at the repository root.
|
|
167
167
|
|
|
168
|
-
`NPM_TOKEN` is available during dependency installation. Mastra redacts its value from the Mastra source-build logs that it streams. The generated Dockerfile receives it as a build argument
|
|
168
|
+
`NPM_TOKEN` is available during dependency installation. Mastra redacts its value from the Mastra source-build logs that it streams. The generated Dockerfile receives it as a build argument. The runtime image stays free of the token. `NPM_TOKEN` is also injected into the running service as a regular environment variable, so treat it as a secret your application can read.
|
|
169
169
|
|
|
170
170
|
Projects without a private-registry `.npmrc` need no changes. When your `.npmrc` references `${NPM_TOKEN}`, set the variable or the dependency install fails.
|
|
171
171
|
|
|
@@ -59,7 +59,7 @@ Variables are applied when a deploy starts. To apply changed variables to a runn
|
|
|
59
59
|
mastra env restart staging
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
To see the set an environment's deploys actually run with, with managed variables listed by name, pull them into a local env file. Each environment is pulled on its own
|
|
62
|
+
To see the set an environment's deploys actually run with, with managed variables listed by name, pull them into a local env file. Each environment is pulled on its own. The file never mixes in another environment's values:
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
65
|
mastra env vars pull staging --output .env.staging
|
|
@@ -38,7 +38,7 @@ yarn create mastra
|
|
|
38
38
|
bunx create-mastra
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
The create command authenticates with Mastra Platform and creates an observability project. It then
|
|
41
|
+
The create command authenticates with Mastra Platform and creates an observability project. It then creates an access token and writes `MASTRA_PLATFORM_ACCESS_TOKEN` and `MASTRA_PROJECT_ID` to `.env`.
|
|
42
42
|
|
|
43
43
|
### Existing project
|
|
44
44
|
|
|
@@ -103,7 +103,7 @@ export async function runInFreshSandbox(command: string) {
|
|
|
103
103
|
}
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
Or clone a configured sandbox as the template for a fleet
|
|
106
|
+
Or clone a configured sandbox as the template for a fleet. The clones inherit credentials, environment, network isolation, and defaults without repeating them:
|
|
107
107
|
|
|
108
108
|
```typescript
|
|
109
109
|
const template = new PlatformSandbox({ networkIsolation: 'PRIVATE' })
|
|
@@ -128,7 +128,7 @@ export const agent = new Agent({
|
|
|
128
128
|
|
|
129
129
|
Mastra inserts a temporal gap marker when the gap is at least 10 minutes. The marker is stored in memory and also emitted as a transient reminder event, so clients can render it as a lightweight timeline hint.
|
|
130
130
|
|
|
131
|
-
The observer also sees these markers when it processes the thread
|
|
131
|
+
The observer also sees these markers when it processes the thread. The observations it writes can anchor memories to when they happened (for example, "User asked about deployment after a 2-day gap").
|
|
132
132
|
|
|
133
133
|
See [the API reference](https://mastra.ai/reference/memory/observational-memory) for the full configuration shape.
|
|
134
134
|
|
|
@@ -223,7 +223,7 @@ A provider outage usually takes out both stages, so set the policy on both if yo
|
|
|
223
223
|
|
|
224
224
|
This policy applies only to Observer and Reflector model and provider failures in synchronous, resource-scoped, and buffered observation. Persistence, indexing, transform, locking, invariant, and explicit abort failures remain fatal. It doesn't prevent the underlying provider or network error, change `blockAfter`, or change attachment handling.
|
|
225
225
|
|
|
226
|
-
> **Warning:** `'continue'` has no backstop for a sustained outage. Unobserved messages stay pending and keep accruing in the main agent's context
|
|
226
|
+
> **Warning:** `'continue'` has no backstop for a sustained outage. Unobserved messages stay pending and keep accruing in the main agent's context. A long outage moves the failure from the memory layer to the model's context limit.
|
|
227
227
|
|
|
228
228
|
See [the API reference](https://mastra.ai/reference/memory/observational-memory) for the full configuration shape.
|
|
229
229
|
|
|
@@ -231,7 +231,7 @@ See [the API reference](https://mastra.ai/reference/memory/observational-memory)
|
|
|
231
231
|
|
|
232
232
|
- **Prompt caching**: OM's context is stable and observations append over time rather than being retrieved at runtime each turn. This keeps the prompt prefix cacheable, which reduces costs.
|
|
233
233
|
- **Compression**: Raw message history and tool results get compressed into a dense observation log. Smaller context means faster responses and longer coherent conversations.
|
|
234
|
-
- **Zero context rot**: The agent sees relevant information instead of noisy tool calls and irrelevant tokens,
|
|
234
|
+
- **Zero context rot**: The agent sees relevant information instead of noisy tool calls and irrelevant tokens, which keeps the agent on task over long sessions.
|
|
235
235
|
|
|
236
236
|
## How it works
|
|
237
237
|
|
|
@@ -202,7 +202,7 @@ Each delegation creates a fresh `threadId` and a deterministic `resourceId` for
|
|
|
202
202
|
|
|
203
203
|
> **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.
|
|
204
204
|
|
|
205
|
-
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
|
|
205
|
+
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/subagents) callback.
|
|
206
206
|
|
|
207
207
|
> **Note:** Subagent resource IDs are always suffixed with the agent name (`{parentResourceId}-{agentName}`). Different subagents under the same supervisor never share a resource ID through delegation.
|
|
208
208
|
|
|
@@ -110,7 +110,7 @@ If multiple highest-priority candidates have the same source type, Mastra can't
|
|
|
110
110
|
|
|
111
111
|
The agent can bypass name-based resolution by passing the exact path shown in the system message to `skill` or `skill_read`. Paths with or without the trailing `/SKILL.md` work. If several configured paths resolve to the same canonical directory, Mastra treats them as aliases and lists the skill once.
|
|
112
112
|
|
|
113
|
-
Direct [agent skills](https://mastra.ai/docs/skills) are resolved before filesystem-backed skills
|
|
113
|
+
Direct [agent skills](https://mastra.ai/docs/skills) are resolved before filesystem-backed skills. A direct skill wins when both types use the same name.
|
|
114
114
|
|
|
115
115
|
## Search skill content
|
|
116
116
|
|
|
@@ -70,7 +70,7 @@ export const mastra = new Mastra({
|
|
|
70
70
|
|
|
71
71
|
### Distributed deployments
|
|
72
72
|
|
|
73
|
-
Use a distributed backend when you run more than one instance or host,
|
|
73
|
+
Use a distributed backend when you run more than one instance or host, and every instance receives the same events. This matters whenever a request handled by one instance must reach work running on another.
|
|
74
74
|
|
|
75
75
|
For example, sending a signal to an agent run requires the signal event to cross the process boundary to the instance that owns the run. With the in-process default, that instance never receives the event.
|
|
76
76
|
|
|
@@ -781,7 +781,7 @@ When using adapters, configure these features directly with your framework. For
|
|
|
781
781
|
|
|
782
782
|
Server adapters register MCP (Model Context Protocol) routes during `registerRoutes()` when MCP servers are configured in your Mastra instance. MCP allows external tools and services to connect to your Mastra server and interact with your agents.
|
|
783
783
|
|
|
784
|
-
Each server is exposed at `/api/mcp/:serverId/mcp` over Streamable HTTP.
|
|
784
|
+
Each server is exposed at `/api/mcp/:serverId/mcp` over Streamable HTTP. Because every request is self-contained, the routes work unchanged in serverless environments like Cloudflare Workers or Vercel Edge.
|
|
785
785
|
|
|
786
786
|
Pass `mcpOptions` to control how the authenticated principal reaches tools. When using the Mastra deployer (the standard `mastra dev` / `mastra build` path), set it in your server config:
|
|
787
787
|
|