@mastra/mcp-docs-server 1.2.23-alpha.0 → 1.2.23-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/code-mode.md +1 -1
- package/.docs/docs/agents/human-in-the-loop.md +1 -1
- package/.docs/docs/agents/networks.md +1 -1
- package/.docs/docs/agents/processors.md +1 -1
- package/.docs/docs/agents/structured-output.md +1 -1
- package/.docs/docs/auth/fga.md +16 -16
- package/.docs/docs/channels.md +2 -2
- package/.docs/docs/connections/mcp.md +1 -1
- package/.docs/docs/datasets/running-experiments.md +1 -1
- package/.docs/docs/deployment/sandbox.md +2 -2
- package/.docs/docs/deployment/workers.md +2 -2
- package/.docs/docs/evals/custom-scorers.md +3 -4
- package/.docs/docs/evals/multi-turn.md +1 -1
- package/.docs/docs/evals/overview.md +11 -11
- package/.docs/docs/evals/quick-checks.md +1 -1
- package/.docs/docs/evals/vitest-integration.md +136 -0
- package/.docs/docs/guides/context-engineering.md +1 -1
- package/.docs/docs/guides/multi-agent-systems.md +1 -1
- package/.docs/docs/guides/streaming.md +72 -52
- package/.docs/docs/harness/agent-controller.md +49 -1
- package/.docs/docs/harness/background-tasks.md +1 -1
- package/.docs/docs/harness/durable-agents.md +1 -1
- package/.docs/docs/harness/overview.md +10 -11
- package/.docs/docs/harness/schedules.md +1 -1
- package/.docs/docs/harness/signal-providers.md +1 -1
- package/.docs/docs/harness/signals.md +1 -1
- package/.docs/docs/index.md +1 -1
- package/.docs/docs/mastra-platform/deploy.md +15 -15
- package/.docs/docs/mastra-platform/environments.md +2 -2
- package/.docs/docs/mastra-platform/github.md +2 -2
- package/.docs/docs/mastra-platform/regions.md +1 -1
- package/.docs/docs/mastra-platform/server.md +4 -4
- package/.docs/docs/mastra-platform/studio.md +1 -1
- package/.docs/docs/mastra-platform/trace-intelligence.md +1 -1
- package/.docs/docs/mastra-platform/workspaces.md +1 -1
- package/.docs/docs/memory/message-history.md +3 -3
- package/.docs/docs/memory/observational-memory.md +18 -18
- package/.docs/docs/memory/overview.md +1 -1
- package/.docs/docs/memory/semantic-recall.md +0 -2
- package/.docs/docs/memory/working-memory.md +1 -1
- package/.docs/docs/observability/feedback.md +2 -2
- package/.docs/docs/observability/integrations/exporters/mastra-storage.md +1 -1
- package/.docs/docs/observability/logging.md +1 -1
- package/.docs/docs/observability/metrics/overview.md +1 -1
- package/.docs/docs/observability/overview.md +13 -11
- package/.docs/docs/observability/tracing/overview.md +13 -13
- package/.docs/docs/sandbox/lsp.md +1 -1
- package/.docs/docs/sandbox/overview.md +1 -1
- package/.docs/docs/server/mastra-client.md +1 -1
- package/.docs/docs/server/overview.md +1 -1
- package/.docs/docs/server/pubsub.md +1 -1
- package/.docs/docs/server/request-context.md +2 -2
- package/.docs/docs/server/server-adapters.md +1 -1
- package/.docs/docs/skills.md +1 -1
- package/.docs/docs/studio/deployment.md +1 -1
- package/.docs/docs/studio/editor.md +1 -1
- package/.docs/docs/studio/observability.md +2 -2
- package/.docs/docs/studio/overview.md +1 -1
- package/.docs/docs/subagents.md +2 -2
- package/.docs/docs/workflows/agents-and-tools.md +0 -4
- package/.docs/docs/workflows/control-flow.md +1 -3
- package/.docs/docs/workflows/overview.md +1 -1
- package/.docs/docs/workflows/scheduled-workflows.md +1 -1
- package/.docs/docs/workflows/suspend-and-resume.md +2 -2
- package/.docs/integrations/sandboxes/agentcore.md +2 -0
- package/.docs/integrations/sandboxes/apple-container.md +5 -3
- package/.docs/integrations/sandboxes/blaxel.md +2 -0
- package/.docs/integrations/sandboxes/cloudflare-sandbox.md +1 -1
- package/.docs/integrations/sandboxes/daytona.md +2 -0
- package/.docs/integrations/sandboxes/docker.md +3 -1
- package/.docs/integrations/sandboxes/e2b.md +4 -0
- package/.docs/integrations/sandboxes/modal.md +3 -1
- package/.docs/integrations/sandboxes/railway.md +2 -0
- package/.docs/integrations/sandboxes/vercel.md +4 -0
- package/.docs/models/environment-variables.md +5 -0
- package/.docs/models/gateways/merge-gateway.md +2 -1
- package/.docs/models/gateways/netlify.md +6 -10
- package/.docs/models/gateways/openrouter.md +3 -7
- package/.docs/models/gateways/vercel.md +4 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/abliteration-ai.md +7 -6
- package/.docs/models/providers/above.md +83 -0
- package/.docs/models/providers/aiand.md +4 -2
- package/.docs/models/providers/anthropic.md +2 -1
- package/.docs/models/providers/berget.md +4 -2
- package/.docs/models/providers/bothub.md +76 -0
- package/.docs/models/providers/chutes.md +1 -1
- package/.docs/models/providers/coralbricks.md +4 -4
- package/.docs/models/providers/cortecs.md +5 -4
- package/.docs/models/providers/crof.md +2 -1
- package/.docs/models/providers/crossmodel.md +4 -3
- package/.docs/models/providers/digitalocean.md +2 -1
- package/.docs/models/providers/edenai.md +10 -9
- package/.docs/models/providers/empiriolabs.md +1 -2
- package/.docs/models/providers/fireworks-ai.md +6 -5
- package/.docs/models/providers/friendli.md +3 -2
- package/.docs/models/providers/google.md +1 -2
- package/.docs/models/providers/groq.md +2 -1
- package/.docs/models/providers/huggingface.md +2 -1
- package/.docs/models/providers/hyper.md +8 -6
- package/.docs/models/providers/iteracompute.md +8 -7
- package/.docs/models/providers/kilo.md +31 -36
- package/.docs/models/providers/klokintegration.md +77 -0
- package/.docs/models/providers/llmgateway-providers.md +4 -29
- package/.docs/models/providers/llmgateway.md +3 -14
- package/.docs/models/providers/nano-gpt.md +75 -92
- package/.docs/models/providers/neuralwatt.md +2 -1
- package/.docs/models/providers/ollama-cloud.md +2 -1
- package/.docs/models/providers/opencode-go.md +1 -1
- package/.docs/models/providers/opencode.md +2 -2
- package/.docs/models/providers/orcarouter.md +3 -2
- package/.docs/models/providers/requesty.md +5 -6
- package/.docs/models/providers/sensenova.md +77 -0
- package/.docs/models/providers/synthetic.md +3 -2
- package/.docs/models/providers/togetherai.md +2 -1
- package/.docs/models/providers/tokenrouter.md +75 -0
- package/.docs/models/providers/trustedrouter.md +13 -13
- package/.docs/models/providers/vancine.md +13 -11
- package/.docs/models/providers/wandb.md +3 -4
- package/.docs/models/providers.md +5 -0
- package/.docs/reference/agent-controller/agent-controller-class.md +2 -2
- package/.docs/reference/agent-controller/session.md +3 -3
- package/.docs/reference/agents/durable-agent.md +77 -9
- package/.docs/reference/agents/getDefaultGenerateOptions.md +1 -1
- package/.docs/reference/agents/listSuspendedRuns.md +2 -2
- package/.docs/reference/ai-sdk/chat-route.md +1 -1
- package/.docs/reference/ai-sdk/network-route.md +1 -1
- package/.docs/reference/ai-sdk/workflow-route.md +1 -1
- package/.docs/reference/browser/browser-viewer.md +1 -1
- package/.docs/reference/cli/mastra.md +4 -4
- package/.docs/reference/core/mastra-class.md +1 -1
- package/.docs/reference/datasets/createExperiment.md +1 -1
- package/.docs/reference/editor/tool-provider.md +1 -1
- package/.docs/reference/editor/versioning.md +1 -1
- package/.docs/reference/evals/multi-turn-judge.md +1 -1
- package/.docs/reference/evals/rubric.md +1 -1
- package/.docs/reference/file-based-agents/schedules.md +2 -2
- package/.docs/reference/file-based-agents/workspace.md +1 -1
- package/.docs/reference/manual-install.md +3 -3
- package/.docs/reference/memory/observational-memory.md +4 -4
- package/.docs/reference/memory/settled.md +1 -1
- package/.docs/reference/migrations/mastra-cloud.md +9 -9
- package/.docs/reference/migrations/upgrade-to-v1/overview.md +1 -1
- package/.docs/reference/observability/tracing/configuration.md +2 -2
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +1 -1
- package/.docs/reference/processors/processor-interface.md +1 -1
- package/.docs/reference/processors/regex-filter-processor.md +3 -3
- package/.docs/reference/processors/token-cost-control.md +2 -2
- package/.docs/reference/processors/token-limiter-processor.md +1 -1
- package/.docs/reference/processors/tool-search-processor.md +1 -1
- package/.docs/reference/processors/working-memory-processor.md +1 -1
- package/.docs/reference/pubsub/base.md +2 -2
- package/.docs/reference/pubsub/lease-provider.md +2 -2
- package/.docs/reference/rag/vector-databases.md +33 -33
- package/.docs/reference/server/create-route.md +1 -1
- package/.docs/reference/signals/task-signal-provider.md +1 -1
- package/.docs/reference/storage/composite.md +1 -1
- package/.docs/reference/storage/retention.md +4 -4
- package/.docs/reference/streaming/ChunkType.md +1 -1
- package/.docs/reference/tools/isolated-vm-transport.md +1 -1
- package/.docs/reference/tools/mcp-client.md +2 -2
- package/.docs/reference/vectors/couchbase.md +1 -1
- package/.docs/reference/vectors/mongodb.md +2 -2
- package/.docs/reference/voice/overview.md +1 -1
- package/.docs/reference/workflows/workflow-methods/agent.md +4 -4
- package/.docs/reference/workflows/workflow-methods/foreach.md +1 -1
- package/.docs/reference/workflows/workflow-methods/tool.md +2 -2
- package/.docs/reference/workspace/platform-sandbox.md +6 -2
- package/.docs/reference/workspace/process-manager.md +1 -1
- package/.docs/reference/workspace/sandbox.md +20 -3
- package/.docs/reference/workspace/workspace-class.md +3 -3
- package/package.json +5 -6
- package/CHANGELOG.md +0 -5929
|
@@ -85,7 +85,7 @@ export const mastra = new Mastra({
|
|
|
85
85
|
- `stop()` tears down the remote sandbox while preserving its recovery checkpoint when it has one.
|
|
86
86
|
- `destroy()` also releases the recovery checkpoint associated with a caller-supplied recovery `id`.
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
A statically configured `PlatformSandbox` is shared across every request and agent using that configuration rather than creating separate sandboxes for requests or memory threads. `PlatformFilesystem` is also a separate provider: configuring both providers doesn't mount the environment bucket inside the sandbox.
|
|
89
89
|
|
|
90
90
|
When your agent needs another isolated environment, for example a per-task sandbox, a per-user tenant, or a background job that shouldn't touch shared shell state, construct another `PlatformSandbox`:
|
|
91
91
|
|
|
@@ -119,8 +119,8 @@ await agent.stream('Hello', {
|
|
|
119
119
|
|
|
120
120
|
You can use this history in two ways:
|
|
121
121
|
|
|
122
|
-
- **Automatic inclusion**: Mastra automatically
|
|
123
|
-
- [**Manual querying**](#querying): For more control,
|
|
122
|
+
- **Automatic inclusion**: Mastra automatically includes recent messages in the context window. The default of 10 messages keeps agents grounded in the conversation. Adjust it with `lastMessages` when needed.
|
|
123
|
+
- [**Manual querying**](#querying): For more control, query threads and messages directly with `recall()`. Use the results to choose which memories enter the context window or to render conversation history in your UI.
|
|
124
124
|
|
|
125
125
|
> **Tip:** When memory is enabled, [Studio](https://mastra.ai/docs/studio/overview) uses message history to display past conversations in the chat sidebar.
|
|
126
126
|
|
|
@@ -230,7 +230,7 @@ const thread = await memory.getThreadById({ threadId: 'thread-123' })
|
|
|
230
230
|
|
|
231
231
|
### Messages
|
|
232
232
|
|
|
233
|
-
Once you have a thread, use [`recall()`](https://mastra.ai/reference/memory/recall) to retrieve its messages. It supports pagination
|
|
233
|
+
Once you have a thread, use [`recall()`](https://mastra.ai/reference/memory/recall) to retrieve its messages. It supports pagination and [semantic search](https://mastra.ai/docs/memory/semantic-recall), with optional date filtering.
|
|
234
234
|
|
|
235
235
|
Basic recall returns all messages from a thread:
|
|
236
236
|
|
|
@@ -31,7 +31,7 @@ export const agent = new Agent({
|
|
|
31
31
|
|
|
32
32
|
**For AI agents:** Using Observational Memory requires a storage provider! You either need to set it on the Mastra instance at `src/mastra/index.ts` or pass it to the Agent constructor.
|
|
33
33
|
|
|
34
|
-
The following script creates a local LibSQL database
|
|
34
|
+
The following script creates a local LibSQL database and enables Observational Memory before using one resource and thread across two agent calls:
|
|
35
35
|
|
|
36
36
|
```typescript
|
|
37
37
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -214,11 +214,11 @@ When message history tokens exceed a threshold (default: 30,000), the Observer c
|
|
|
214
214
|
|
|
215
215
|
OM uses fast local token estimation for this thresholding work. Text is estimated with `tokenx`, while image parts use provider-aware heuristics so multimodal conversations still trigger observation at the right time. The same applies to image-like `file` parts when a transport normalizes an uploaded image as a file instead of an image part. For example, OpenAI image detail settings can materially change when OM decides to observe.
|
|
216
216
|
|
|
217
|
-
The Observer can also see attachments in the history it reviews. OM keeps
|
|
217
|
+
The Observer can also see attachments in the history it reviews. For readability, OM keeps placeholders such as `[Image #1: reference-board.png]` or `[File #1: floorplan.pdf]` in the transcript while forwarding the actual attachments beside the text. When possible, image-like `file` parts become image inputs for the Observer. Other attachments remain file parts and use normalized token counting. This applies to both normal thread observation and batched resource-scope observation.
|
|
218
218
|
|
|
219
219
|
### Extractors
|
|
220
220
|
|
|
221
|
-
Use extractors when you want OM to persist specific values alongside observations. Built-in values
|
|
221
|
+
Use extractors when you want OM to persist specific values alongside observations. Built-in values use the same extraction pipeline as custom values. They include **current task** and **suggested response**, along with **thread title**.
|
|
222
222
|
|
|
223
223
|
The following example extracts a compact user profile from observations:
|
|
224
224
|
|
|
@@ -380,7 +380,7 @@ new Agent({
|
|
|
380
380
|
})
|
|
381
381
|
```
|
|
382
382
|
|
|
383
|
-
You can also pass an allowlist of mimeType globs (for example `['image/*']`) to forward only the kinds the Observer can handle. Alternatively, set `observeAttachments: 'auto'`
|
|
383
|
+
You can also pass an allowlist of mimeType globs (for example `['image/*']`) to forward only the kinds the Observer can handle. Alternatively, set `observeAttachments: 'auto'` so Mastra consults the provider capabilities registry. It forwards attachments when the Observer model supports multimodal input and drops them otherwise. If capability data is unavailable for the model, the setting falls back to `true`.
|
|
384
384
|
|
|
385
385
|
```md
|
|
386
386
|
Date: 2026-01-15
|
|
@@ -426,7 +426,7 @@ With [`shareTokenBudget`](https://mastra.ai/reference/memory/observational-memor
|
|
|
426
426
|
|
|
427
427
|
### Retrieval mode
|
|
428
428
|
|
|
429
|
-
Normal OM compresses messages into observations, which is great for staying on task, but the original wording is gone. Retrieval mode fixes this by keeping each observation group linked to the raw messages that produced it.
|
|
429
|
+
Normal OM compresses messages into observations, which is great for staying on task, but the original wording is gone. Retrieval mode fixes this by keeping each observation group linked to the raw messages that produced it. The agent can call a `recall` tool to recover source details compressed by the summary, including exact wording and tool output as well as chronology.
|
|
430
430
|
|
|
431
431
|
#### Browsing only
|
|
432
432
|
|
|
@@ -716,23 +716,23 @@ When message tokens reach the `messageTokens` threshold, buffered chunks activat
|
|
|
716
716
|
|
|
717
717
|
Buffered observations also include continuation hints, a suggested next response and the current task, so the main agent maintains conversational continuity after activation shrinks the context window.
|
|
718
718
|
|
|
719
|
-
|
|
719
|
+
When message production outpaces the Observer, the `blockAfter` safety threshold allows activation to overshoot the retention target instead of using fewer chunks. Activation still uses no more chunks than needed to reach the target, and the default settings remain unaffected. A synchronous observation runs when the `messageTokens` threshold is reached and buffered activation didn't happen. Buffered activation usually preserves a minimum remaining context (the smaller of \~1k tokens or the configured retention floor), but a single buffered chunk that covers the whole pending window still activates and can leave less.
|
|
720
720
|
|
|
721
721
|
Reflection works similarly, the Reflector runs in the background when observations reach a fraction of the reflection threshold.
|
|
722
722
|
|
|
723
723
|
### Settings
|
|
724
724
|
|
|
725
|
-
| Setting | Default | What it controls
|
|
726
|
-
| ------------------------------------- | ------- |
|
|
727
|
-
| `observation.bufferTokens` | `0.2` | How often to buffer. `0.2` means every 20% of `messageTokens`. With the default 30k threshold, that's roughly every 6k tokens. Can also be an absolute token count (e.g. `5000`).
|
|
728
|
-
| `observation.bufferActivation` | `0.8` | How aggressively to clear the message window on activation. `0.8` means remove enough messages to keep only 20% of `messageTokens` remaining. Lower values keep more message history.
|
|
729
|
-
| `observation.blockAfter` | `1.2` | Safety net if buffering can't keep up. Values from 1 up to (but not including) 100 multiply `messageTokens
|
|
730
|
-
| `activateAfterIdle` | none | Forces buffered observations to activate after a period of inactivity, even before `observation.messageTokens` is reached. Accepts a numeric millisecond value such as `300_000`, duration strings like `"5m"` or `"1hr"`, or `"auto"` for a provider-aware prompt cache TTL.
|
|
731
|
-
| `activateOnProviderChange` | `false` | Forces buffered observations to activate when the next step uses a different `provider/model` than the one that produced the latest assistant step. Use this when switching providers or models would invalidate prompt cache reuse.
|
|
732
|
-
| `reflection.bufferActivation` | `0.5` | When to start background reflection. `0.5` means reflection begins when observations reach 50% of the `observationTokens` threshold.
|
|
733
|
-
| `reflection.activateAfterIdle` | none | Opts buffered reflections into idle activation. Reflections don't inherit top-level `activateAfterIdle`.
|
|
734
|
-
| `reflection.activateOnProviderChange` | `false` | Opts buffered reflections into provider-change activation. Reflections don't inherit top-level `activateOnProviderChange`.
|
|
735
|
-
| `reflection.blockAfter` | `1.2` | Safety threshold for reflection. Same value format as observation (absolute values must be greater than `observationTokens`), but above it reflection runs synchronously when no buffered reflection is ready to activate.
|
|
725
|
+
| Setting | Default | What it controls |
|
|
726
|
+
| ------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
727
|
+
| `observation.bufferTokens` | `0.2` | How often to buffer. `0.2` means every 20% of `messageTokens`. With the default 30k threshold, that's roughly every 6k tokens. Can also be an absolute token count (e.g. `5000`). |
|
|
728
|
+
| `observation.bufferActivation` | `0.8` | How aggressively to clear the message window on activation. `0.8` means remove enough messages to keep only 20% of `messageTokens` remaining. Lower values keep more message history. |
|
|
729
|
+
| `observation.blockAfter` | `1.2` | Safety net if buffering can't keep up. Values from 1 up to (but not including) 100 multiply `messageTokens`. For example, `1.2` creates a threshold of 36k tokens (1.2 × 30k), above which activation may overshoot the retention target rather than use fewer chunks. Values of 100 or more are absolute token counts (e.g. `50_000`) and must be greater than `messageTokens`. |
|
|
730
|
+
| `activateAfterIdle` | none | Forces buffered observations to activate after a period of inactivity, even before `observation.messageTokens` is reached. Accepts a numeric millisecond value such as `300_000`, duration strings like `"5m"` or `"1hr"`, or `"auto"` for a provider-aware prompt cache TTL. |
|
|
731
|
+
| `activateOnProviderChange` | `false` | Forces buffered observations to activate when the next step uses a different `provider/model` than the one that produced the latest assistant step. Use this when switching providers or models would invalidate prompt cache reuse. |
|
|
732
|
+
| `reflection.bufferActivation` | `0.5` | When to start background reflection. `0.5` means reflection begins when observations reach 50% of the `observationTokens` threshold. |
|
|
733
|
+
| `reflection.activateAfterIdle` | none | Opts buffered reflections into idle activation. Reflections don't inherit top-level `activateAfterIdle`. |
|
|
734
|
+
| `reflection.activateOnProviderChange` | `false` | Opts buffered reflections into provider-change activation. Reflections don't inherit top-level `activateOnProviderChange`. |
|
|
735
|
+
| `reflection.blockAfter` | `1.2` | Safety threshold for reflection. Same value format as observation (absolute values must be greater than `observationTokens`), but above it reflection runs synchronously when no buffered reflection is ready to activate. |
|
|
736
736
|
|
|
737
737
|
If you're relying on prompt caching, set `activateAfterIdle` to `"auto"` or to a specific cache TTL. That way, once a thread has been idle long enough for the cache to expire, the next request can activate buffered observations first and send a smaller compressed context window.
|
|
738
738
|
|
|
@@ -784,7 +784,7 @@ const memory = new Memory({
|
|
|
784
784
|
|
|
785
785
|
Setting `bufferTokens: false` disables both observation and reflection async buffering. See [async buffering configuration](https://mastra.ai/reference/memory/observational-memory) for the full API.
|
|
786
786
|
|
|
787
|
-
> **Note:**
|
|
787
|
+
> **Note:** Resource scope automatically disables async buffering.
|
|
788
788
|
|
|
789
789
|
## Observer Context Optimization
|
|
790
790
|
|
|
@@ -116,7 +116,7 @@ Use memory when your agent needs to maintain multi-turn conversations that refer
|
|
|
116
116
|
|
|
117
117
|
Visit [Memory Class](https://mastra.ai/reference/memory/memory-class) for a full list of configuration options.
|
|
118
118
|
|
|
119
|
-
5. Call your agent, for example in [Studio](https://mastra.ai/docs/studio/overview). Inside Studio, start a new chat with your agent and take a look at the right sidebar. It'll now display
|
|
119
|
+
5. Call your agent, for example in [Studio](https://mastra.ai/docs/studio/overview). Inside Studio, start a new chat with your agent and take a look at the right sidebar. It'll now display memory details.
|
|
120
120
|
|
|
121
121
|
## Message history
|
|
122
122
|
|
|
@@ -14,8 +14,6 @@ Semantic recall is RAG-based search that helps agents maintain context across lo
|
|
|
14
14
|
|
|
15
15
|
It uses vector embeddings of messages for similarity search and integrates with vector stores, plus has configurable context windows around retrieved messages.
|
|
16
16
|
|
|
17
|
-

|
|
18
|
-
|
|
19
17
|
When it's enabled, new messages are used to query a vector DB for semantically similar messages.
|
|
20
18
|
|
|
21
19
|
After getting a response from the LLM, all new messages (user, assistant, and tool calls/results) are inserted into the vector DB to be recalled in later interactions.
|
|
@@ -275,7 +275,7 @@ Schema-based working memory uses **merge semantics**, meaning the agent only nee
|
|
|
275
275
|
## Choosing between template and schema
|
|
276
276
|
|
|
277
277
|
- Use a **template** (Markdown) if you want the agent to maintain memory as a free-form text block, such as a user profile or scratchpad. Templates use **replace semantics**: the agent must provide the complete memory content on each update.
|
|
278
|
-
- Use a **schema**
|
|
278
|
+
- Use a **schema** for structured, type-safe JSON data that supports validation and programmatic access. The `workingMemory.schema` field accepts any `PublicSchema`-compatible schema, such as Zod v3 or v4. JSON Schema and already-standard schemas are also supported. **Merge semantics** preserve existing fields when the agent provides only the fields to update.
|
|
279
279
|
- Only one mode can be active at a time: setting both `template` and `schema` isn't supported.
|
|
280
280
|
|
|
281
281
|
## Example: Multi-step retention
|
|
@@ -155,7 +155,7 @@ The local runtime exposes the list route at `/api/observability/feedback` and an
|
|
|
155
155
|
|
|
156
156
|
[`MastraPlatformExporter`](https://mastra.ai/reference/observability/tracing/exporters/mastra-platform-exporter) forwards emitted feedback events to Mastra Platform automatically because the hosted query API doesn't provide a creation route.
|
|
157
157
|
|
|
158
|
-
If your application adds feedback after an agent or workflow response using only its `traceId`, configure `MastraStorageExporter` alongside `MastraPlatformExporter`. The storage exporter keeps the trace available for `addFeedback()` to rehydrate,
|
|
158
|
+
If your application adds feedback after an agent or workflow response using only its `traceId`, configure `MastraStorageExporter` alongside `MastraPlatformExporter`. The storage exporter keeps the trace available for `addFeedback()` to rehydrate, while the Platform exporter forwards the resulting feedback event without adding the trace to the application's local storage.
|
|
159
159
|
|
|
160
160
|
See [Observability on Mastra Platform](https://mastra.ai/docs/mastra-platform/observability) for the combined exporter configuration.
|
|
161
161
|
|
|
@@ -166,7 +166,7 @@ Feedback flows through the observability event bus, so exporters that support fe
|
|
|
166
166
|
## Related
|
|
167
167
|
|
|
168
168
|
- [Observability overview](https://mastra.ai/docs/observability/overview)
|
|
169
|
-
- [
|
|
169
|
+
- [Traces usage](https://mastra.ai/docs/observability/tracing/overview)
|
|
170
170
|
- [Metrics overview](https://mastra.ai/docs/observability/metrics/overview)
|
|
171
171
|
- [Client SDK observability reference](https://mastra.ai/reference/client-js/observability)
|
|
172
172
|
- [Feedback reference](https://mastra.ai/reference/observability/feedback)
|
|
@@ -248,7 +248,7 @@ new MastraStorageExporter({
|
|
|
248
248
|
|
|
249
249
|
## Related
|
|
250
250
|
|
|
251
|
-
- [
|
|
251
|
+
- [Traces usage](https://mastra.ai/docs/observability/tracing/overview)
|
|
252
252
|
- [MastraPlatformExporter](https://mastra.ai/docs/mastra-platform/observability)
|
|
253
253
|
- [Composite Storage](https://mastra.ai/reference/storage/composite): Combine multiple storage providers
|
|
254
254
|
- [Storage Configuration](https://mastra.ai/docs/storage)
|
|
@@ -78,7 +78,7 @@ export const mastra = new Mastra({
|
|
|
78
78
|
|
|
79
79
|
### Custom loggers
|
|
80
80
|
|
|
81
|
-
Custom `IMastraLogger` implementations keep working: Mastra
|
|
81
|
+
Custom `IMastraLogger` implementations keep working: Mastra uses a deprecated dual-write fallback that forwards log calls to observability without adding `trace_id` or `span_id` to the logger's native output. To get trace-correlated output, implement the `__attachObservability()` adapter hook from `@mastra/core/logger`:
|
|
82
82
|
|
|
83
83
|
```typescript
|
|
84
84
|
import { MastraLogger, buildLogRecordData } from '@mastra/core/logger'
|
|
@@ -104,5 +104,5 @@ In production, always include a timestamp range in metric queries. Time bounds l
|
|
|
104
104
|
## Related
|
|
105
105
|
|
|
106
106
|
- [Observability overview](https://mastra.ai/docs/observability/overview)
|
|
107
|
-
- [
|
|
107
|
+
- [Traces usage](https://mastra.ai/docs/observability/tracing/overview)
|
|
108
108
|
- [MastraStorageExporter](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage)
|
|
@@ -4,14 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
# Observability
|
|
6
6
|
|
|
7
|
-
Mastra's observability system gives you visibility into every agent run, workflow step, tool call, and model interaction. Agent behavior depends on model responses, prompts, tools, memory, and workflow state, so observability helps you inspect runtime decisions from day one.
|
|
7
|
+
Mastra's observability system gives you visibility into every agent run, workflow step, tool call, and model interaction. Agent behavior depends on model responses, prompts, tools, memory, and workflow state, so observability helps you inspect runtime decisions from day one.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
- [**
|
|
12
|
-
- [**Logging**](https://mastra.ai/docs/observability/logging):
|
|
13
|
-
- [**
|
|
14
|
-
- [**
|
|
9
|
+
Start with the trace-correlated pages:
|
|
10
|
+
|
|
11
|
+
- [**Usage**](https://mastra.ai/docs/observability/tracing/overview): Inspect the span hierarchy, inputs, outputs, token usage, timing, and trace context for an execution.
|
|
12
|
+
- [**Logging**](https://mastra.ai/docs/observability/logging): Forward structured log entries from your application and Mastra internals, correlated to traces automatically.
|
|
13
|
+
- [**Feedback**](https://mastra.ai/docs/observability/feedback): Store ratings, comments, corrections, and other review signals linked to traces and spans.
|
|
14
|
+
- [**Storage**](#storage): Choose backends for persisted traces, logs, metrics aggregation, and feedback queries.
|
|
15
|
+
|
|
16
|
+
Use [**Metrics**](https://mastra.ai/docs/observability/metrics/overview) to analyze aggregate usage, performance, and cost data derived from spans. No additional instrumentation is required. Use [**Configuration**](#configuration) to enable the signals and exporters your application needs.
|
|
15
17
|
|
|
16
18
|
## When to use observability
|
|
17
19
|
|
|
@@ -23,15 +25,15 @@ Mastra's observability system gives you visibility into every agent run, workflo
|
|
|
23
25
|
|
|
24
26
|
## How the pieces fit together
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
When observability is configured, every agent run, workflow execution, tool call, and model interaction produces a [span](https://opentelemetry.io/docs/concepts/signals/traces/#spans). Mastra organizes related spans into traces that show the full request lifecycle as a hierarchical timeline.
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
When a span ends, Mastra extracts duration, token counts, and cost estimates without any extra code. These metrics power the aggregate dashboards in [Studio](https://mastra.ai/docs/studio/observability).
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
Every `logger.info()`, `logger.warn()`, or `logger.error()` call within a traced context is tagged with the current trace and span IDs. You can move from a log entry directly to the trace that produced it.
|
|
31
33
|
|
|
32
34
|
Feedback records human review signals such as ratings, comments, and corrections. Feedback can be linked to traces and spans, then queried with the same observability store used for metrics.
|
|
33
35
|
|
|
34
|
-
These
|
|
36
|
+
These records share correlation fields such as trace ID, span ID, entity type, and entity name. You can use them to move from a metric spike to its traces, logs, and related feedback.
|
|
35
37
|
|
|
36
38
|
## Quickstart
|
|
37
39
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# Usage
|
|
6
6
|
|
|
7
7
|
Tracing is the observability signal that records how a request moves through agents, workflows, tools, and model calls. Mastra represents each operation as a span and groups related spans into a trace so you can inspect the full execution path.
|
|
8
8
|
|
|
@@ -144,7 +144,7 @@ export const mastra = new Mastra({
|
|
|
144
144
|
})
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
-
If `environment` isn't set, Mastra falls back to `process.env.NODE_ENV`. If
|
|
147
|
+
If `environment` isn't set, runs started through `mastra dev` resolve to `development` (even though the dev server itself runs with `NODE_ENV=production`); otherwise Mastra falls back to `process.env.NODE_ENV`. If none of these are set, the field is left undefined rather than guessed.
|
|
148
148
|
|
|
149
149
|
Per-call `tracingOptions.metadata.environment` always takes precedence, so individual calls can override the value when needed.
|
|
150
150
|
|
|
@@ -660,8 +660,8 @@ export const mastra = new Mastra({
|
|
|
660
660
|
default: {
|
|
661
661
|
serviceName: 'my-service',
|
|
662
662
|
serializationOptions: {
|
|
663
|
-
maxStringLength: 2048, // Maximum length for string values (default:
|
|
664
|
-
maxDepth: 10, // Maximum depth for nested objects (default:
|
|
663
|
+
maxStringLength: 2048, // Maximum length for string values (default: 131072)
|
|
664
|
+
maxDepth: 10, // Maximum depth for nested objects (default: 8)
|
|
665
665
|
maxArrayLength: 100, // Maximum number of items in arrays (default: 50)
|
|
666
666
|
maxObjectKeys: 75, // Maximum number of keys in objects (default: 50)
|
|
667
667
|
},
|
|
@@ -674,12 +674,12 @@ export const mastra = new Mastra({
|
|
|
674
674
|
|
|
675
675
|
### Available options
|
|
676
676
|
|
|
677
|
-
| Option | Default
|
|
678
|
-
| ----------------- |
|
|
679
|
-
| `maxStringLength` |
|
|
680
|
-
| `maxDepth` |
|
|
681
|
-
| `maxArrayLength` | 50
|
|
682
|
-
| `maxObjectKeys` | 50
|
|
677
|
+
| Option | Default | Description |
|
|
678
|
+
| ----------------- | --------------- | ---------------------------------------------------------------- |
|
|
679
|
+
| `maxStringLength` | 131072 (128 KB) | Maximum length for string values. Longer strings are truncated. |
|
|
680
|
+
| `maxDepth` | 8 | Maximum depth for nested objects. Deeper levels are omitted. |
|
|
681
|
+
| `maxArrayLength` | 50 | Maximum number of items in arrays. Additional items are omitted. |
|
|
682
|
+
| `maxObjectKeys` | 50 | Maximum number of keys in objects. Additional keys are omitted. |
|
|
683
683
|
|
|
684
684
|
### Use cases
|
|
685
685
|
|
|
@@ -687,9 +687,9 @@ export const mastra = new Mastra({
|
|
|
687
687
|
|
|
688
688
|
```ts
|
|
689
689
|
serializationOptions: {
|
|
690
|
-
maxStringLength:
|
|
691
|
-
maxDepth: 12,
|
|
692
|
-
maxArrayLength: 200,
|
|
690
|
+
maxStringLength: 262144, // Capture longer text content (256 KB)
|
|
691
|
+
maxDepth: 12, // Handle deeply nested JSON responses
|
|
692
|
+
maxArrayLength: 200, // Keep more items from large lists
|
|
693
693
|
}
|
|
694
694
|
```
|
|
695
695
|
|
|
@@ -149,7 +149,7 @@ lsp: {
|
|
|
149
149
|
},
|
|
150
150
|
```
|
|
151
151
|
|
|
152
|
-
`binaryOverrides` maps a built-in server ID to its full startup command. `searchPaths` adds package roots whose `node_modules` may contain
|
|
152
|
+
`binaryOverrides` maps a built-in server ID to its full startup command. `searchPaths` adds package roots whose `node_modules` may contain required modules or binaries. As a last-resort fallback, you can set a `packageRunner` such as `pnpm dlx`. Package-runner fallback is disabled by default because it may install software or hang in some project layouts.
|
|
153
153
|
|
|
154
154
|
`diagnosticTimeout` controls how long the direct `getDiagnostics()` and `getDiagnosticsMulti()` APIs wait for diagnostics. The agent inspection tool currently waits up to five seconds.
|
|
155
155
|
|
|
@@ -264,7 +264,7 @@ The example mounts the filesystem inside the resolver because static `mounts` ca
|
|
|
264
264
|
|
|
265
265
|
With a static sandbox, Mastra knows which capabilities the backend supports and only gives the agent the corresponding tools. Application code should also check that an optional capability is available before using it.
|
|
266
266
|
|
|
267
|
-
|
|
267
|
+
Because a [resolver-backed sandbox](#sandboxes-per-user-or-thread) isn't known until request time, Mastra initially exposes every sandbox tool. Calling one unsupported by the resolved backend fails with `SandboxFeatureNotSupportedError`.
|
|
268
268
|
|
|
269
269
|
## Background processes
|
|
270
270
|
|
|
@@ -305,7 +305,7 @@ export const colorAgent = new Agent({
|
|
|
305
305
|
|
|
306
306
|
## Use MastraClient on the server
|
|
307
307
|
|
|
308
|
-
|
|
308
|
+
Server-side API routes and serverless functions, including actions, can also use `MastraClient`. The usage is unchanged, although you may need to recreate the response for your client:
|
|
309
309
|
|
|
310
310
|
```typescript
|
|
311
311
|
export async function action() {
|
|
@@ -66,7 +66,7 @@ Mastra exposes OpenAI-compatible Responses and Conversations routes that let you
|
|
|
66
66
|
|
|
67
67
|
These APIs are currently experimental.
|
|
68
68
|
|
|
69
|
-
Use `agent_id` to select the Mastra agent that should handle the request. Initial requests target an agent directly
|
|
69
|
+
Use `agent_id` to select the Mastra agent that should handle the request. Initial requests target an agent directly. Stored follow-up turns can continue through `previous_response_id`. Pass `model` to override the configured model for one request, or omit it to use the agent's existing model.
|
|
70
70
|
|
|
71
71
|
The Responses routes support streaming, function calling (tools), stored continuations with `previous_response_id`, conversation threads through `conversation_id`, provider-specific passthrough with `providerOptions`, and JSON output through `text.format`.
|
|
72
72
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
Mastra uses a publish/subscribe (pub/sub) system as its internal event bus. Components publish events to topics, and other components subscribe to those topics to react. The backend you configure decides how far those events travel: within one process or across processes on one host, or alternatively across separate instances.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Set the backend once on the `Mastra` instance for use throughout the system. The default is an in-process backend that requires no setup.
|
|
10
10
|
|
|
11
11
|
## How Mastra uses PubSub
|
|
12
12
|
|
|
@@ -152,7 +152,7 @@ You can also use `requestContext` with other options like `agents`, `workflows`,
|
|
|
152
152
|
|
|
153
153
|
### Dynamic instructions
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
Provide agent instructions through an async function to resolve prompts at runtime. Together with `requestContext`, this supports patterns like:
|
|
156
156
|
|
|
157
157
|
- **Personalization**: Tailor instructions based on user attributes, preferences, or tier
|
|
158
158
|
- **Localization**: Adjust tone, language, or behavior based on locale
|
|
@@ -270,7 +270,7 @@ auth: {
|
|
|
270
270
|
}
|
|
271
271
|
```
|
|
272
272
|
|
|
273
|
-
When the resource ID is derived this way, clients can omit `memory.resource` from agent generate and stream request bodies
|
|
273
|
+
When the resource ID is derived this way, clients can omit `memory.resource` from agent generate and stream request bodies. The server-derived value is used instead and always takes precedence over a client-provided value. If a request uses memory and neither the body nor the request context provides a resource ID, the server responds with a 400 error.
|
|
274
274
|
|
|
275
275
|
You can also set these keys manually in middleware:
|
|
276
276
|
|
|
@@ -337,7 +337,7 @@ bun add @mastra/nestjs@latest
|
|
|
337
337
|
|
|
338
338
|
## Configuration
|
|
339
339
|
|
|
340
|
-
Initialize your app as usual, then create a `MastraServer` by passing in the `app` and your main `mastra` instance from `src/mastra/index.ts`. Calling `init()` automatically registers Mastra middleware and all available endpoints.
|
|
340
|
+
Initialize your app as usual, then create a `MastraServer` by passing in the `app` and your main `mastra` instance from `src/mastra/index.ts`. Calling `init()` automatically registers Mastra middleware and all available endpoints. Continue adding your own routes either before or after `init()`. They run alongside Mastra’s endpoints.
|
|
341
341
|
|
|
342
342
|
**Elysia**:
|
|
343
343
|
|
package/.docs/docs/skills.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
Skills are reusable instructions that teach agents how to perform specific tasks. They follow the [Agent Skills specification](https://agentskills.io).
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Attach skills directly through an agent's `skills` config, or configure them on a [workspace](https://mastra.ai/docs/sandbox/skills). Agent-level skills belong to one agent and can be defined in code without a workspace, while workspace skills are discovered from the filesystem and shared by every agent using that workspace. This page explains how to define and load agent-level skills with per-request resolution.
|
|
10
10
|
|
|
11
11
|
## When to use agent-level skills
|
|
12
12
|
|
|
@@ -51,7 +51,7 @@ Run the `mastra studio` command:
|
|
|
51
51
|
mastra studio
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
Open [localhost:3000](http://localhost:3000) in your browser to see the Studio UI. By default, it
|
|
54
|
+
Open [localhost:3000](http://localhost:3000) in your browser to see the Studio UI. By default, it connects to a Mastra server at `http://localhost:4111`; when no server is available, the UI displays a form for entering your Mastra instance URL and API prefix.
|
|
55
55
|
|
|
56
56
|
The command uses Node's built-in `http` module and [`serve-handler`](https://www.npmjs.com/package/serve-handler) to serve the static files.
|
|
57
57
|
|
|
@@ -77,7 +77,7 @@ An instruction block can include values from the current request. For example, `
|
|
|
77
77
|
|
|
78
78
|
### Prompt blocks
|
|
79
79
|
|
|
80
|
-
A prompt block is a saved piece of instruction text that can be used by more than one agent. Create one under **Prompts
|
|
80
|
+
A prompt block is a saved piece of instruction text that can be used by more than one agent. Create and publish one under **Prompts**. Then open an agent's **Instructions** section and select **Add block**.
|
|
81
81
|
|
|
82
82
|
For example, agents for support, returns, and order status may all need the same refund policy. Save the policy as a prompt block and add it to each agent. When the policy changes, update and publish the block once instead of editing three agents.
|
|
83
83
|
|
|
@@ -102,7 +102,7 @@ Above the trace list, open **Columns** to show or hide input, entity, duration,
|
|
|
102
102
|
|
|
103
103
|
Token and estimated cost columns require an observability store that supports metrics. These columns stay hidden in the **Branches** view because several branch rows can belong to the same trace.
|
|
104
104
|
|
|
105
|
-
Tracing filters out low-level framework details so your traces stay focused and readable. Visit
|
|
105
|
+
Tracing filters out low-level framework details so your traces stay focused and readable. Visit [Traces usage](https://mastra.ai/docs/observability/tracing/overview) for more details.
|
|
106
106
|
|
|
107
107
|
To export a trace, select **Download trace JSON** in the trace panel header. This saves the entire trace as a `trace-<id>.json` file, with every span and its full input, output, metadata, and attributes. Use it to share a trace or attach it to a bug report, or alternatively build an evaluation dataset offline.
|
|
108
108
|
|
|
@@ -116,6 +116,6 @@ Log forwarding is enabled by default when you configure observability. See [logg
|
|
|
116
116
|
|
|
117
117
|
- [Observability overview](https://mastra.ai/docs/observability/overview)
|
|
118
118
|
- [Metrics overview](https://mastra.ai/docs/observability/metrics/overview)
|
|
119
|
-
- [
|
|
119
|
+
- [Traces usage](https://mastra.ai/docs/observability/tracing/overview)
|
|
120
120
|
- [Logging](https://mastra.ai/docs/observability/logging)
|
|
121
121
|
- [Mastra platform observability](https://mastra.ai/docs/mastra-platform/observability)
|
|
@@ -41,7 +41,7 @@ Once the server is running, you can:
|
|
|
41
41
|
- Open the Studio UI at [`localhost:4111`](http://localhost:4111/) to interact with your agents, workflows, and tools.
|
|
42
42
|
- Visit [`localhost:4111/swagger-ui`](http://localhost:4111/swagger-ui) to discover and interact with the underlying REST API.
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
Studio lets you edit your [agents](https://mastra.ai/docs/agents/overview), [workflows](https://mastra.ai/docs/workflows/overview), and other parts of your Mastra application in real time.
|
|
45
45
|
|
|
46
46
|
## Deploy Studio
|
|
47
47
|
|
package/.docs/docs/subagents.md
CHANGED
|
@@ -138,7 +138,7 @@ Called after a delegation finishes. Use it to inspect results or provide feedbac
|
|
|
138
138
|
- Return `{ feedback: '...' }`: Add feedback that gets saved to the parent agent's memory and is visible to subsequent iterations
|
|
139
139
|
- Return `{ resultText: '...' }`: Replace the tool result text the parent model sees for this delegation, within the current run
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
Set `resultText` when the subagent's own result would give the parent a misleading signal. For example, empty text from a subagent stopped on a tool-calls step looks like a successful but empty delegation to the parent model. Unlike `feedback` on the next turn, `resultText` affects the parent's reasoning immediately.
|
|
142
142
|
|
|
143
143
|
```typescript
|
|
144
144
|
const stream = await parentAgent.stream('Research AI trends', {
|
|
@@ -196,7 +196,7 @@ await parentAgent.generate('Research AI trends', { maxSteps: 10, requestContext
|
|
|
196
196
|
const hookErrors = requestContext.get('__mastra_delegationHookErrors') ?? []
|
|
197
197
|
```
|
|
198
198
|
|
|
199
|
-
When `hookErrorStrategy` is `'throw'`, a throwing `onDelegationStart` blocks the subagent from running at all, and a throwing `messageFilter` or `onDelegationComplete` surfaces to the parent as a failed tool call. If `onDelegationComplete` throws while handling a failed delegation, the original delegation error
|
|
199
|
+
When `hookErrorStrategy` is `'throw'`, a throwing `onDelegationStart` blocks the subagent from running at all, and a throwing `messageFilter` or `onDelegationComplete` surfaces to the parent as a failed tool call. If `onDelegationComplete` throws while handling a failed delegation, the original delegation error remains the surfaced error. The hook isn't invoked again for its own failure.
|
|
200
200
|
|
|
201
201
|
## Message filtering
|
|
202
202
|
|
|
@@ -41,8 +41,6 @@ const step1 = createStep({
|
|
|
41
41
|
|
|
42
42
|
Compose an agent as a step using `createStep()` when you don't need to modify the agent call. Use `.map()` to transform the previous step's output into a `prompt` the agent can use.
|
|
43
43
|
|
|
44
|
-

|
|
45
|
-
|
|
46
44
|
```typescript
|
|
47
45
|
import { testAgent } from '../agents/test-agent'
|
|
48
46
|
const step1 = createStep(testAgent)
|
|
@@ -155,8 +153,6 @@ const step2 = createStep({
|
|
|
155
153
|
|
|
156
154
|
Compose a tool as a step using `createStep()` when the previous step's output matches the tool's input context. You can use `.map()` to transform the previous step's output if they don't.
|
|
157
155
|
|
|
158
|
-

|
|
159
|
-
|
|
160
156
|
```typescript
|
|
161
157
|
import { testTool } from '../tools/test-tool'
|
|
162
158
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Control flow
|
|
6
6
|
|
|
7
|
-
Workflows
|
|
7
|
+
Workflows give you control over predefined tasks by dividing each task into **steps**. Those steps can run sequentially or in parallel, and they can follow conditional paths.
|
|
8
8
|
|
|
9
9
|
Each step connects to the next in the workflow through defined schemas that keep data controlled and consistent.
|
|
10
10
|
|
|
@@ -212,8 +212,6 @@ Visit [Choosing the right pattern](#choosing-the-right-pattern) to understand wh
|
|
|
212
212
|
|
|
213
213
|
Use `.branch()` to choose which step to run based on a condition. All steps in a branch need the same `inputSchema` and `outputSchema` because branching requires consistent schemas so workflows can follow different paths.
|
|
214
214
|
|
|
215
|
-

|
|
216
|
-
|
|
217
215
|
```typescript
|
|
218
216
|
const step1 = createStep({...})
|
|
219
217
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Workflows
|
|
6
6
|
|
|
7
|
-
Workflows let you define complex sequences
|
|
7
|
+
Workflows let you define complex task sequences with clear, structured steps instead of relying on one agent to reason through the entire process. You control the task breakdown along with the flow and timing of data. Workflows use the built-in execution engine by default, while managed infrastructure is available through [workflow runners](https://mastra.ai/docs/deployment/workflow-runners) such as Inngest.
|
|
8
8
|
|
|
9
9
|
**For AI agents:** Run `npx mastra api workflow run start test-workflow '{"inputData":{"message":"Hello, world!"}}'` to start this workflow directly instead of writing a temporary script. The command requires a running Mastra server; start the local server with `npx mastra dev`, or pass the reachable server's base URL with `--url`. Run `npx mastra api workflow run start --schema` before constructing different input. Install Mastra's skill with `npx skills add mastra-ai/skills --skill mastra` for complete API CLI discovery, targeting, schema, authentication, and error-handling guidance.
|
|
10
10
|
|
|
@@ -44,7 +44,7 @@ A separate "register schedule" call won't happen. The scheduler reads `schedule`
|
|
|
44
44
|
|
|
45
45
|
A workflow that declares `schedule` is auto-promoted to the **evented execution engine**. The public API (`workflow.start()`, `workflow.startAsync()`, `streamLegacy()`, `resume()`) is unchanged, `EventedWorkflow extends Workflow` and overrides each method with matching signatures. From your code, scheduled fires and manual runs are indistinguishable.
|
|
46
46
|
|
|
47
|
-
The promotion
|
|
47
|
+
The promotion means evented runs require a storage adapter with concurrent-update support, such as `@mastra/libsql`; otherwise, `createRun()` throws a clear error that points to the `schedule` field. Switch adapters or remove the schedule.
|
|
48
48
|
|
|
49
49
|
## Single schedule
|
|
50
50
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Suspend and resume
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Pause a workflow at any step to collect additional data, wait for an API callback, throttle a costly operation, or request [human-in-the-loop](https://mastra.ai/docs/workflows/human-in-the-loop) input. Suspension saves the current execution state as a snapshot. Later, resume from a [specific step ID](https://mastra.ai/docs/workflows/snapshots) to restore the exact captured state. [Snapshots](https://mastra.ai/docs/workflows/snapshots) are stored in your configured storage provider and persist across deployments and application restarts.
|
|
8
8
|
|
|
9
9
|
## Pausing a workflow with `suspend()`
|
|
10
10
|
|
|
@@ -98,7 +98,7 @@ const stream = run.resume({
|
|
|
98
98
|
})
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
You can call `resume()` from anywhere in your application,
|
|
101
|
+
You can call `resume()` from anywhere in your application, such as an HTTP endpoint or event handler. Timers and code responding to [human input](https://mastra.ai/docs/workflows/human-in-the-loop) can also resume a workflow.
|
|
102
102
|
|
|
103
103
|
```typescript
|
|
104
104
|
const midnight = new Date()
|