@mastra/mcp-docs-server 1.3.6-alpha.1 → 1.3.6-alpha.10
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 +5 -3
- package/.docs/docs/agents/processors.md +13 -8
- package/.docs/docs/agents/tools.md +24 -0
- package/.docs/docs/browser.md +0 -2
- package/.docs/docs/guides/authentication-identity.md +1 -1
- package/.docs/docs/harness/agent-controller.md +29 -0
- package/.docs/docs/memory/memory-processors.md +2 -5
- package/.docs/docs/memory/message-history.md +15 -8
- package/.docs/docs/memory/observational-memory.md +33 -4
- package/.docs/docs/memory/semantic-recall.md +2 -2
- package/.docs/docs/memory/working-memory.md +16 -0
- package/.docs/docs/observability/tracing/overview.md +1 -1
- package/.docs/docs/subagents.md +10 -8
- package/.docs/docs/workflows/control-flow.md +1 -1
- package/.docs/docs/workflows/time-travel.md +5 -3
- package/.docs/integrations/agentic-ui/ai-sdk-ui.md +60 -0
- package/.docs/integrations/deploy/temporal.md +23 -0
- package/.docs/integrations/sandboxes/docker.md +61 -0
- package/.docs/integrations/sandboxes/e2b.md +37 -0
- package/.docs/models/embeddings.md +1 -1
- package/.docs/models/gateways/merge-gateway.md +2 -1
- package/.docs/models/gateways/netlify.md +4 -5
- package/.docs/models/gateways/openrouter.md +4 -3
- package/.docs/models/gateways/vercel.md +4 -5
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/alibaba.md +1 -1
- package/.docs/models/providers/anthropic.md +4 -3
- package/.docs/models/providers/berget.md +1 -1
- package/.docs/models/providers/coralbricks.md +1 -2
- package/.docs/models/providers/cortecs.md +5 -2
- package/.docs/models/providers/crossmodel.md +2 -1
- package/.docs/models/providers/deepinfra.md +0 -2
- package/.docs/models/providers/edenai.md +11 -8
- package/.docs/models/providers/hyper.md +4 -6
- package/.docs/models/providers/kilo.md +19 -17
- package/.docs/models/providers/llmgateway-providers.md +4 -2
- package/.docs/models/providers/llmgateway.md +2 -1
- package/.docs/models/providers/mistral.md +10 -17
- package/.docs/models/providers/nano-gpt.md +32 -30
- package/.docs/models/providers/neuralwatt.md +3 -1
- package/.docs/models/providers/ollama-cloud.md +2 -1
- package/.docs/models/providers/opencode-go.md +7 -5
- package/.docs/models/providers/opencode.md +3 -2
- package/.docs/models/providers/ovhcloud.md +1 -2
- package/.docs/models/providers/requesty.md +7 -4
- package/.docs/models/providers/vivgrid.md +2 -1
- package/.docs/reference/agent-controller/agent-controller-class.md +15 -1
- package/.docs/reference/agent-controller/session.md +17 -6
- package/.docs/reference/agents/generate.md +1 -1
- package/.docs/reference/agents/inngest-agent.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-v4-messages.md +3 -3
- package/.docs/reference/classifier/classifier.md +35 -35
- package/.docs/reference/client-js/memory.md +13 -1
- package/.docs/reference/coding-agent/create-coding-agent.md +2 -2
- package/.docs/reference/configuration.md +2 -2
- package/.docs/reference/connect/providers.md +118 -112
- package/.docs/reference/core/getClassifier.md +1 -1
- package/.docs/reference/datasets/updateItem.md +10 -0
- package/.docs/reference/deployer/vercel.md +1 -1
- package/.docs/reference/deployer.md +7 -14
- package/.docs/reference/editor/blob-store-provider.md +2 -1
- package/.docs/reference/editor/browser-provider.md +3 -2
- package/.docs/reference/editor/filesystem-provider.md +2 -1
- package/.docs/reference/editor/processor-provider.md +2 -2
- package/.docs/reference/editor/sandbox-provider.md +2 -1
- package/.docs/reference/editor/storage-workspace-ref.md +27 -2
- package/.docs/reference/evals/answer-relevancy.md +4 -2
- package/.docs/reference/evals/answer-similarity.md +1 -1
- package/.docs/reference/evals/bias.md +3 -1
- package/.docs/reference/evals/content-similarity.md +1 -1
- package/.docs/reference/evals/context-recall.md +1 -1
- package/.docs/reference/evals/context-relevance.md +6 -6
- package/.docs/reference/evals/create-classifier-scorer.md +5 -5
- package/.docs/reference/evals/hallucination.md +7 -8
- package/.docs/reference/evals/keyword-coverage.md +4 -4
- package/.docs/reference/evals/noise-sensitivity.md +6 -6
- package/.docs/reference/evals/prompt-alignment.md +1 -1
- package/.docs/reference/evals/run-evals.md +1 -1
- package/.docs/reference/evals/scorer-utils.md +8 -8
- package/.docs/reference/evals/tone-consistency.md +23 -24
- package/.docs/reference/evals/tool-call-accuracy.md +19 -15
- package/.docs/reference/evals/toxicity.md +3 -1
- package/.docs/reference/index.md +2 -0
- package/.docs/reference/logging/pino-logger.md +4 -4
- package/.docs/reference/memory/deleteMessages.md +1 -1
- package/.docs/reference/memory/memory-class.md +2 -2
- package/.docs/reference/memory/observational-memory.md +8 -4
- package/.docs/reference/memory/summarizeConversation.md +1 -1
- package/.docs/reference/migrations/ai-sdk-v4-to-v5.md +2 -2
- package/.docs/reference/migrations/upgrade-to-v1/mcp.md +2 -0
- package/.docs/reference/migrations/upgrade-to-v1/memory.md +1 -1
- package/.docs/reference/migrations/upgrade-to-v1/tools.md +1 -1
- package/.docs/reference/observability/tracing/configuration.md +10 -1
- package/.docs/reference/observability/tracing/instances.md +1 -1
- package/.docs/reference/observability/tracing/interfaces.md +1 -1
- package/.docs/reference/processors/batch-parts-processor.md +1 -1
- package/.docs/reference/processors/classifier-processor.md +6 -6
- package/.docs/reference/processors/file-upload-processor.md +236 -0
- package/.docs/reference/processors/message-history-processor.md +3 -2
- package/.docs/reference/processors/model-selection-processor.md +11 -11
- package/.docs/reference/processors/processor-interface.md +2 -0
- package/.docs/reference/processors/response-cache.md +1 -1
- package/.docs/reference/processors/semantic-recall-processor.md +2 -3
- package/.docs/reference/processors/stream-error-retry-processor.md +1 -1
- package/.docs/reference/processors/unicode-normalizer.md +1 -1
- package/.docs/reference/processors/unsupported-file-handler.md +69 -0
- package/.docs/reference/processors/working-memory-processor.md +3 -2
- package/.docs/reference/project-structure.md +11 -13
- package/.docs/reference/pubsub/unix-socket-pubsub.md +6 -2
- package/.docs/reference/rag/chunk.md +2 -2
- package/.docs/reference/rag/chunking-and-embedding.md +1 -1
- package/.docs/reference/rag/database-config.md +14 -2
- package/.docs/reference/rag/document.md +7 -2
- package/.docs/reference/rag/extract-params.md +5 -5
- package/.docs/reference/rag/graph-rag-guide.md +1 -1
- package/.docs/reference/rag/metadata-filters.md +1 -1
- package/.docs/reference/rag/rerank.md +5 -4
- package/.docs/reference/rag/rerankWithScorer.md +2 -2
- package/.docs/reference/rag/retrieval.md +7 -5
- package/.docs/reference/rag/vector-databases.md +1 -1
- package/.docs/reference/server/mastra-server.md +2 -2
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/tools/isolated-vm-transport.md +0 -2
- package/.docs/reference/tools/quickjs-transport.md +0 -2
- package/.docs/reference/workflows/run-methods/restart.md +6 -0
- package/.docs/reference/workflows/step.md +1 -1
- package/.docs/reference/workspace/platform-sandbox.md +36 -2
- package/package.json +6 -6
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# OVHcloud AI Endpoints
|
|
6
6
|
|
|
7
|
-
Access
|
|
7
|
+
Access 13 OVHcloud AI Endpoints models through Mastra's model router. Authentication is handled automatically using the `OVHCLOUD_API_KEY` environment variable.
|
|
8
8
|
|
|
9
9
|
Learn more in the [OVHcloud AI Endpoints documentation](https://www.ovhcloud.com/en/public-cloud/ai-endpoints/catalog//).
|
|
10
10
|
|
|
@@ -45,7 +45,6 @@ for await (const chunk of stream) {
|
|
|
45
45
|
| `ovhcloud/mistral-nemo-instruct-2407` | 66K | | | | | | $0.14 | $0.14 |
|
|
46
46
|
| `ovhcloud/mistral-small-3.2-24b-instruct-2506` | 131K | | | | | | $0.10 | $0.31 |
|
|
47
47
|
| `ovhcloud/qwen2.5-vl-72b-instruct` | 33K | | | | | | $1 | $1 |
|
|
48
|
-
| `ovhcloud/qwen3-coder-30b-a3b-instruct` | 262K | | | | | | $0.07 | $0.26 |
|
|
49
48
|
| `ovhcloud/qwen3.5-397b-a17b` | 262K | | | | | | $0.71 | $4 |
|
|
50
49
|
| `ovhcloud/qwen3.5-9b` | 262K | | | | | | $0.12 | $0.18 |
|
|
51
50
|
| `ovhcloud/qwen3.6-27b` | 262K | | | | | | $0.47 | $3 |
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Requesty
|
|
6
6
|
|
|
7
|
-
Access
|
|
7
|
+
Access 171 Requesty models through Mastra's model router. Authentication is handled automatically using the `REQUESTY_API_KEY` environment variable.
|
|
8
8
|
|
|
9
9
|
Learn more in the [Requesty documentation](https://requesty.ai/solution/llm-routing/models).
|
|
10
10
|
|
|
@@ -38,12 +38,14 @@ for await (const chunk of stream) {
|
|
|
38
38
|
|
|
39
39
|
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
40
40
|
| ------------------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
41
|
-
| `requesty/claude-fable-5` | 1.0M | | | | | | $
|
|
41
|
+
| `requesty/claude-fable-5` | 1.0M | | | | | | $11 | $55 |
|
|
42
42
|
| `requesty/claude-fable-5.1` | 1.0M | | | | | | $10 | $50 |
|
|
43
43
|
| `requesty/claude-fable-5.1@eu` | 1.0M | | | | | | $11 | $55 |
|
|
44
44
|
| `requesty/claude-fable-5@eu` | 1.0M | | | | | | $11 | $55 |
|
|
45
45
|
| `requesty/claude-haiku-4-5` | 200K | | | | | | $1 | $5 |
|
|
46
46
|
| `requesty/claude-haiku-4-5@eu` | 200K | | | | | | $1 | $6 |
|
|
47
|
+
| `requesty/claude-haiku-5-5` | 1.0M | | | | | | $0.10 | $0.50 |
|
|
48
|
+
| `requesty/claude-haiku-5-5@eu` | 1.0M | | | | | | $0.11 | $0.55 |
|
|
47
49
|
| `requesty/claude-opus-4-1` | 200K | | | | | | $15 | $75 |
|
|
48
50
|
| `requesty/claude-opus-4-5` | 200K | | | | | | $5 | $25 |
|
|
49
51
|
| `requesty/claude-opus-4-5@eu` | 200K | | | | | | $6 | $28 |
|
|
@@ -146,6 +148,7 @@ for await (const chunk of stream) {
|
|
|
146
148
|
| `requesty/inkling` | 66K | | | | | | $2 | $5 |
|
|
147
149
|
| `requesty/inkling-256k` | 262K | | | | | | $2 | $5 |
|
|
148
150
|
| `requesty/kat-coder-pro` | 256K | | | | | | $0.30 | $1 |
|
|
151
|
+
| `requesty/kimi-k2.5@eu` | 128K | | | | | | $0.72 | $4 |
|
|
149
152
|
| `requesty/kimi-k2.6` | 262K | | | | | | $0.95 | $4 |
|
|
150
153
|
| `requesty/kimi-k2.6@eu` | 256K | | | | | | $0.95 | $4 |
|
|
151
154
|
| `requesty/kimi-k2.7-code` | 262K | | | | | | $0.95 | $4 |
|
|
@@ -167,8 +170,8 @@ for await (const chunk of stream) {
|
|
|
167
170
|
| `requesty/minimax-m2.7-highspeed` | 200K | | | | | | $0.60 | $2 |
|
|
168
171
|
| `requesty/minimax-m3` | 1.0M | | | | | | $0.30 | $1 |
|
|
169
172
|
| `requesty/minimax-m3@eu` | 1.0M | | | | | | $0.40 | $2 |
|
|
170
|
-
| `requesty/mistral-large-4` |
|
|
171
|
-
| `requesty/mistral-large-4@eu` |
|
|
173
|
+
| `requesty/mistral-large-4` | 524K | | | | | | $0.68 | $2 |
|
|
174
|
+
| `requesty/mistral-large-4@eu` | 524K | | | | | | $0.68 | $2 |
|
|
172
175
|
| `requesty/mistral-medium-3-5` | 262K | | | | | | $2 | $8 |
|
|
173
176
|
| `requesty/mistral-medium-3-5@eu` | 262K | | | | | | $2 | $8 |
|
|
174
177
|
| `requesty/mistral-medium-latest` | 131K | | | | | | $0.44 | $2 |
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Vivgrid
|
|
6
6
|
|
|
7
|
-
Access
|
|
7
|
+
Access 37 Vivgrid models through Mastra's model router. Authentication is handled automatically using the `VIVGRID_API_KEY` environment variable.
|
|
8
8
|
|
|
9
9
|
Learn more in the [Vivgrid documentation](https://docs.vivgrid.com/models).
|
|
10
10
|
|
|
@@ -40,6 +40,7 @@ for await (const chunk of stream) {
|
|
|
40
40
|
| --------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
41
41
|
| `vivgrid/claude-fable-5` | 1.0M | | | | | | $10 | $50 |
|
|
42
42
|
| `vivgrid/claude-fable-5-1` | 1.0M | | | | | | $10 | $50 |
|
|
43
|
+
| `vivgrid/claude-haiku-5-5` | 1.0M | | | | | | $0.10 | $0.50 |
|
|
43
44
|
| `vivgrid/claude-opus-5` | 1.0M | | | | | | $5 | $25 |
|
|
44
45
|
| `vivgrid/claude-opus-5-5` | 1.0M | | | | | | $4 | $20 |
|
|
45
46
|
| `vivgrid/claude-sonnet-5` | 1.0M | | | | | | $2 | $10 |
|
|
@@ -136,7 +136,21 @@ A message lifecycle starts with the initial message in `message_start`. Compact
|
|
|
136
136
|
|
|
137
137
|
**gateways** (`MastraModelGatewayInterface[]`): Custom model gateways merged with the built-in gateways.
|
|
138
138
|
|
|
139
|
-
**omConfig** (`AgentControllerOMConfig`): Default observational memory
|
|
139
|
+
**omConfig** (`AgentControllerOMConfig`): Default observational memory model selections, automatic model resolver, and thresholds.
|
|
140
|
+
|
|
141
|
+
**omConfig.defaultObserverModelId** (`string`): Concrete observer fallback used when automatic resolution returns no model or throws.
|
|
142
|
+
|
|
143
|
+
**omConfig.observerModel** (`'auto' | string`): Default observer model. Use 'auto' to follow the active main model.
|
|
144
|
+
|
|
145
|
+
**omConfig.defaultReflectorModelId** (`string`): Concrete reflector fallback used when automatic resolution returns no model or throws.
|
|
146
|
+
|
|
147
|
+
**omConfig.reflectorModel** (`'auto' | string`): Default reflector model. Use 'auto' to follow the active main model.
|
|
148
|
+
|
|
149
|
+
**omConfig.resolveAutoModelId** (`(args: ResolveAutoOMModelArgs) => string | undefined`): Synchronously resolves an automatic role selection to a concrete model ID from the role, current main model, and read-only session state.
|
|
150
|
+
|
|
151
|
+
**omConfig.defaultObservationThreshold** (`number`): Default observation threshold in tokens.
|
|
152
|
+
|
|
153
|
+
**omConfig.defaultReflectionThreshold** (`number`): Default reflection threshold in tokens.
|
|
140
154
|
|
|
141
155
|
**disableBuiltinTools** (`BuiltinToolId[]`): Built-in controller tools to omit from runs.
|
|
142
156
|
|
|
@@ -519,11 +519,24 @@ The client SDK exposes the same operation as `session.switchModel(modelId, { thi
|
|
|
519
519
|
|
|
520
520
|
## Observational Memory
|
|
521
521
|
|
|
522
|
-
The observational-memory model selection, grouped by role under `session.om.observer` and `session.om.reflector`. Both roles expose the same methods.
|
|
522
|
+
The observational-memory model selection, grouped by role under `session.om.observer` and `session.om.reflector`. Both roles expose the same methods. Selection intent and the effective concrete model ID are separate values.
|
|
523
|
+
|
|
524
|
+
### `session.om.observer.model()` / `session.om.reflector.model()`
|
|
525
|
+
|
|
526
|
+
Return the role's configured model.
|
|
527
|
+
|
|
528
|
+
```typescript
|
|
529
|
+
const observerModel = session.om.observer.model()
|
|
530
|
+
const reflectorModel = session.om.reflector.model()
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
Returns: `'auto' | string | undefined`
|
|
534
|
+
|
|
535
|
+
`'auto'` follows the active main model. Any other string is an explicit model ID.
|
|
523
536
|
|
|
524
537
|
### `session.om.observer.modelId()` / `session.om.reflector.modelId()`
|
|
525
538
|
|
|
526
|
-
Return the role's model ID,
|
|
539
|
+
Return the role's effective concrete model ID. For an automatic selection, the controller calls `omConfig.resolveAutoModelId` with the role, current main model ID, and read-only session state. If that resolver returns no model or throws, the role uses its concrete `omConfig` fallback.
|
|
527
540
|
|
|
528
541
|
```typescript
|
|
529
542
|
const observer = session.om.observer.modelId()
|
|
@@ -541,12 +554,10 @@ const reflectionThreshold = session.om.reflector.threshold()
|
|
|
541
554
|
|
|
542
555
|
### `session.om.observer.switchModel({ modelId })` / `session.om.reflector.switchModel({ modelId })`
|
|
543
556
|
|
|
544
|
-
Switch
|
|
557
|
+
Switch one role between automatic and explicit selection. Pass `'auto'` to follow the active main model, or pass a concrete model ID to pin the role. Automatic selection clears the role's stale concrete model ID. The other role is unchanged. The emitted `om_model_changed` event continues to contain the effective concrete `modelId`.
|
|
545
558
|
|
|
546
559
|
```typescript
|
|
547
|
-
await session.om.observer.switchModel({
|
|
548
|
-
modelId: 'anthropic/claude-haiku-4-5',
|
|
549
|
-
})
|
|
560
|
+
await session.om.observer.switchModel({ modelId: 'auto' })
|
|
550
561
|
await session.om.reflector.switchModel({
|
|
551
562
|
modelId: 'anthropic/claude-haiku-4-5',
|
|
552
563
|
})
|
|
@@ -64,7 +64,7 @@ const result = await agent.generate('message for agent')
|
|
|
64
64
|
|
|
65
65
|
**options.delegation.onDelegationComplete** (`(context: DelegationCompleteContext) => { feedback?: string } | void | Promise<{ feedback?: string } | void>`): Called after a subagent delegation completes. The context includes a bail() method to stop further execution, and you can return { feedback } to guide the supervisor's next action. Feedback is saved to supervisor memory as an assistant message.
|
|
66
66
|
|
|
67
|
-
**options.delegation.messageFilter** (`(context: MessageFilterContext) =>
|
|
67
|
+
**options.delegation.messageFilter** (`(context: MessageFilterContext) => ModelMessage[] | Promise<ModelMessage[]>`): Callback function called before delegating to a subagent. Use this to filter the messages that are passed to the subagent.
|
|
68
68
|
|
|
69
69
|
**options.scorers** (`MastraScorers | Record<string, { scorer: MastraScorer['name']; sampling?: ScoringSamplingConfig }>`): Evaluation scorers to run on the execution results.
|
|
70
70
|
|
|
@@ -263,7 +263,7 @@ Returns: `boolean`
|
|
|
263
263
|
|
|
264
264
|
**maxSteps** (`number`): Maximum number of steps to run.
|
|
265
265
|
|
|
266
|
-
**toolsets** (`object`): Additional tool sets available for this run.
|
|
266
|
+
**toolsets** (`object`): Additional tool sets available for this run. Toolset tools contain server-side code that cannot be serialized, so they only work when the Inngest worker runs in the same process as the caller. A worker in a separate process throws an error naming the missing tools. Register these tools on the agent instead. The worker matches toolset tools by name, so if a toolset tool shares a name with an agent tool, the agent tool runs.
|
|
267
267
|
|
|
268
268
|
**clientTools** (`object`): Client-side tools available during execution.
|
|
269
269
|
|
|
@@ -9,7 +9,7 @@ Converts messages from input formats to AI SDK V4 UI message format. This functi
|
|
|
9
9
|
## Usage example
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
import { toAISdkV4Messages } from '@mastra/ai-sdk'
|
|
12
|
+
import { toAISdkV4Messages } from '@mastra/ai-sdk/ui'
|
|
13
13
|
import { useChat } from 'ai/react' // AI SDK V4
|
|
14
14
|
|
|
15
15
|
// Stored messages from your database, memory or API
|
|
@@ -64,7 +64,7 @@ Returns an array of AI SDK V4 `UIMessage` objects with the following structure:
|
|
|
64
64
|
### Converting text messages
|
|
65
65
|
|
|
66
66
|
```typescript
|
|
67
|
-
import { toAISdkV4Messages } from '@mastra/ai-sdk'
|
|
67
|
+
import { toAISdkV4Messages } from '@mastra/ai-sdk/ui'
|
|
68
68
|
|
|
69
69
|
const messages = toAISdkV4Messages(['Hello', 'How can I help you today?'])
|
|
70
70
|
// Returns array of UIMessage objects with user role and content string
|
|
@@ -74,7 +74,7 @@ const messages = toAISdkV4Messages(['Hello', 'How can I help you today?'])
|
|
|
74
74
|
|
|
75
75
|
```typescript
|
|
76
76
|
import { MastraClient } from '@mastra/client-js'
|
|
77
|
-
import { toAISdkV4Messages } from '@mastra/ai-sdk'
|
|
77
|
+
import { toAISdkV4Messages } from '@mastra/ai-sdk/ui'
|
|
78
78
|
|
|
79
79
|
const client = new MastraClient()
|
|
80
80
|
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
# Classifier
|
|
6
6
|
|
|
7
|
-
`Classifier` asks
|
|
7
|
+
`Classifier` asks a decision model one or more fixed-domain questions about shared state. Use it when your application needs a typed choice, numeric score, or boolean probability without parsing generated text.
|
|
8
8
|
|
|
9
9
|
A classifier only returns evaluation results. Your application decides how to use them, for example by selecting a route or comparing a probability with a safety threshold.
|
|
10
10
|
|
|
11
|
-
`Classifier` requires
|
|
11
|
+
`Classifier` requires a decision model (`DecisionModelV4`, or the deprecated `EvaluationModelV4`, optionally wrapped in `MastraDecisionModel`). It doesn't accept a `'provider/model'` string, a bare model ID, or a language model.
|
|
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). Make sure to set the `TYPESAFE_AI_API_KEY` environment variable. To use another provider, see [
|
|
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 [Decision models](#decision-models).
|
|
16
16
|
|
|
17
17
|
Install the provider package:
|
|
18
18
|
|
|
@@ -48,7 +48,7 @@ import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
|
48
48
|
|
|
49
49
|
const classifier = new Classifier({
|
|
50
50
|
id: 'request-classifier',
|
|
51
|
-
model: typeSafeAi.
|
|
51
|
+
model: typeSafeAi.decisionModel('jev-latest'),
|
|
52
52
|
questions: {
|
|
53
53
|
route: {
|
|
54
54
|
type: 'choice',
|
|
@@ -65,7 +65,7 @@ const classifier = new Classifier({
|
|
|
65
65
|
},
|
|
66
66
|
})
|
|
67
67
|
|
|
68
|
-
const result = await classifier.
|
|
68
|
+
const result = await classifier.decide({
|
|
69
69
|
state: {
|
|
70
70
|
subject: 'Duplicate charge',
|
|
71
71
|
message: 'I was charged twice for the same subscription.',
|
|
@@ -76,11 +76,11 @@ result.answers.route.choice // 'billing' | 'support'
|
|
|
76
76
|
result.answers.urgent.probability // P(true), from 0 to 1
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
The
|
|
79
|
+
The decision model receives every question with the same `state`. When a question omits `instructions`, its question name is used instead.
|
|
80
80
|
|
|
81
|
-
##
|
|
81
|
+
## Decision models
|
|
82
82
|
|
|
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
|
|
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 a `decisionModel()` factory (previously `evaluationModel()`, still available as a deprecated alias). Mastra calls `doDecide()` and falls back to `doEvaluate()` for older providers. See [provider models](https://ai-sdk.dev/docs/ai-sdk-core/decisions#provider-models) for the full list, supported model IDs, and how each provider answers questions.
|
|
84
84
|
|
|
85
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
86
|
|
|
@@ -89,7 +89,7 @@ Pass a key explicitly by calling the factory instead:
|
|
|
89
89
|
```typescript
|
|
90
90
|
import { createTypeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
91
91
|
|
|
92
|
-
const model = createTypeSafeAi({ apiKey: process.env.TYPESAFE_AI_API_KEY }).
|
|
92
|
+
const model = createTypeSafeAi({ apiKey: process.env.TYPESAFE_AI_API_KEY }).decisionModel(
|
|
93
93
|
'jev-latest',
|
|
94
94
|
)
|
|
95
95
|
```
|
|
@@ -102,11 +102,11 @@ new Classifier(options)
|
|
|
102
102
|
|
|
103
103
|
**id** (`string`): A non-empty identifier used in tracing and error context.
|
|
104
104
|
|
|
105
|
-
**model** (`EvaluationModelV4 |
|
|
105
|
+
**model** (`DecisionModelV4 | EvaluationModelV4 | MastraDecisionModel`): An AI SDK decision model or a Mastra decision model wrapper. The model declares which question types it supports.
|
|
106
106
|
|
|
107
|
-
**questions** (`ClassifierQuestions`): A non-empty record of named questions. Omit this field to supply the questions to each
|
|
107
|
+
**questions** (`ClassifierQuestions`): A non-empty record of named questions. Omit this field to supply the questions to each decide() call instead.
|
|
108
108
|
|
|
109
|
-
Constructor questions and per-call questions are mutually exclusive. If the constructor includes `questions`, `
|
|
109
|
+
Constructor questions and per-call questions are mutually exclusive. If the constructor includes `questions`, `decide()` rejects a `questions` option at compile time. If the constructor omits them, every `decide()` call must provide them. A processor, workflow step, or scorer classifies through a configured classifier, which requires constructor questions.
|
|
110
110
|
|
|
111
111
|
## Question types
|
|
112
112
|
|
|
@@ -210,9 +210,11 @@ These rules keep a question answerable from the state:
|
|
|
210
210
|
|
|
211
211
|
To check a question, change one field of the state and confirm one answer moves.
|
|
212
212
|
|
|
213
|
-
## `
|
|
213
|
+
## `decide(options)`
|
|
214
214
|
|
|
215
|
-
|
|
215
|
+
Answers all questions against the supplied state.
|
|
216
|
+
|
|
217
|
+
`evaluate(options)` is a deprecated alias for `decide(options)` and will be removed in a future release.
|
|
216
218
|
|
|
217
219
|
**state** (`ClassifierState`): The JSON-compatible state evaluated by every question.
|
|
218
220
|
|
|
@@ -220,7 +222,7 @@ Evaluates all questions against the supplied state.
|
|
|
220
222
|
|
|
221
223
|
**abortSignal** (`AbortSignal`): Cancels the active provider request and any wait between retry attempts.
|
|
222
224
|
|
|
223
|
-
**providerOptions** (`SharedV4ProviderOptions`): Provider-specific options forwarded unchanged to the
|
|
225
|
+
**providerOptions** (`SharedV4ProviderOptions`): Provider-specific options forwarded unchanged to the decision model.
|
|
224
226
|
|
|
225
227
|
**maxRetries** (`number`): The number of retries allowed after retryable provider API errors. Must be a non-negative integer. (Default: `2`)
|
|
226
228
|
|
|
@@ -234,10 +236,10 @@ import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
|
234
236
|
|
|
235
237
|
const classifier = new Classifier({
|
|
236
238
|
id: 'dynamic-classifier',
|
|
237
|
-
model: typeSafeAi.
|
|
239
|
+
model: typeSafeAi.decisionModel('jev-latest'),
|
|
238
240
|
})
|
|
239
241
|
|
|
240
|
-
const result = await classifier.
|
|
242
|
+
const result = await classifier.decide({
|
|
241
243
|
state: { response: 'Your refund has been processed.' },
|
|
242
244
|
questions: {
|
|
243
245
|
tone: {
|
|
@@ -255,17 +257,17 @@ result.answers.tone.choice // 'empathetic' | 'neutral'
|
|
|
255
257
|
|
|
256
258
|
## Return value
|
|
257
259
|
|
|
258
|
-
`
|
|
260
|
+
`decide()` returns `Promise<ClassifierResult<QUESTIONS>>`.
|
|
259
261
|
|
|
260
262
|
**answers** (`ClassifierAnswers<QUESTIONS>`): One typed answer for each configured question.
|
|
261
263
|
|
|
262
264
|
**usage** (`ClassifierUsage`): Token usage reported by the provider. totalTokens is the sum of inputTokens and outputTokens, with missing values counted as zero.
|
|
263
265
|
|
|
264
|
-
**warnings** (`SharedV4Warning[]`): Warnings returned by the
|
|
266
|
+
**warnings** (`SharedV4Warning[]`): Warnings returned by the decision model.
|
|
265
267
|
|
|
266
268
|
**rounding** (`{ probabilityDecimals?: number; scoreDecimals?: number }`): The precision the provider used for probabilities and scores.
|
|
267
269
|
|
|
268
|
-
**providerMetadata** (`SharedV4ProviderMetadata`): Provider-specific metadata returned by the
|
|
270
|
+
**providerMetadata** (`SharedV4ProviderMetadata`): Provider-specific metadata returned by the decision model.
|
|
269
271
|
|
|
270
272
|
**response** (`ClassifierResult["response"]`): Provider response metadata. Mastra supplies the current time and configured model ID when the provider omits them.
|
|
271
273
|
|
|
@@ -295,33 +297,29 @@ Input validation includes:
|
|
|
295
297
|
- `state`, instructions, and criteria must be JSON-compatible.
|
|
296
298
|
- The question record and choice criteria must not be empty.
|
|
297
299
|
- Score criteria must contain at least two defined levels.
|
|
298
|
-
- Every question type must be supported by the
|
|
300
|
+
- Every question type must be supported by the decision model.
|
|
299
301
|
- `maxRetries` must be a non-negative integer.
|
|
300
302
|
|
|
301
303
|
Provider responses must contain exactly one matching answer for each question. The classifier also rejects invalid choices, out-of-range scores or probabilities, incomplete probability distributions, non-finite token counts, malformed warnings, and invalid response timestamps.
|
|
302
304
|
|
|
303
|
-
Only retryable AI SDK `APICallError` failures are retried. Other errors reject immediately. When all retries fail, `
|
|
305
|
+
Only retryable AI SDK `APICallError` failures are retried. Other errors reject immediately. When all retries fail, `decide()` rethrows the last provider error. Aborting the supplied signal rejects with the signal's abort reason, including when cancellation occurs during retry backoff.
|
|
304
306
|
|
|
305
307
|
## Observability
|
|
306
308
|
|
|
307
|
-
When an active Mastra span exists, `
|
|
309
|
+
When an active Mastra span exists, `decide()` creates a `CLASSIFIER_EVALUATION` child span. It records the classifier and model identifiers, provider, question count and types, attempts, duration, and token usage.
|
|
308
310
|
|
|
309
311
|
The span doesn't include the evaluated state, question instructions, criteria, answers, probabilities, provider response body, or generated text.
|
|
310
312
|
|
|
311
313
|
## Customize provider responses
|
|
312
314
|
|
|
313
|
-
`Classifier` automatically wraps a raw AI SDK
|
|
315
|
+
`Classifier` automatically wraps a raw AI SDK decision model in `MastraDecisionModel`. Pass your own wrapper when provider output needs normalization before validation.
|
|
314
316
|
|
|
315
317
|
```typescript
|
|
316
|
-
import {
|
|
317
|
-
Classifier,
|
|
318
|
-
MastraEvaluationModel,
|
|
319
|
-
type EvaluationModelResult,
|
|
320
|
-
} from '@mastra/core/classifier'
|
|
318
|
+
import { Classifier, MastraDecisionModel, type DecisionModelResult } from '@mastra/core/classifier'
|
|
321
319
|
import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
322
320
|
|
|
323
|
-
class
|
|
324
|
-
protected override transformResult(result:
|
|
321
|
+
class NormalizedDecisionModel extends MastraDecisionModel {
|
|
322
|
+
protected override transformResult(result: DecisionModelResult): DecisionModelResult {
|
|
325
323
|
return {
|
|
326
324
|
...result,
|
|
327
325
|
answers: normalizeAnswers(result.answers),
|
|
@@ -331,14 +329,16 @@ class NormalizedEvaluationModel extends MastraEvaluationModel {
|
|
|
331
329
|
|
|
332
330
|
const classifier = new Classifier({
|
|
333
331
|
id: 'normalized-classifier',
|
|
334
|
-
model: new
|
|
335
|
-
typeSafeAi.
|
|
332
|
+
model: new NormalizedDecisionModel(
|
|
333
|
+
typeSafeAi.decisionModel('jev-latest'),
|
|
336
334
|
),
|
|
337
335
|
})
|
|
338
336
|
```
|
|
339
337
|
|
|
340
338
|
`transformResult()` runs after the provider call and before `Classifier` validates the response.
|
|
341
339
|
|
|
340
|
+
`MastraEvaluationModel` and `EvaluationModelResult` are deprecated aliases for `MastraDecisionModel` and `DecisionModelResult` and will be removed in a future release.
|
|
341
|
+
|
|
342
342
|
## Registering classifiers
|
|
343
343
|
|
|
344
344
|
Register classifiers on the `Mastra` instance to share them across your application and retrieve them by key or ID. When a registered classifier is evaluated without an active trace, it starts a root `CLASSIFIER_EVALUATION` span through the `Mastra` instance's configured observability provider.
|
|
@@ -350,7 +350,7 @@ import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
|
350
350
|
|
|
351
351
|
export const safety = new Classifier({
|
|
352
352
|
id: 'safety',
|
|
353
|
-
model: typeSafeAi.
|
|
353
|
+
model: typeSafeAi.decisionModel('jev-latest'),
|
|
354
354
|
questions: {
|
|
355
355
|
unsafe: { type: 'boolean' },
|
|
356
356
|
},
|
|
@@ -384,7 +384,7 @@ const workflow = createWorkflow({
|
|
|
384
384
|
|
|
385
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
386
|
|
|
387
|
-
The workflow adapter doesn't include warnings, raw provider responses, headers, or provider metadata in step output. Use direct `
|
|
387
|
+
The workflow adapter doesn't include warnings, raw provider responses, headers, or provider metadata in step output. Use direct `decide()` calls or classifier observability when you need that provider-level detail.
|
|
388
388
|
|
|
389
389
|
## Related
|
|
390
390
|
|
|
@@ -204,7 +204,7 @@ const workingMemory = await mastraClient.getWorkingMemory({
|
|
|
204
204
|
|
|
205
205
|
The response includes:
|
|
206
206
|
|
|
207
|
-
- `workingMemory`: The current working memory content (string or null)
|
|
207
|
+
- `workingMemory`: The current working memory content (a string or `null`). When using a JSON or schema-based working memory template, the content is a JSON-encoded string
|
|
208
208
|
- `source`: Whether the memory is from `"thread"` or `"resource"` scope
|
|
209
209
|
- `workingMemoryTemplate`: The template used for working memory (if configured)
|
|
210
210
|
- `threadExists`: Whether the thread exists
|
|
@@ -230,6 +230,18 @@ await mastraClient.updateWorkingMemory({
|
|
|
230
230
|
|
|
231
231
|
For resource-scoped working memory, you must provide the `resourceId` parameter. It allows the memory to persist across all conversation threads for that user.
|
|
232
232
|
|
|
233
|
+
By default the call replaces the whole record. For schema-based, resource-scoped working memory, pass `mode: 'merge'` with a JSON object string to deep-merge only the provided fields atomically. The server returns `400` if the storage adapter doesn't support atomic merges (currently only `@mastra/pg` does).
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
await mastraClient.updateWorkingMemory({
|
|
237
|
+
agentId: 'agent-1',
|
|
238
|
+
threadId: 'thread-1',
|
|
239
|
+
resourceId: 'user-123',
|
|
240
|
+
workingMemory: JSON.stringify({ city: 'Berlin' }),
|
|
241
|
+
mode: 'merge',
|
|
242
|
+
})
|
|
243
|
+
```
|
|
244
|
+
|
|
233
245
|
### Get Memory Status
|
|
234
246
|
|
|
235
247
|
Check the status of the memory system:
|
|
@@ -51,7 +51,7 @@ For the behavioral prompt Mastra Code uses, covering repository exploration, edi
|
|
|
51
51
|
|
|
52
52
|
**signals** (`SignalProvider[]`): Signal providers for the agent. A TaskSignalProvider is added only when memory is configured, and it is merged into the providers you pass rather than replacing them. Without memory, the agent gets exactly the providers you pass, or none.
|
|
53
53
|
|
|
54
|
-
**errorProcessors** (`Processor[]`): Error processors for the agent. When omitted, defaults to unknown stream-error retries with specialized ECONNRESET and bad-request policies, plus PrefillErrorHandler, ProviderHistoryCompat, and CyberRefusalHandler.
|
|
54
|
+
**errorProcessors** (`Processor[]`): Error processors for the agent. When omitted, defaults to unknown stream-error retries with specialized ECONNRESET and bad-request policies, plus PrefillErrorHandler, ProviderHistoryCompat, UnsupportedFileHandler, and CyberRefusalHandler.
|
|
55
55
|
|
|
56
56
|
**outputProcessors** (`Processor[]`): Output processors for the agent. When omitted, defaults to CyberRefusalHandler.
|
|
57
57
|
|
|
@@ -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` sets the base list: any of the
|
|
199
|
+
Specific network-reset and bad-request policies take precedence over the unknown-error policy. Passing `errorProcessors` sets the base list: any of the four shared defaults your list doesn't name by `id` is still added, at the position its `id` gives it. An empty list gets all four. 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
|
|
|
@@ -366,7 +366,7 @@ export const mastra = new Mastra({
|
|
|
366
366
|
|
|
367
367
|
**Type:** `Record<string, Classifier>`
|
|
368
368
|
|
|
369
|
-
Classifiers ask
|
|
369
|
+
Classifiers ask decision models fixed-option questions about application state and return typed answers. Register reusable classifiers here to retrieve them with `getClassifier()` or `getClassifierById()`. When a registered classifier is evaluated without an active trace, it starts a root `CLASSIFIER_EVALUATION` span through the `Mastra` instance's configured observability provider.
|
|
370
370
|
|
|
371
371
|
Visit the [Classifier reference](https://mastra.ai/reference/classifier/classifier) to learn more.
|
|
372
372
|
|
|
@@ -377,7 +377,7 @@ import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
|
377
377
|
|
|
378
378
|
const safety = new Classifier({
|
|
379
379
|
id: 'safety',
|
|
380
|
-
model: typeSafeAi.
|
|
380
|
+
model: typeSafeAi.decisionModel('jev-latest'),
|
|
381
381
|
questions: {
|
|
382
382
|
unsafe: {
|
|
383
383
|
type: 'boolean',
|