@mastra/mcp-docs-server 1.3.2 → 1.3.3-alpha.3
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/human-in-the-loop.md +6 -4
- package/.docs/docs/agents/processors.md +58 -4
- package/.docs/docs/connections/mcp.md +2 -0
- package/.docs/docs/deployment/workers.md +3 -1
- package/.docs/docs/guides/authentication-identity.md +4 -2
- package/.docs/docs/guides/mcp-authentication-authorization.md +136 -0
- package/.docs/docs/index.md +1 -1
- package/.docs/docs/server/server-adapters.md +54 -11
- package/.docs/docs/workflows/control-flow.md +2 -4
- package/.docs/docs/workflows/scheduled-workflows.md +5 -1
- package/.docs/models/environment-variables.md +1 -1
- package/.docs/models/gateways/merge-gateway.md +2 -1
- package/.docs/models/gateways/openrouter.md +2 -1
- package/.docs/models/gateways/vercel.md +6 -1
- package/.docs/models/index.md +2 -2
- package/.docs/models/providers/302ai.md +2 -1
- package/.docs/models/providers/baseten.md +2 -1
- package/.docs/models/providers/cortecs.md +3 -2
- package/.docs/models/providers/crossmodel.md +3 -3
- package/.docs/models/providers/deepinfra.md +1 -5
- package/.docs/models/providers/edenai.md +3 -2
- package/.docs/models/providers/kilo.md +16 -14
- package/.docs/models/providers/llmgateway-providers.md +3 -11
- package/.docs/models/providers/llmgateway.md +2 -1
- package/.docs/models/providers/nano-gpt.md +5 -2
- package/.docs/models/providers/opencode.md +2 -1
- package/.docs/models/providers/requesty.md +3 -1
- package/.docs/models/providers/tempr.md +23 -4
- package/.docs/models/providers/vivgrid.md +3 -1
- package/.docs/models/providers/vultr.md +22 -17
- package/.docs/models/providers.md +1 -1
- package/.docs/reference/agent-controller/agent-controller-class.md +2 -0
- package/.docs/reference/agent-controller/session.md +8 -8
- package/.docs/reference/classifier/classifier.md +49 -22
- package/.docs/reference/client-js/observability.md +1 -1
- package/.docs/reference/coding-agent/create-coding-agent.md +2 -2
- package/.docs/reference/configuration.md +2 -4
- package/.docs/reference/evals/create-classifier-scorer.md +2 -4
- package/.docs/reference/evals/create-scorer.md +1 -1
- package/.docs/reference/memory/observational-memory.md +3 -1
- package/.docs/reference/observability/tracing/spans.md +1 -1
- package/.docs/reference/processors/classifier-processor.md +8 -10
- package/.docs/reference/processors/model-selection-processor.md +8 -10
- package/.docs/reference/processors/prefill-error-handler.md +2 -2
- package/.docs/reference/processors/processor-interface.md +2 -2
- package/.docs/reference/processors/provider-history-compat.md +37 -17
- package/.docs/reference/processors/stream-error-retry-processor.md +9 -4
- package/.docs/reference/server/elysia-adapter.md +2 -0
- package/.docs/reference/server/express-adapter.md +1 -1
- package/.docs/reference/server/fastify-adapter.md +2 -0
- package/.docs/reference/server/hono-adapter.md +2 -0
- package/.docs/reference/server/koa-adapter.md +2 -0
- package/.docs/reference/server/nestjs-adapter.md +48 -0
- package/.docs/reference/tools/mcp-server.md +25 -10
- package/.docs/reference/workflows/step.md +2 -4
- package/package.json +5 -5
|
@@ -12,7 +12,7 @@ A classifier only returns evaluation results. Your application decides how to us
|
|
|
12
12
|
|
|
13
13
|
## Basic usage
|
|
14
14
|
|
|
15
|
-
This example uses the [TypeSafe AI provider](https://ai-sdk.dev/providers/ai-sdk-providers/typesafe-ai). To use another provider, see [Evaluation models](#evaluation-models).
|
|
15
|
+
This example uses the [TypeSafe AI provider](https://ai-sdk.dev/providers/ai-sdk-providers/typesafe-ai). Make sure to set the `TYPESAFE_AI_API_KEY` environment variable. To use another provider, see [Evaluation models](#evaluation-models).
|
|
16
16
|
|
|
17
17
|
Install the provider package:
|
|
18
18
|
|
|
@@ -44,13 +44,11 @@ Define questions in the constructor when every evaluation uses the same question
|
|
|
44
44
|
|
|
45
45
|
```typescript
|
|
46
46
|
import { Classifier } from '@mastra/core/classifier'
|
|
47
|
-
import {
|
|
47
|
+
import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
48
48
|
|
|
49
49
|
const classifier = new Classifier({
|
|
50
50
|
id: 'request-classifier',
|
|
51
|
-
model:
|
|
52
|
-
'jev-latest',
|
|
53
|
-
),
|
|
51
|
+
model: typeSafeAi.evaluationModel('jev-latest'),
|
|
54
52
|
questions: {
|
|
55
53
|
route: {
|
|
56
54
|
type: 'choice',
|
|
@@ -84,7 +82,17 @@ The evaluation model receives every question with the same `state`. When a quest
|
|
|
84
82
|
|
|
85
83
|
The examples on this page follow the [TypeSafe AI provider setup](https://ai-sdk.dev/providers/ai-sdk-providers/typesafe-ai#setup) in the AI SDK documentation. Other AI SDK providers, including OpenAI, Anthropic, and Google, also expose an `evaluationModel()` factory. See [provider models](https://ai-sdk.dev/docs/ai-sdk-core/evaluation#provider-models) for the full list, supported model IDs, and how each provider answers questions.
|
|
86
84
|
|
|
87
|
-
Each provider
|
|
85
|
+
Each provider exports a ready-made instance, which is what the examples on this page use. See [AI SDK providers](https://ai-sdk.dev/providers/ai-sdk-providers) for the others.
|
|
86
|
+
|
|
87
|
+
Pass a key explicitly by calling the factory instead:
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { createTypeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
91
|
+
|
|
92
|
+
const model = createTypeSafeAi({ apiKey: process.env.TYPESAFE_AI_API_KEY }).evaluationModel(
|
|
93
|
+
'jev-latest',
|
|
94
|
+
)
|
|
95
|
+
```
|
|
88
96
|
|
|
89
97
|
## Constructor
|
|
90
98
|
|
|
@@ -98,7 +106,7 @@ new Classifier(options)
|
|
|
98
106
|
|
|
99
107
|
**questions** (`ClassifierQuestions`): A non-empty record of named questions. Omit this field to supply the questions to each evaluate() call instead.
|
|
100
108
|
|
|
101
|
-
Constructor questions and per-call questions are mutually exclusive. If the constructor includes `questions`, `evaluate()` rejects a `questions` option at compile time. If the constructor omits them, every `evaluate()` call must provide them.
|
|
109
|
+
Constructor questions and per-call questions are mutually exclusive. If the constructor includes `questions`, `evaluate()` rejects a `questions` option at compile time. If the constructor omits them, every `evaluate()` call must provide them. A processor, workflow step, or scorer classifies through a configured classifier, which requires constructor questions.
|
|
102
110
|
|
|
103
111
|
## Question types
|
|
104
112
|
|
|
@@ -190,6 +198,18 @@ const answer = {
|
|
|
190
198
|
}
|
|
191
199
|
```
|
|
192
200
|
|
|
201
|
+
## Designing questions
|
|
202
|
+
|
|
203
|
+
These rules keep a question answerable from the state:
|
|
204
|
+
|
|
205
|
+
- Ask for one judgment. A question that moves when either of two fields changes can't be routed on.
|
|
206
|
+
- Keep criteria exclusive. `strong: 'A good fit'` and `partial: 'Maybe a fit'` leak probability between them.
|
|
207
|
+
- Give a score enough levels to represent intermediate values.
|
|
208
|
+
- Add an escape level when the list isn't closed. Three teams and no `other` forces every input into a team.
|
|
209
|
+
- Put fields in `state`, not in `instructions`. One changed field then moves one answer.
|
|
210
|
+
|
|
211
|
+
To check a question, change one field of the state and confirm one answer moves.
|
|
212
|
+
|
|
193
213
|
## `evaluate(options)`
|
|
194
214
|
|
|
195
215
|
Evaluates all questions against the supplied state.
|
|
@@ -210,11 +230,11 @@ Omit `questions` from the constructor when the question set changes between eval
|
|
|
210
230
|
|
|
211
231
|
```typescript
|
|
212
232
|
import { Classifier } from '@mastra/core/classifier'
|
|
213
|
-
import {
|
|
233
|
+
import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
214
234
|
|
|
215
235
|
const classifier = new Classifier({
|
|
216
236
|
id: 'dynamic-classifier',
|
|
217
|
-
model:
|
|
237
|
+
model: typeSafeAi.evaluationModel('jev-latest'),
|
|
218
238
|
})
|
|
219
239
|
|
|
220
240
|
const result = await classifier.evaluate({
|
|
@@ -298,7 +318,7 @@ import {
|
|
|
298
318
|
MastraEvaluationModel,
|
|
299
319
|
type EvaluationModelResult,
|
|
300
320
|
} from '@mastra/core/classifier'
|
|
301
|
-
import {
|
|
321
|
+
import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
302
322
|
|
|
303
323
|
class NormalizedEvaluationModel extends MastraEvaluationModel {
|
|
304
324
|
protected override transformResult(result: EvaluationModelResult): EvaluationModelResult {
|
|
@@ -312,7 +332,7 @@ class NormalizedEvaluationModel extends MastraEvaluationModel {
|
|
|
312
332
|
const classifier = new Classifier({
|
|
313
333
|
id: 'normalized-classifier',
|
|
314
334
|
model: new NormalizedEvaluationModel(
|
|
315
|
-
|
|
335
|
+
typeSafeAi.evaluationModel('jev-latest'),
|
|
316
336
|
),
|
|
317
337
|
})
|
|
318
338
|
```
|
|
@@ -326,20 +346,20 @@ Register classifiers on the `Mastra` instance to share them across your applicat
|
|
|
326
346
|
```typescript
|
|
327
347
|
import { Mastra } from '@mastra/core'
|
|
328
348
|
import { Classifier } from '@mastra/core/classifier'
|
|
329
|
-
import {
|
|
349
|
+
import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
330
350
|
|
|
331
|
-
export const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
questions: {
|
|
337
|
-
unsafe: { type: 'boolean' },
|
|
338
|
-
},
|
|
339
|
-
}),
|
|
351
|
+
export const safety = new Classifier({
|
|
352
|
+
id: 'safety',
|
|
353
|
+
model: typeSafeAi.evaluationModel('jev-latest'),
|
|
354
|
+
questions: {
|
|
355
|
+
unsafe: { type: 'boolean' },
|
|
340
356
|
},
|
|
341
357
|
})
|
|
342
358
|
|
|
359
|
+
export const mastra = new Mastra({
|
|
360
|
+
classifiers: { safety },
|
|
361
|
+
})
|
|
362
|
+
|
|
343
363
|
mastra.getClassifier('safety')
|
|
344
364
|
mastra.getClassifierById('safety')
|
|
345
365
|
mastra.listClassifiers()
|
|
@@ -350,20 +370,27 @@ mastra.listClassifiers()
|
|
|
350
370
|
A classifier with constructor-configured questions can be added to a workflow with [`createStep(classifier)`](https://mastra.ai/reference/workflows/step) or [`.classifier()`](https://mastra.ai/reference/workflows/workflow-methods/classifier). Workflow output contains complete typed `answers` and normalized `usage`.
|
|
351
371
|
|
|
352
372
|
```typescript
|
|
373
|
+
import { safety } from '../index'
|
|
374
|
+
|
|
353
375
|
const workflow = createWorkflow({
|
|
354
376
|
id: 'ticket-triage',
|
|
355
377
|
inputSchema: z.object({ message: z.string() }),
|
|
356
378
|
outputSchema: z.any(),
|
|
357
379
|
})
|
|
358
380
|
.map({ message: { initData: true, path: 'message' } })
|
|
359
|
-
.classifier('safety')
|
|
381
|
+
.classifier<typeof safety.questions>('safety')
|
|
360
382
|
.commit()
|
|
361
383
|
```
|
|
362
384
|
|
|
385
|
+
A string reference resolves through the `Mastra` instance at execution time. The ID doesn't carry the question types, so supply them with a type argument to keep the answers typed. In Studio, the workflow graph shows the step as a classifier node.
|
|
386
|
+
|
|
363
387
|
The workflow adapter doesn't include warnings, raw provider responses, headers, or provider metadata in step output. Use direct `evaluate()` calls or classifier observability when you need that provider-level detail.
|
|
364
388
|
|
|
365
389
|
## Related
|
|
366
390
|
|
|
391
|
+
- [ClassifierProcessor](https://mastra.ai/reference/processors/classifier-processor)
|
|
392
|
+
- [ModelSelectionProcessor](https://mastra.ai/reference/processors/model-selection-processor)
|
|
393
|
+
- [createClassifierScorer()](https://mastra.ai/reference/evals/create-classifier-scorer)
|
|
367
394
|
- [Workflow.classifier()](https://mastra.ai/reference/workflows/workflow-methods/classifier)
|
|
368
395
|
- [Step class](https://mastra.ai/reference/workflows/step)
|
|
369
396
|
- [getClassifier()](https://mastra.ai/reference/core/getClassifier)
|
|
@@ -45,7 +45,7 @@ const completeTrace = await mastraClient.getTrace(traces.spans[0].traceId)
|
|
|
45
45
|
|
|
46
46
|
## Listing traces for a list view
|
|
47
47
|
|
|
48
|
-
`listTracesLight()` returns the same rows as a trace list, without the `input`, `output` and `attributes` payloads. Each row carries a short `inputPreview` string instead, so a list can render a preview column without transferring the whole prompt.
|
|
48
|
+
`listTracesLight()` returns the same rows as a trace list, without the `input`, `output` and `attributes` payloads. Each row carries a short `inputPreview` string instead, so a list can render a preview column without transferring the whole prompt, plus `threadId` and `resourceId` for the memory context columns.
|
|
49
49
|
|
|
50
50
|
Prefer it whenever you are rendering many traces at once, and fetch the full record only when a row is opened:
|
|
51
51
|
|
|
@@ -82,7 +82,7 @@ Each default has an explicit opt-out:
|
|
|
82
82
|
| ---------------------- | ------------------------------------------- |
|
|
83
83
|
| Workspace | `workspace: undefined` |
|
|
84
84
|
| Task tracking | Don't configure `memory` on the agent |
|
|
85
|
-
| Error processors | `
|
|
85
|
+
| Error processors | `errorProcessorDefaults: false` |
|
|
86
86
|
| Output processors | `outputProcessors: []` |
|
|
87
87
|
| Processor retry budget | `maxProcessorRetries: 0` |
|
|
88
88
|
| Goal judge prompt | Omit `goal`, or pass your own `goal.prompt` |
|
|
@@ -196,7 +196,7 @@ The default [`StreamErrorRetryProcessor`](https://mastra.ai/reference/processors
|
|
|
196
196
|
- Network resets (`ECONNRESET` / `socket hang up`) retry up to twice with exponential backoff (`1000ms * 2^retryCount`, capped at `30000ms`).
|
|
197
197
|
- Bad-request errors retry once after `2000ms`.
|
|
198
198
|
|
|
199
|
-
Specific network-reset and bad-request policies take precedence over the unknown-error policy. Passing `errorProcessors`
|
|
199
|
+
Specific network-reset and bad-request policies take precedence over the unknown-error policy. Passing `errorProcessors` sets the base list: any of the three shared defaults your list doesn't name by `id` is still added, at the position its `id` gives it. An empty list gets all three. Setting `errorProcessorDefaults: false` keeps your list exactly as given, adding none of the shared defaults. Without a list, the agent then runs no error processors. A `StreamErrorRetryProcessor` added this way uses the shared defaults, so it retries neither unknown errors nor bad-request (HTTP 400) responses. Supply your own instance in the list to keep either policy. `PrefillErrorHandler` and `ProviderHistoryCompat` are also included for provider compatibility: both repair errors caused by the shape of the message history, such as a provider rejecting a conversation that ends with an assistant message.
|
|
200
200
|
|
|
201
201
|
[`CyberRefusalHandler`](https://mastra.ai/reference/processors/cyber-refusal-handler) retries once when an OpenAI or Anthropic cybersecurity safeguard refuses a step, which often happens to ordinary coding work. It runs in both `errorProcessors` (OpenAI refusals are API errors) and `outputProcessors` (Anthropic refusals finish the step). Passing either list replaces that half of the handler.
|
|
202
202
|
|
|
@@ -373,13 +373,11 @@ Visit the [Classifier reference](https://mastra.ai/reference/classifier/classifi
|
|
|
373
373
|
```typescript
|
|
374
374
|
import { Mastra } from '@mastra/core'
|
|
375
375
|
import { Classifier } from '@mastra/core/classifier'
|
|
376
|
-
import {
|
|
376
|
+
import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
377
377
|
|
|
378
378
|
const safety = new Classifier({
|
|
379
379
|
id: 'safety',
|
|
380
|
-
model:
|
|
381
|
-
'jev-latest',
|
|
382
|
-
),
|
|
380
|
+
model: typeSafeAi.evaluationModel('jev-latest'),
|
|
383
381
|
questions: {
|
|
384
382
|
unsafe: {
|
|
385
383
|
type: 'boolean',
|
|
@@ -14,7 +14,7 @@ Agent scorer runs contain message objects that `Classifier.evaluate()` can't acc
|
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
16
|
import { Classifier } from '@mastra/core/classifier'
|
|
17
|
-
import {
|
|
17
|
+
import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
18
18
|
import { createClassifierScorer } from '@mastra/core/evals'
|
|
19
19
|
import {
|
|
20
20
|
getAssistantMessageFromRunOutput,
|
|
@@ -23,9 +23,7 @@ import {
|
|
|
23
23
|
|
|
24
24
|
const responseJudge = new Classifier({
|
|
25
25
|
id: 'response-judge',
|
|
26
|
-
model:
|
|
27
|
-
'jev-latest',
|
|
28
|
-
),
|
|
26
|
+
model: typeSafeAi.evaluationModel('jev-latest'),
|
|
29
27
|
questions: {
|
|
30
28
|
quality: {
|
|
31
29
|
type: 'score',
|
|
@@ -55,7 +55,7 @@ const scorer = createScorer({
|
|
|
55
55
|
|
|
56
56
|
**judge.errorProcessors** (`Processor[]`): Error processors for judge models that use Mastra’s current generation API. These implement processAPIError and can inspect LLM API rejections and signal a retry, e.g. StreamErrorRetryProcessor. Legacy model adapters use generateLegacy() and do not run error processors.
|
|
57
57
|
|
|
58
|
-
**judge.maxProcessorRetries** (`number`): Maximum number of times error processors can retry one judge generation. The runtime defaults to
|
|
58
|
+
**judge.maxProcessorRetries** (`number`): Maximum number of times error processors can retry one judge generation. The runtime defaults to 3 when errorProcessors are configured without this value. Set it explicitly to bound the retry budget.
|
|
59
59
|
|
|
60
60
|
**type** (`string`): Type specification for input/output. Use 'agent' for automatic agent types. For custom types, use the generic approach instead.
|
|
61
61
|
|
|
@@ -793,7 +793,7 @@ Mastra also injects scope-aware usage instructions into the agent's context. For
|
|
|
793
793
|
|
|
794
794
|
**limit** (`number`): Maximum number of items to return per page. (Default: `20`)
|
|
795
795
|
|
|
796
|
-
**detail** (`'low' | 'high'`): Controls how much content is shown per message part. 'low' shows truncated text and tool names with positional indices (\[p0], \[p1]). 'high' shows full content including tool arguments and results, clamped to one part per call with continuation hints. (Default: `'low'`)
|
|
796
|
+
**detail** (`'low' | 'high'`): Controls how much content is shown per message part. 'low' shows truncated text and tool names with positional indices (\[p0], \[p1]). 'high' shows full content including tool arguments and results, clamped to one part per call with continuation hints. Image and file parts show their filename, media type, and stored URL or provider file ID so the agent can reuse the attachment. Inline file data such as base64 or data URIs is omitted. Pass viewAttachment with cursor and partIndex to send inline attachment data to the model. (Default: `'low'`)
|
|
797
797
|
|
|
798
798
|
**partType** (`'text' | 'tool-call' | 'tool-result' | 'reasoning' | 'image' | 'file'`): Filter results to only include message parts of this type. Only applies to mode: "messages".
|
|
799
799
|
|
|
@@ -803,6 +803,8 @@ Mastra also injects scope-aware usage instructions into the agent's context. For
|
|
|
803
803
|
|
|
804
804
|
**charOffset** (`number`): Character position to continue reading a truncated single part. Only applies with cursor and partIndex. When a part is larger than the token budget, the result includes nextCharOffset — pass that exact value here in the next call to read the following chunk. The chunks concatenate to the original part text. (Default: `0`)
|
|
805
805
|
|
|
806
|
+
**viewAttachment** (`boolean`): Show the attachment itself rather than only describing it. Requires cursor and partIndex, and applies when that part is an image or file. Inline data such as base64 or data URIs is sent as a native media part. Attachments stored as remote URLs or provider file IDs, media types outside image/\* and application/pdf, and oversized payloads come back as an explanation instead. (Default: `false`)
|
|
807
|
+
|
|
806
808
|
**before** (`string`): For mode: "threads" only. Filter to threads created before this date. Accepts ISO 8601 format (e.g. "2026-03-15", "2026-03-10T00:00:00Z").
|
|
807
809
|
|
|
808
810
|
**after** (`string`): For mode: "threads" only. Filter to threads created after this date. Accepts ISO 8601 format (e.g. "2026-03-01", "2026-03-10T00:00:00Z").
|
|
@@ -105,7 +105,7 @@ Ends the span and triggers export to configured exporters. Sets the `endTime` an
|
|
|
105
105
|
error(options: ErrorSpanOptions<TType>): void
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
Records an error on the span. Sets the `errorInfo` field and can optionally end the span.
|
|
108
|
+
Records an error on the span. Sets the `errorInfo` field and can optionally end the span. When the error is an AI SDK `APICallError` (or wraps one as `cause`), `errorInfo.details` also carries the HTTP `statusCode`, request `url`, `isRetryable` flag and provider `responseBody`.
|
|
109
109
|
|
|
110
110
|
#### update
|
|
111
111
|
|
|
@@ -12,14 +12,12 @@ Abort reasons are always the string supplied by the caller. Provider-generated t
|
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
14
|
import { Classifier } from '@mastra/core/classifier'
|
|
15
|
-
import {
|
|
15
|
+
import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
16
16
|
import { ClassifierProcessor } from '@mastra/core/processors'
|
|
17
17
|
|
|
18
18
|
const safety = new Classifier({
|
|
19
19
|
id: 'safety',
|
|
20
|
-
model:
|
|
21
|
-
'jev-latest',
|
|
22
|
-
),
|
|
20
|
+
model: typeSafeAi.evaluationModel('jev-latest'),
|
|
23
21
|
questions: {
|
|
24
22
|
unsafe: {
|
|
25
23
|
type: 'boolean',
|
|
@@ -95,12 +93,12 @@ Messages with no text content are passed through without calling the classifier.
|
|
|
95
93
|
```typescript
|
|
96
94
|
import { Agent } from '@mastra/core/agent'
|
|
97
95
|
import { Classifier } from '@mastra/core/classifier'
|
|
98
|
-
import {
|
|
96
|
+
import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
99
97
|
import { ClassifierProcessor } from '@mastra/core/processors'
|
|
100
98
|
|
|
101
99
|
const topic = new Classifier({
|
|
102
100
|
id: 'topic',
|
|
103
|
-
model:
|
|
101
|
+
model: typeSafeAi.evaluationModel('jev-latest'),
|
|
104
102
|
questions: {
|
|
105
103
|
topic: {
|
|
106
104
|
type: 'choice',
|
|
@@ -137,12 +135,12 @@ export const agent = new Agent({
|
|
|
137
135
|
```typescript
|
|
138
136
|
import { Agent } from '@mastra/core/agent'
|
|
139
137
|
import { Classifier } from '@mastra/core/classifier'
|
|
140
|
-
import {
|
|
138
|
+
import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
141
139
|
import { ClassifierProcessor } from '@mastra/core/processors'
|
|
142
140
|
|
|
143
141
|
const quality = new Classifier({
|
|
144
142
|
id: 'quality',
|
|
145
|
-
model:
|
|
143
|
+
model: typeSafeAi.evaluationModel('jev-latest'),
|
|
146
144
|
questions: {
|
|
147
145
|
quality: {
|
|
148
146
|
type: 'score',
|
|
@@ -175,13 +173,13 @@ Register the classifier on the `Mastra` instance and reference it by key or ID.
|
|
|
175
173
|
```typescript
|
|
176
174
|
import { Mastra } from '@mastra/core'
|
|
177
175
|
import { Classifier } from '@mastra/core/classifier'
|
|
178
|
-
import {
|
|
176
|
+
import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
179
177
|
|
|
180
178
|
export const mastra = new Mastra({
|
|
181
179
|
classifiers: {
|
|
182
180
|
safety: new Classifier({
|
|
183
181
|
id: 'safety',
|
|
184
|
-
model:
|
|
182
|
+
model: typeSafeAi.evaluationModel('jev-latest'),
|
|
185
183
|
questions: {/* ... */},
|
|
186
184
|
}),
|
|
187
185
|
},
|
|
@@ -13,7 +13,7 @@ Describe each model alongside the kind of request it should handle. The processo
|
|
|
13
13
|
```typescript
|
|
14
14
|
import { Agent } from '@mastra/core/agent'
|
|
15
15
|
import { ModelSelectionProcessor } from '@mastra/core/processors'
|
|
16
|
-
import {
|
|
16
|
+
import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
17
17
|
|
|
18
18
|
export const agent = new Agent({
|
|
19
19
|
name: 'support-agent',
|
|
@@ -21,9 +21,7 @@ export const agent = new Agent({
|
|
|
21
21
|
model: 'openai/gpt-5.6-sol',
|
|
22
22
|
inputProcessors: [
|
|
23
23
|
new ModelSelectionProcessor({
|
|
24
|
-
model:
|
|
25
|
-
'jev-latest',
|
|
26
|
-
),
|
|
24
|
+
model: typeSafeAi.evaluationModel('jev-latest'),
|
|
27
25
|
choices: [
|
|
28
26
|
{
|
|
29
27
|
model: 'openai/gpt-5-mini',
|
|
@@ -81,13 +79,13 @@ By default the decision applies to every step of the run. Set `scope: 'first-ste
|
|
|
81
79
|
|
|
82
80
|
```typescript
|
|
83
81
|
import { ModelSelectionProcessor } from '@mastra/core/processors'
|
|
84
|
-
import {
|
|
82
|
+
import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
85
83
|
import { PinoLogger } from '@mastra/loggers'
|
|
86
84
|
|
|
87
85
|
const logger = new PinoLogger({ name: 'model-selection' })
|
|
88
86
|
|
|
89
87
|
new ModelSelectionProcessor({
|
|
90
|
-
model:
|
|
88
|
+
model: typeSafeAi.evaluationModel('jev-latest'),
|
|
91
89
|
choices: [
|
|
92
90
|
{ model: 'openai/gpt-5-mini', criteria: 'Simple lookups' },
|
|
93
91
|
{ model: 'openai/gpt-5.6-sol', criteria: 'Multi-step reasoning' },
|
|
@@ -114,11 +112,11 @@ Pass `classifier` instead of `choices` to route on a [Classifier](https://mastra
|
|
|
114
112
|
|
|
115
113
|
```typescript
|
|
116
114
|
import { Classifier } from '@mastra/core/classifier'
|
|
117
|
-
import {
|
|
115
|
+
import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
118
116
|
|
|
119
117
|
const triage = new Classifier({
|
|
120
118
|
id: 'triage',
|
|
121
|
-
model:
|
|
119
|
+
model: typeSafeAi.evaluationModel('jev-latest'),
|
|
122
120
|
questions: {
|
|
123
121
|
complexity: {
|
|
124
122
|
type: 'choice',
|
|
@@ -155,12 +153,12 @@ Choice criteria are mutually exclusive, which is the wrong shape when routing de
|
|
|
155
153
|
|
|
156
154
|
```typescript
|
|
157
155
|
import { Classifier } from '@mastra/core/classifier'
|
|
158
|
-
import {
|
|
156
|
+
import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
159
157
|
import { ModelSelectionProcessor } from '@mastra/core/processors'
|
|
160
158
|
|
|
161
159
|
const triage = new Classifier({
|
|
162
160
|
id: 'triage',
|
|
163
|
-
model:
|
|
161
|
+
model: typeSafeAi.evaluationModel('jev-latest'),
|
|
164
162
|
questions: {
|
|
165
163
|
complexity: {
|
|
166
164
|
type: 'choice',
|
|
@@ -8,7 +8,7 @@ The `PrefillErrorHandler` is an **error processor** that handles assistant-respo
|
|
|
8
8
|
|
|
9
9
|
When the error is detected, the processor sends a hidden `system-reminder` signal with `continue` as its contents and signals a retry. The reminder is persisted as signal metadata, which keeps it available for retry reconstruction and raw history while standard UI-facing message conversions hide it.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Mastra adds this processor to every agent's `errorProcessors` by default, after `ProviderHistoryCompat` and before `StreamErrorRetryProcessor`. It only acts on the first retry attempt, so it needs no configuration. Supply your own instance to tune it. Anything already in your list is kept and the default is only added when its `id` is absent.
|
|
12
12
|
|
|
13
13
|
## How it works
|
|
14
14
|
|
|
@@ -21,7 +21,7 @@ The processor now reacts to the API rejection itself instead of re-checking whet
|
|
|
21
21
|
|
|
22
22
|
## Usage example
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
To tune or explicitly scope prefill recovery, supply your own instance. The default `PrefillErrorHandler` isn't added when you do:
|
|
25
25
|
|
|
26
26
|
```typescript
|
|
27
27
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -170,7 +170,7 @@ Use `messages` when you only need to read, map over, or lightly edit fields on t
|
|
|
170
170
|
|
|
171
171
|
When memory is enabled, only what ends up in `messageList` after all processors finish is persisted to storage. Both return styles are equivalent for persistence:
|
|
172
172
|
|
|
173
|
-
- When you mutate `messageList` directly (or return the same `MessageList` instance), recorded mutations are applied in place
|
|
173
|
+
- When you mutate `messageList` directly (or return the same `MessageList` instance), recorded mutations are applied in place. The saved conversation reflects your changes.
|
|
174
174
|
- When you return a `MastraDBMessage[]` or `{ messages, systemMessages }`, Mastra reconciles the returned array against `messageList` for the current stage, removing missing messages and replacing system messages.
|
|
175
175
|
|
|
176
176
|
Returning a different `MessageList` instance is an error. Always mutate the one passed to your processor.
|
|
@@ -1034,7 +1034,7 @@ abort('Blocked content detected', { retry: false, metadata: { category: 'pii' }
|
|
|
1034
1034
|
```
|
|
1035
1035
|
|
|
1036
1036
|
- `reason`: A human-readable explanation. Appears as `tripwire.payload.reason`.
|
|
1037
|
-
- `retry`: When `true`, the agent retries the same step with `reason` fed back as feedback. Retries only run when `maxProcessorRetries` is set on the agent or call; otherwise the request aborts.
|
|
1037
|
+
- `retry`: When `true`, the agent retries the same step with `reason` fed back as feedback. Retries only run when `maxProcessorRetries` is set on the agent or call; otherwise the request aborts. The safety cap of `3` that applies when no cap is set covers only error-processor retries from `processAPIError`. It doesn't give abort retries a budget.
|
|
1038
1038
|
- `metadata`: Optional structured data attached to the `tripwire` chunk for downstream consumers.
|
|
1039
1039
|
|
|
1040
1040
|
The emitted `tripwire` chunk has the shape:
|
|
@@ -10,7 +10,7 @@ Use it when an agent may switch between model providers or reuse message history
|
|
|
10
10
|
|
|
11
11
|
## Usage example
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Mastra adds this processor to every agent's `errorProcessors` by default when your list doesn't already contain that `id`. Among the added defaults it comes first. Its outbound prompt rules run before the other defaults, including the retry processor's blind resend. Supply your own instance to add custom rules or position it yourself:
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
16
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -21,19 +21,18 @@ export const agent = new Agent({
|
|
|
21
21
|
name: 'my-agent',
|
|
22
22
|
instructions: 'You are a helpful assistant.',
|
|
23
23
|
model: 'anthropic/claude-sonnet-4-5',
|
|
24
|
-
|
|
25
|
-
errorProcessors: [new ProviderHistoryCompat()],
|
|
24
|
+
errorProcessors: [new ProviderHistoryCompat({ additionalRules: [/* ... */] })],
|
|
26
25
|
})
|
|
27
26
|
```
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
A supplied `ProviderHistoryCompat` is used instead of the default. The default is only added when no processor in your list carries that `id`. Place an instance in `inputProcessors` when you want the prompt-rewriting rules to run in the input lane instead.
|
|
30
29
|
|
|
31
30
|
The placement decides which half of the processor works:
|
|
32
31
|
|
|
33
|
-
- **Reactive rules need `errorProcessors`.** On the standard loop, `processAPIError` runs from any of the three lists, so an input-processor registration does repair the message list, but the retry it asks for is only honored when the agent has a retry budget,
|
|
34
|
-
- **Preemptive rules
|
|
32
|
+
- **Reactive rules need `errorProcessors`.** On the standard loop, `processAPIError` runs from any of the three lists, so an input-processor registration does repair the message list, but the retry it asks for is only honored when the agent has a retry budget. With the default error processors in place the resolved list is non-empty, so a safety cap of `3` applies. The budget is left `undefined` only when the caller runs with no error processors at all (`errorProcessorDefaults: false` with none configured) and doesn't set `maxProcessorRetries` explicitly. Registered only as an input processor in that no-budget state, a reactive rule repairs the history and the request still fails. On the durable path the API-error pass additionally requires a non-empty `errorProcessors` list. If that list is empty, an input-processor registration can't trigger reactive recovery there at all, even with `maxProcessorRetries` set.
|
|
33
|
+
- **Preemptive rules run from either list.** `processLLMRequest` runs over the input processors and over the resolved error processors, so a `ProviderHistoryCompat` in `errorProcessors` gets its prompt rewrites as well as its reactive recovery. An instance registered in `inputProcessors` runs once, in its input position.
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
Registering in `errorProcessors` alone, as the example above does, covers both halves. Double registration can't cause a double retry: the runner stops at the first processor that asks for one, and each reactive rule bails once `retryCount` is above zero, so a repaired turn is attempted exactly once more.
|
|
37
36
|
|
|
38
37
|
## Constructor parameters
|
|
39
38
|
|
|
@@ -55,19 +54,21 @@ An agent that wants both registers the processor in both lists, as the example a
|
|
|
55
54
|
|
|
56
55
|
`ProviderHistoryCompat` includes these built-in compatibility rules:
|
|
57
56
|
|
|
58
|
-
| Rule | Provider | Timing | Behavior
|
|
59
|
-
| ------------------------------------------- | -------------------------------- | --------------------------- |
|
|
60
|
-
| `anthropic-tool-id-format` | Anthropic |
|
|
61
|
-
| `cerebras-strip-reasoning-content` | Cerebras | Preemptive prompt rewrite | Removes assistant `reasoning` parts from the outbound prompt so they're not serialized as unsupported `reasoning_content` fields.
|
|
62
|
-
| `anthropic-strip-foreign-reasoning-content` | Anthropic | Preemptive prompt rewrite | Removes non-Anthropic assistant `reasoning` parts from the outbound prompt. Anthropic-native thinking history is preserved.
|
|
63
|
-
| `anthropic-strip-foreign-signed-reasoning` | Anthropic-compatible | Preemptive prompt rewrite | Drops signed thinking from the outbound prompt when its origin turn was stamped with a different provider (for example Kimi For Coding ↔ `anthropic/claude-sonnet-4-6`), since the receiving provider can't verify another provider's signature. Turns emptied of all content by the drop are removed from the prompt. Unstamped history is left untouched.
|
|
64
|
-
| `azure-system-reminder-transform` | Azure OpenAI | Preemptive prompt rewrite | Renames `<system-reminder>` wrappers in user text and system instructions to `<memory-context>` for the outbound request. Stored history remains unchanged.
|
|
65
|
-
| `openai-orphan-item-id` | OpenAI, Azure OpenAI (Responses) | Reactive API error recovery | Recovers history that OpenAI rejects with `Item 'msg_…' of type 'message' was provided without its required 'reasoning' item`. Drops the Responses `itemId` from every item-bearing part of an assistant message that carries one but has no `reasoning` part,
|
|
57
|
+
| Rule | Provider | Timing | Behavior |
|
|
58
|
+
| ------------------------------------------- | -------------------------------- | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
59
|
+
| `anthropic-tool-id-format` | Anthropic | Preemptive prompt rewrite | Rewrites tool call IDs that contain characters outside `[a-zA-Z0-9_-]` in the outbound prompt, on both the call and its result. A sanitized ID that would collide with one already in the prompt gets a `_2`, `_3`, … suffix. The provider's rejection never fires, and persisted history keeps the original IDs. A reactive fallback covers providers the preemptive check doesn't recognize, such as Vertex-hosted Claude. |
|
|
60
|
+
| `cerebras-strip-reasoning-content` | Cerebras | Preemptive prompt rewrite | Removes assistant `reasoning` parts from the outbound prompt so they're not serialized as unsupported `reasoning_content` fields. |
|
|
61
|
+
| `anthropic-strip-foreign-reasoning-content` | Anthropic | Preemptive prompt rewrite | Removes non-Anthropic assistant `reasoning` parts from the outbound prompt. Anthropic-native thinking history is preserved. |
|
|
62
|
+
| `anthropic-strip-foreign-signed-reasoning` | Anthropic-compatible | Preemptive prompt rewrite | Drops signed thinking from the outbound prompt when its origin turn was stamped with a different provider (for example Kimi For Coding ↔ `anthropic/claude-sonnet-4-6`), since the receiving provider can't verify another provider's signature. Turns emptied of all content by the drop are removed from the prompt. Unstamped history is left untouched. |
|
|
63
|
+
| `azure-system-reminder-transform` | Azure OpenAI | Preemptive prompt rewrite | Renames `<system-reminder>` wrappers in user text and system instructions to `<memory-context>` for the outbound request. Stored history remains unchanged. |
|
|
64
|
+
| `openai-orphan-item-id` | OpenAI, Azure OpenAI (Responses) | Reactive API error recovery | Recovers history that OpenAI rejects with `Item 'msg_…' of type 'message' was provided without its required 'reasoning' item`. Drops the Responses `itemId` from every item-bearing part of an assistant message that carries one but has no `reasoning` part, and retries. The message then replays by value instead of as an unsatisfiable `item_reference`. The repair is applied to the in-memory list for the current turn. |
|
|
66
65
|
|
|
67
|
-
Preemptive rules run through `processLLMRequest` after Mastra converts messages to the model prompt format and before the prompt is sent to the provider. These rewrites affect only the current provider call.
|
|
66
|
+
Preemptive rules run through `processLLMRequest` after Mastra converts messages to the model prompt format and before the prompt is sent to the provider. These rewrites affect only the current provider call. Persisted history is never changed, so the IDs and content in memory and in the Studio stay exactly as written.
|
|
68
67
|
|
|
69
68
|
Reactive rules run through `processAPIError` after a provider rejection. They can update the persisted `messageList` and request a retry.
|
|
70
69
|
|
|
70
|
+
`anthropic-tool-id-format` implements both. Its preemptive hook normally prevents the rejection from happening at all, which leaves the reactive hook dormant. See [Tool call ID repair is prompt-scoped](#tool-call-id-repair-is-prompt-scoped) below.
|
|
71
|
+
|
|
71
72
|
## `CompatRule`
|
|
72
73
|
|
|
73
74
|
A `CompatRule` defines one provider history compatibility fix:
|
|
@@ -140,7 +141,26 @@ export const agent = new Agent({
|
|
|
140
141
|
})
|
|
141
142
|
```
|
|
142
143
|
|
|
143
|
-
Use `applyToPrompt` for provider-specific rewrites that shouldn't be saved to memory. Use `fix` with `errorPatterns` when the
|
|
144
|
+
Use `applyToPrompt` for provider-specific rewrites that shouldn't be saved to memory. This is what new rules should normally reach for, and it's the hook the built-in rules use. Use `fix` with `errorPatterns` only when the repaired history must persist and be reused on future turns, and when the provider can't be stopped from rejecting the request up front.
|
|
145
|
+
|
|
146
|
+
## Tool call ID repair is prompt-scoped
|
|
147
|
+
|
|
148
|
+
Anthropic enforces `^[a-zA-Z0-9_-]+$` on `tool_use.id`. A tool call whose ID came from another provider, containing `.` or `:`, is rejected. The rule sanitizes those IDs in the outbound request:
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
// What the provider receives
|
|
152
|
+
tool_use.id: 'call_abc_1'
|
|
153
|
+
// What stays in memory, in the returned messages, and in the Studio
|
|
154
|
+
toolCallId: 'call.abc:1'
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Both the `tool-call` and its paired `tool-result` are rewritten from the same map, so call/result pairing survives the rewrite. Replacement IDs are assigned in encounter order and never collide with an ID the prompt already carries: if `a.b` sanitizes to `a_b` and the prompt already has an `a_b`, the rewritten ID becomes `a_b_2`.
|
|
158
|
+
|
|
159
|
+
Because nothing is persisted, a caller that reuses the same message list in a later turn sees the original IDs again, and the repair runs again on that request.
|
|
160
|
+
|
|
161
|
+
### Reactive fallback
|
|
162
|
+
|
|
163
|
+
The rule's `errorPatterns` and `fix` hooks repair the same rejection after the provider raises it. The preemptive rewrite only runs when `isMaybeAnthropic(model)` matches. The reactive path stays the fallback for Claude served through a provider the check doesn't recognize, such as Vertex-hosted Claude, and the only repair once a call has already been rejected. A rule can use both hooks together, and `fix` on the `CompatRule` interface itself isn't deprecated: custom rules legitimately use it.
|
|
144
164
|
|
|
145
165
|
## Related
|
|
146
166
|
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
`StreamErrorRetryProcessor` is an **error processor** that retries transient LLM API and stream failures. It includes built-in matching for OpenAI Responses stream errors and supports additional matchers for other provider-specific error shapes.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Mastra adds this processor to every agent's `errorProcessors` by default, last, after the `ProviderHistoryCompat` and `PrefillErrorHandler` defaults, so the processors that repair a request get their chance before this one retries it unchanged. The default instance uses `maxRetries: 2` with a connection-reset matcher alongside the built-in matching, and it doesn't retry unknown errors or replay bad-request (HTTP 400) responses the repair processors couldn't fix. Supply your own instance in `errorProcessors` to change its policy. Because a default is only added when its `id` is missing from your list, your instance is used and the default isn't added alongside it.
|
|
10
10
|
|
|
11
11
|
## Usage example
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Configure `StreamErrorRetryProcessor`. Supplying the same `id` means the default isn't added:
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
16
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -21,10 +21,15 @@ export const agent = new Agent({
|
|
|
21
21
|
name: 'openai-agent',
|
|
22
22
|
instructions: 'You are a helpful assistant.',
|
|
23
23
|
model: 'openai/gpt-5',
|
|
24
|
-
errorProcessors: [new StreamErrorRetryProcessor()],
|
|
24
|
+
errorProcessors: [new StreamErrorRetryProcessor({ maxRetries: 5 })],
|
|
25
|
+
maxProcessorRetries: 5,
|
|
25
26
|
})
|
|
26
27
|
```
|
|
27
28
|
|
|
29
|
+
Set `maxProcessorRetries` alongside a `maxRetries` above `3`, because the agent stops error-processor retries at `3` when it's unset. See [Retry limits](#retry-limits).
|
|
30
|
+
|
|
31
|
+
To run only the processors you configure, with none of the defaults merged in, set `errorProcessorDefaults: false`. Without an `errorProcessors` list, the agent then runs no error processors. An empty `errorProcessors` list still gets the defaults. Supplying your own processor for all three default ids replaces every default with your own implementation.
|
|
32
|
+
|
|
28
33
|
## How it works
|
|
29
34
|
|
|
30
35
|
The processor checks the error and its cause chain for:
|
|
@@ -39,7 +44,7 @@ When `delayMs` is set, the processor waits before signaling a retry. This is use
|
|
|
39
44
|
|
|
40
45
|
### Retry limits
|
|
41
46
|
|
|
42
|
-
`maxRetries` defaults to `1` and limits this processor's retry requests. The agent also limits processor retries with `maxProcessorRetries`. When error processors are configured without an agent limit, the runtime cap is `
|
|
47
|
+
`maxRetries` defaults to `1` and limits this processor's retry requests. The agent also limits processor retries with `maxProcessorRetries`. When error processors are configured without an agent limit, the runtime cap is `3`.
|
|
43
48
|
|
|
44
49
|
Set both values explicitly to the same bounded value when you need a single retry budget. Keep model `maxRetries` at `0` for that call to avoid multiplying provider attempts.
|
|
45
50
|
|
|
@@ -53,6 +53,8 @@ app.listen(3000)
|
|
|
53
53
|
console.log('Server running on http://localhost:3000')
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
`init()` doesn't start Mastra's background workers. To run [scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows), agent schedules, or event listeners, call `await mastra.startWorkers()` after the server starts listening. See [Start background workers](https://mastra.ai/docs/server/server-adapters).
|
|
57
|
+
|
|
56
58
|
## Constructor parameters
|
|
57
59
|
|
|
58
60
|
**app** (`Elysia`): Elysia app instance
|
|
@@ -52,7 +52,7 @@ app.listen(4111, () => {
|
|
|
52
52
|
})
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
Express requires `express.json()` middleware for JSON body parsing. Add it before creating the `MastraServer`. `init()` doesn't start Mastra's background workers. To run [scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows), agent schedules, or event listeners, call `await mastra.startWorkers()` after the server starts listening. See [Start background workers](https://mastra.ai/docs/server/server-adapters).
|
|
56
56
|
|
|
57
57
|
## Constructor parameters
|
|
58
58
|
|
|
@@ -55,6 +55,8 @@ app.listen({ port: 3000 }, (err, address) => {
|
|
|
55
55
|
})
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
`init()` doesn't start Mastra's background workers. To run [scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows), agent schedules, or event listeners, call `await mastra.startWorkers()` after the server starts listening. See [Start background workers](https://mastra.ai/docs/server/server-adapters).
|
|
59
|
+
|
|
58
60
|
## Constructor parameters
|
|
59
61
|
|
|
60
62
|
**app** (`FastifyInstance`): Fastify app instance
|