@mastra/mcp-docs-server 1.3.2-alpha.13 → 1.3.2-alpha.15
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/processors.md +3 -3
- package/.docs/docs/agents/tools.md +1 -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/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 +5 -3
- package/.docs/docs/harness/background-tasks.md +2 -2
- package/.docs/docs/harness/goals.md +27 -4
- package/.docs/docs/harness/schedules.md +1 -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/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/index.md +212 -2
- package/.docs/models/providers/edenai.md +3 -1
- package/.docs/models/providers/kilo.md +13 -13
- package/.docs/models/providers/llmgateway-providers.md +1 -3
- package/.docs/models/providers/nano-gpt.md +1 -6
- package/.docs/models/providers/pioneer.md +3 -1
- package/.docs/reference/client-js/agent-controller.md +1 -1
- package/.docs/reference/datasets/finalizeExperiment.md +1 -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/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/model-selection-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/workflow.md +1 -1
- 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 +4 -4
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -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({
|
|
@@ -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
|
|
|
@@ -66,7 +66,7 @@ Studio handles the token as follows:
|
|
|
66
66
|
|
|
67
67
|
- It reads `auth_header` once on load and sends the value as the `Authorization` header on every API request in that session.
|
|
68
68
|
- It removes `auth_header` from the address bar while preserving other query parameters and the hash.
|
|
69
|
-
- It keeps the token in memory only and never writes it to local storage, so
|
|
69
|
+
- It keeps the token in memory only and never writes it to local storage, so it doesn't persist across page reloads.
|
|
70
70
|
|
|
71
71
|
The token rides in a URL parameter, so the host application is responsible for how that URL is generated and transmitted. URL parameters can be exposed through browser history and referrer headers, plus server access logs.
|
|
72
72
|
|
|
@@ -100,7 +100,7 @@ await mastra.addDynamicWorkflow(definition)
|
|
|
100
100
|
|
|
101
101
|
### Register dependencies first
|
|
102
102
|
|
|
103
|
-
Register referenced components on the same `Mastra` instance before adding the dynamic workflow. Agent and nested workflow entries use their intrinsic IDs. A tool entry uses its key from the `Mastra` `tools` object
|
|
103
|
+
Register referenced components on the same `Mastra` instance before adding the dynamic workflow. Agent and nested workflow entries use their intrinsic IDs. A tool entry uses its key from the `Mastra` `tools` object. The quickstart registers the tool under `create-greeting` before referencing that key with `toolId`.
|
|
104
104
|
|
|
105
105
|
Use a `mapping` entry when one step's output doesn't match the next step's input. Mapping entries can read data from the workflow input and previous step results, along with workflow state and request context. The [definition reference](https://mastra.ai/reference/workflows/dynamic-workflow-definition) lists the supported mapping descriptors.
|
|
106
106
|
|
|
@@ -294,7 +294,7 @@ const testWorkflow = mastra.getWorkflow('testWorkflow')
|
|
|
294
294
|
> 1. It provides access to the Mastra instance configuration (logger, telemetry, storage, registered agents, and vector stores)
|
|
295
295
|
> 2. It provides full TypeScript type inference for workflow input and output schemas
|
|
296
296
|
>
|
|
297
|
-
> Use `getWorkflow()` with the workflow's **registration key** (the key used when adding it to Mastra).
|
|
297
|
+
> Use `getWorkflow()` with the workflow's **registration key** (the key used when adding it to Mastra). `getWorkflowById()` retrieves workflows by their `id` property, but it doesn't provide the same level of type inference.
|
|
298
298
|
|
|
299
299
|
## Running workflows
|
|
300
300
|
|
|
@@ -40,11 +40,15 @@ export const dailyReport = createWorkflow({
|
|
|
40
40
|
|
|
41
41
|
A separate "register schedule" call won't happen. The scheduler reads `schedule` straight off the workflow when `Mastra` boots.
|
|
42
42
|
|
|
43
|
-
##
|
|
43
|
+
## Execution engine
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
Declaring `schedule` doesn't change how the workflow runs. Scheduled fires run in-process on the host that runs the scheduler, the same way `workflow.start()` or an HTTP-triggered run does. A workflow that declares `schedule` needs no extra storage or worker setup to run directly.
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
Split-worker deployments are the exception. When the [`MASTRA_WORKERS`](https://mastra.ai/reference/workers/overview) environment variable is set to any value, including `false`, `createWorkflow` builds scheduled workflows on the **evented execution engine** so that every process in the deployment runs them the same way. Scheduled fires then run on the [orchestration worker](https://mastra.ai/docs/deployment/workers), and Mastra logs a warning to the console when the workflow is created. The public API (`workflow.start()`, `workflow.startAsync()`, `resume()`) doesn't change.
|
|
48
|
+
|
|
49
|
+
Evented runs require a storage adapter that applies concurrent updates atomically, such as `@mastra/libsql` or `@mastra/pg`. With any other adapter, `createRun()` throws an error that lists the supported adapters.
|
|
50
|
+
|
|
51
|
+
Only the environment variable triggers the switch, because `createWorkflow` runs before `Mastra` reads its `workers` option. If you split workers with the `workers` option instead, import `createWorkflow` from `@mastra/core/workflows/evented` for your scheduled workflows.
|
|
48
52
|
|
|
49
53
|
## Single schedule
|
|
50
54
|
|
|
@@ -92,7 +96,7 @@ Each entry creates an independent schedule row and fires on its own cron, plus s
|
|
|
92
96
|
|
|
93
97
|
Studio surfaces schedules as a top-level area, not as a tab inside a workflow:
|
|
94
98
|
|
|
95
|
-
- **All schedules**: open `/workflows/schedules` for a cross-workflow list. Each row shows the workflow id, cron, next fire, and the most recent run's status
|
|
99
|
+
- **All schedules**: open `/workflows/schedules` for a cross-workflow list. Each row shows the workflow id, cron, next fire, and the most recent run's status. The list answers "is anything broken?" at a glance.
|
|
96
100
|
- **Filtered by workflow**: append `?workflowId=<id>` to scope the list to a single workflow, for example `/workflows/schedules?workflowId=daily-report`.
|
|
97
101
|
- **Schedule detail**: Select any row to open `/workflows/schedules/:scheduleId`. The page shows schedule metadata and **Pause** / **Resume** controls, followed by the full trigger history.
|
|
98
102
|
|
|
@@ -133,7 +137,7 @@ await client.resumeSchedule('wf_daily-report')
|
|
|
133
137
|
|
|
134
138
|
In Studio, open the schedule detail page and select **Pause** or **Resume** in the header.
|
|
135
139
|
|
|
136
|
-
A few rules
|
|
140
|
+
A few rules to know:
|
|
137
141
|
|
|
138
142
|
- Pause is durable. The status is written to the schedules table and survives process restarts and redeploys. The declarative-config upsert never overwrites a user-set status, even when you change `cron`, `timezone`, or other fields.
|
|
139
143
|
- Resume recomputes `nextFireAt` from now. A schedule paused for a week doesn't fire seven backlogged runs the moment you resume it. It fires on the next regular cron tick.
|
|
@@ -163,9 +167,9 @@ Deploy targets such as Fly Machines, Railway, Render, AWS ECS, GKE, or your own
|
|
|
163
167
|
|
|
164
168
|
### Serverless platforms
|
|
165
169
|
|
|
166
|
-
Functions-as-a-service platforms such as Vercel, Netlify, AWS Lambda, and Cloudflare Workers shut the process down after each request, so the tick loop doesn't get a second tick and schedules declared in code don't fire with the built-in scheduler today.
|
|
170
|
+
Functions-as-a-service platforms such as Vercel, Netlify, AWS Lambda, and Cloudflare Workers shut the process down after each request, so the tick loop doesn't get a second tick and schedules declared in code don't fire with the built-in scheduler today. Direct runs still work: calling `run.start()` from an HTTP route runs a workflow that declares `schedule` in-process, like any other workflow.
|
|
167
171
|
|
|
168
|
-
|
|
172
|
+
For cron fires on these platforms, use [`@mastra/inngest`](#inngest-workflows) instead. Inngest is serverless-native and holds the cron state for you.
|
|
169
173
|
|
|
170
174
|
## Inngest workflows
|
|
171
175
|
|