@mastra/mcp-docs-server 1.2.13-alpha.1 → 1.2.13-alpha.12
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/agent-approval.md +2 -2
- package/.docs/docs/agents/overview.md +1 -1
- package/.docs/docs/agents/supervisor-agents.md +2 -2
- package/.docs/docs/agents/using-tools.md +29 -0
- package/.docs/docs/capabilities/channels/imessage.md +181 -0
- package/.docs/docs/capabilities/channels/overview.md +1 -0
- package/.docs/docs/{evals/datasets → datasets}/overview.md +3 -3
- package/.docs/docs/{evals/datasets → datasets}/running-experiments.md +60 -3
- package/.docs/docs/deployment/workers.md +14 -14
- package/.docs/docs/editor/overview.md +201 -206
- package/.docs/docs/evals/evals-with-memory.md +1 -1
- package/.docs/docs/getting-started/develop.md +196 -0
- package/.docs/docs/index.md +78 -1
- package/.docs/docs/long-running-agents/durable-agents.md +2 -2
- package/.docs/docs/mastra-platform/overview.md +1 -1
- package/.docs/docs/mastra-platform/workspaces.md +152 -0
- package/.docs/docs/memory/observational-memory.md +53 -13
- package/.docs/docs/memory/overview.md +14 -0
- package/.docs/docs/server/auth/workers.md +7 -5
- package/.docs/docs/server/mastra-client.md +60 -0
- package/.docs/docs/server/pubsub.md +2 -2
- package/.docs/docs/studio/observability.md +4 -0
- package/.docs/docs/studio/overview.md +2 -2
- package/.docs/docs/workflows/overview.md +1 -1
- package/.docs/docs/workflows/scheduled-workflows.md +1 -0
- package/.docs/docs/workspace/search.md +1 -1
- package/.docs/guides/deployment/kubernetes.md +2 -0
- package/.docs/guides/deployment/mastra-workers.md +350 -6
- package/.docs/guides/deployment/vercel.md +2 -0
- package/.docs/guides/getting-started/quickstart.md +3 -3
- package/.docs/{docs → guides}/rag/chunking-and-embedding.md +1 -1
- package/.docs/{docs → guides}/rag/graph-rag.md +1 -1
- package/.docs/{docs → guides}/rag/overview.md +2 -2
- package/.docs/{docs → guides}/rag/retrieval.md +1 -1
- package/.docs/{docs → guides}/voice/overview.md +4 -4
- package/.docs/{docs → guides}/voice/realtime-voice.md +2 -2
- package/.docs/{docs → guides}/voice/speech-to-speech.md +1 -1
- package/.docs/{docs → guides}/voice/speech-to-text.md +1 -1
- package/.docs/{docs → guides}/voice/text-to-speech.md +2 -2
- package/.docs/models/embeddings.md +63 -65
- package/.docs/models/environment-variables.md +6 -2
- package/.docs/models/gateways/netlify.md +1 -2
- package/.docs/models/gateways/openrouter.md +5 -6
- package/.docs/models/gateways/vercel.md +9 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/alibaba-cn.md +3 -1
- package/.docs/models/providers/alibaba-token-plan-cn.md +27 -25
- package/.docs/models/providers/alibaba-token-plan.md +27 -25
- package/.docs/models/providers/alibaba.md +2 -1
- package/.docs/models/providers/ambient.md +13 -12
- package/.docs/models/providers/baseten.md +3 -1
- package/.docs/models/providers/chutes.md +6 -8
- package/.docs/models/providers/crof.md +3 -1
- package/.docs/models/providers/crossmodel.md +7 -3
- package/.docs/models/providers/deepinfra.md +9 -2
- package/.docs/models/providers/digitalocean.md +34 -27
- package/.docs/models/providers/empiriolabs.md +5 -1
- package/.docs/models/providers/fireworks-ai.md +20 -19
- package/.docs/models/providers/greenpt.md +17 -8
- package/.docs/models/providers/groq.md +20 -20
- package/.docs/models/providers/huggingface.md +5 -1
- package/.docs/models/providers/hyper.md +13 -8
- package/.docs/models/providers/impossibl.md +148 -0
- package/.docs/models/providers/infomaniak.md +83 -0
- package/.docs/models/providers/kilo.md +349 -350
- package/.docs/models/providers/llmgateway.md +7 -4
- package/.docs/models/providers/minimax.md +1 -1
- package/.docs/models/providers/mistral.md +5 -2
- package/.docs/models/providers/modal.md +5 -4
- package/.docs/models/providers/modelis.md +81 -0
- package/.docs/models/providers/nano-gpt.md +146 -148
- package/.docs/models/providers/neuralwatt.md +4 -1
- package/.docs/models/providers/ofox.md +2 -2
- package/.docs/models/providers/ollama-cloud.md +23 -22
- package/.docs/models/providers/openai.md +2 -2
- package/.docs/models/providers/opencode-go.md +4 -2
- package/.docs/models/providers/opencode.md +1 -1
- package/.docs/models/providers/perplexity-agent.md +3 -1
- package/.docs/models/providers/requesty.md +54 -45
- package/.docs/models/providers/scaleway.md +1 -3
- package/.docs/models/providers/scx.md +74 -0
- package/.docs/models/providers/tensorx.md +97 -0
- package/.docs/models/providers/the-grid-ai.md +3 -3
- package/.docs/models/providers/togetherai.md +2 -1
- package/.docs/models/providers/umans-ai-coding-plan.md +11 -9
- package/.docs/models/providers/umans-ai.md +11 -9
- package/.docs/models/providers/wandb.md +2 -2
- package/.docs/models/providers/zai-coding-plan.md +11 -13
- package/.docs/models/providers/zhipuai-coding-plan.md +12 -12
- package/.docs/models/providers.md +5 -1
- package/.docs/reference/agents/agent.md +1 -1
- package/.docs/reference/agents/durable-agent.md +12 -1
- package/.docs/reference/agents/generate.md +1 -1
- package/.docs/reference/agents/getVoice.md +1 -1
- package/.docs/{docs/getting-started → reference}/build-with-ai.md +5 -110
- package/.docs/reference/cli/create-mastra.md +2 -0
- package/.docs/reference/cli/mastra.md +36 -16
- package/.docs/reference/client-js/agents.md +1 -1
- package/.docs/reference/configuration.md +2 -2
- package/.docs/reference/core/getEditor.md +1 -1
- package/.docs/reference/core/getVector.md +2 -2
- package/.docs/reference/core/listVectors.md +2 -2
- package/.docs/reference/core/mastra-class.md +2 -2
- package/.docs/reference/datasets/startExperiment.md +6 -0
- package/.docs/reference/datasets/startExperimentAsync.md +4 -0
- package/.docs/reference/editor/browser-provider.md +2 -2
- package/.docs/reference/editor/filesystem-provider.md +1 -1
- package/.docs/reference/editor/mastra-editor.md +31 -18
- package/.docs/reference/editor/prompt-blocks.md +137 -0
- package/.docs/reference/editor/sandbox-provider.md +1 -1
- package/.docs/reference/editor/storage-browser-ref.md +3 -3
- package/.docs/reference/editor/storage-workspace-ref.md +3 -3
- package/.docs/reference/editor/tool-provider.md +44 -10
- package/.docs/reference/editor/tools.md +100 -0
- package/.docs/reference/editor/versioning.md +130 -0
- package/.docs/reference/evals/mastra-scorer.md +68 -8
- package/.docs/reference/evals/summarization.md +203 -0
- package/.docs/reference/file-based-agents/config.md +39 -1
- package/.docs/reference/index.md +4 -4
- package/.docs/reference/memory/observational-memory.md +76 -24
- package/.docs/reference/memory/serialized-memory-config.md +3 -3
- package/.docs/reference/observability/tracing/interfaces.md +6 -1
- package/.docs/reference/processors/processor-interface.md +14 -2
- package/.docs/reference/processors/regex-filter-processor.md +1 -1
- package/.docs/reference/processors/token-limiter-processor.md +15 -1
- package/.docs/reference/project-structure.md +1 -1
- package/.docs/reference/rag/database-config.md +1 -1
- package/.docs/reference/storage/composite.md +2 -0
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/tools/isolated-vm-transport.md +1 -1
- package/.docs/reference/vectors/mongodb.md +13 -13
- package/.docs/reference/voice/livekit.md +3 -3
- package/.docs/reference/workers/overview.md +10 -8
- package/.docs/reference/workspace/platform-filesystem.md +8 -5
- package/.docs/reference/workspace/platform-sandbox.md +83 -7
- package/CHANGELOG.md +51 -0
- package/README.md +1 -1
- package/package.json +5 -5
- package/.docs/docs/agent-builder/access-control.md +0 -99
- package/.docs/docs/agent-builder/browser.md +0 -63
- package/.docs/docs/agent-builder/channels.md +0 -78
- package/.docs/docs/agent-builder/configuration.md +0 -132
- package/.docs/docs/agent-builder/deploying.md +0 -124
- package/.docs/docs/agent-builder/integrations.md +0 -115
- package/.docs/docs/agent-builder/memory.md +0 -69
- package/.docs/docs/agent-builder/model-policy.md +0 -50
- package/.docs/docs/agent-builder/overview.md +0 -114
- package/.docs/docs/agent-builder/skill-registries.md +0 -31
- package/.docs/docs/agent-builder/workspace.md +0 -62
- package/.docs/docs/editor/prompts.md +0 -140
- package/.docs/docs/editor/tools.md +0 -148
- package/.docs/docs/getting-started/file-based-agents.md +0 -121
- package/.docs/docs/mastra-platform/workspace.md +0 -111
- package/.docs/docs/what-is-mastra.md +0 -161
- package/.docs/reference/client-js/agent-builder.md +0 -163
- package/.docs/reference/editor/agent-builder/agent-builder-options.md +0 -76
- package/.docs/reference/editor/agent-builder/builder-agent-defaults.md +0 -79
- package/.docs/reference/editor/agent-builder/builder-models.md +0 -66
- /package/.docs/{docs → guides}/getting-started/manual-install.md +0 -0
- /package/.docs/{docs → guides}/rag/vector-databases.md +0 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Develop
|
|
4
|
+
|
|
5
|
+
Once you have a Mastra project, you're ready to develop, run, and test your agent.
|
|
6
|
+
|
|
7
|
+
## Run Mastra locally
|
|
8
|
+
|
|
9
|
+
The fastest way to see your agent working is in [Mastra Studio](https://mastra.ai/docs/studio/overview). From your project root, start Studio and the local development server with [`mastra dev`](https://mastra.ai/reference/cli/mastra):
|
|
10
|
+
|
|
11
|
+
**npm**:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx mastra dev
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**pnpm**:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm dlx mastra dev
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Yarn**:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
yarn dlx mastra dev
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Bun**:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
bun x mastra dev
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Open Studio at [`http://localhost:4111`](http://localhost:4111) to test your agent and inspect its runs.
|
|
36
|
+
|
|
37
|
+
The development server also exposes APIs for your agents, tools, and workflows. Open [`http://localhost:4111/api`](http://localhost:4111/api) to browse what's available, then connect your frontend using the [Mastra Client](https://mastra.ai/docs/server/mastra-client).
|
|
38
|
+
|
|
39
|
+
Changes in your `src/mastra/` directory automatically restart the development server, so you don't need to restart it manually as you build.
|
|
40
|
+
|
|
41
|
+
## Build with AI
|
|
42
|
+
|
|
43
|
+
Mastra provides a skill and a CLI to help your coding agent write high-quality Mastra code.
|
|
44
|
+
|
|
45
|
+
### Mastra skill
|
|
46
|
+
|
|
47
|
+
AI models may not have up-to-date knowledge of Mastra's APIs. Use the [Mastra skill](https://github.com/mastra-ai/skills) to give your coding agent implementation guidance, best practices, and instructions for fetching the latest Mastra documentation.
|
|
48
|
+
|
|
49
|
+
Install the skill manually with:
|
|
50
|
+
|
|
51
|
+
**npm**:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx skills add mastra-ai/skills
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**pnpm**:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pnpm dlx skills add mastra-ai/skills
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Yarn**:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
yarn dlx skills add mastra-ai/skills
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Bun**:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
bun x skills add mastra-ai/skills
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Periodically update the skill to get the latest guidance:
|
|
76
|
+
|
|
77
|
+
**npm**:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npx skills update mastra
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**pnpm**:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pnpm dlx skills update mastra
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Yarn**:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
yarn dlx skills update mastra
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Bun**:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
bun x skills update mastra
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
> **Note:** When you create a project with [create mastra](https://mastra.ai/docs), the command automatically installs the Mastra skill so your coding agent can discover and use it.
|
|
102
|
+
|
|
103
|
+
### Mastra CLI
|
|
104
|
+
|
|
105
|
+
Use the [`mastra` CLI](https://mastra.ai/reference/cli/mastra) to give your coding agent a feedback loop for testing updates and inspecting results. The CLI gives it access to agents, workflows, tools, memory, evals, traces, and logs.
|
|
106
|
+
|
|
107
|
+
For example, your coding agent can run an agent, then pull traces to inspect the results:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
npx mastra api --url http://localhost:4111 agent run agent '{"messages":"Hello"}'
|
|
111
|
+
npx mastra api --url http://localhost:4111 trace list
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Remember to install the [Mastra skill](#mastra-skill) to teach your coding agent how to use the CLI.
|
|
115
|
+
|
|
116
|
+
## Project structure
|
|
117
|
+
|
|
118
|
+
One of the first decisions when adopting a framework is how to structure the project. We recommend keeping framework code under `src/mastra/`, with related primitives grouped into their own files or folders. Use `src/mastra/index.ts` as the central place to configure and register them.
|
|
119
|
+
|
|
120
|
+
A minimal project can look like this:
|
|
121
|
+
|
|
122
|
+
```text
|
|
123
|
+
src/
|
|
124
|
+
mastra/
|
|
125
|
+
agents/
|
|
126
|
+
agent.ts
|
|
127
|
+
tools/
|
|
128
|
+
tool.ts
|
|
129
|
+
workflows/
|
|
130
|
+
workflow.ts
|
|
131
|
+
scorers/
|
|
132
|
+
scorer.ts
|
|
133
|
+
skills.ts
|
|
134
|
+
index.ts
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
See the [project structure reference](https://mastra.ai/reference/project-structure) for the default layout and recommended conventions.
|
|
138
|
+
|
|
139
|
+
## File-based agents
|
|
140
|
+
|
|
141
|
+
> **Beta:** File-based agents are in beta and may change before they're stable.
|
|
142
|
+
|
|
143
|
+
> **📹 Watch:** [How to create your first file-based agent](https://www.youtube.com/watch?v=5Kfn-oYkJNg\&t=18s)
|
|
144
|
+
|
|
145
|
+
With file-based agents, Mastra automatically [discovers](https://mastra.ai/reference/file-based-agents/config) agents and related primitives from supported files under `src/mastra/`. You organize those files by convention instead of importing and registering each primitive on your [`Mastra`](https://mastra.ai/reference/core/mastra-class) instance.
|
|
146
|
+
|
|
147
|
+
The file system becomes a direct representation of your project structure, so you and your coding agent can understand how the project fits together without tracing how everything is wired together in code.
|
|
148
|
+
|
|
149
|
+
You can use file-based agents throughout your project or adopt them incrementally alongside primitives defined in code. Not every Mastra feature or use case is supported yet.
|
|
150
|
+
|
|
151
|
+
### Create your first agent
|
|
152
|
+
|
|
153
|
+
A file-based agent lives in its own directory under `src/mastra/agents/`. To create a working agent, add a `config.ts` file for its model and runtime options and an `instructions.md` file for its always-on prompt:
|
|
154
|
+
|
|
155
|
+
```text
|
|
156
|
+
src/mastra/agents/
|
|
157
|
+
writing-assistant/
|
|
158
|
+
config.ts
|
|
159
|
+
instructions.md
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The directory name becomes the agent's default `id` and `name`. In this example, Mastra registers the agent as `writing-assistant`.
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
import { agentConfig } from '@mastra/core/agent'
|
|
166
|
+
|
|
167
|
+
export default agentConfig({
|
|
168
|
+
model: 'openai/gpt-5.6-sol',
|
|
169
|
+
})
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
```markdown
|
|
173
|
+
Rewrite text clearly and concisely.
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Run `npx mastra dev`, open Studio, and select `writing-assistant` to test it.
|
|
177
|
+
|
|
178
|
+
### How discovery works
|
|
179
|
+
|
|
180
|
+
Mastra uses paths to discover and name file-based capabilities. An agent directory supplies the default agent `id` and `name`. For example, `tools/search_docs.ts` registers a tool as `search_docs`, while `skills/style-guide.md` registers a skill as `style-guide`. See the extension paths below.
|
|
181
|
+
|
|
182
|
+
### Extend your agent
|
|
183
|
+
|
|
184
|
+
Add files or directories when your agent needs more functionality:
|
|
185
|
+
|
|
186
|
+
| Path | What it adds |
|
|
187
|
+
| ------------------------------------------------------------------------------------------ | ------------------------------------------------- |
|
|
188
|
+
| [`tools/<tool-name>.ts`](https://mastra.ai/reference/file-based-agents/tools) | Functions the model can call |
|
|
189
|
+
| [`skills/<skill-name>.md`](https://mastra.ai/reference/file-based-agents/skills) | Detailed guidance the agent loads when relevant |
|
|
190
|
+
| [`memory.ts`](https://mastra.ai/reference/file-based-agents/memory) | Conversation history and working context |
|
|
191
|
+
| [`workspace.ts` and `workspace/`](https://mastra.ai/reference/file-based-agents/workspace) | Filesystem and shell access |
|
|
192
|
+
| [`subagents/<agent-id>/`](https://mastra.ai/reference/file-based-agents/subagents) | Specialist agents that the parent can delegate to |
|
|
193
|
+
|
|
194
|
+
Keep each capability next to the agent that uses it. Mastra discovers and registers these files when the development server starts or restarts.
|
|
195
|
+
|
|
196
|
+
Browse the [file-based agents reference](https://mastra.ai/reference/file-based-agents/config) for all supported file conventions and configuration options.
|
package/.docs/docs/index.md
CHANGED
|
@@ -166,4 +166,81 @@ For other frameworks, see the [framework integration guides](https://mastra.ai/g
|
|
|
166
166
|
|
|
167
167
|
Browse [templates](https://mastra.ai/templates) for complete Mastra projects you can clone and adapt.
|
|
168
168
|
|
|
169
|
-
|
|
169
|
+
## Use cases
|
|
170
|
+
|
|
171
|
+
<details>
|
|
172
|
+
**Embed agents in your product**
|
|
173
|
+
|
|
174
|
+
Add AI capabilities to your platform so your users can build or interact with agents.
|
|
175
|
+
|
|
176
|
+
Used by [Replit](https://mastra.ai/blog/replitagent3), [Fireworks](https://mastra.ai/blog/fireworks-xml-prompting), [Medusa](https://mastra.ai/blog/medusa-ecommerce)
|
|
177
|
+
|
|
178
|
+
</details>
|
|
179
|
+
|
|
180
|
+
<details>
|
|
181
|
+
**Customer-facing assistants**
|
|
182
|
+
|
|
183
|
+
Build agents that handle inquiries, schedule appointments, send reminders, and answer questions via chat, WhatsApp, or voice.
|
|
184
|
+
|
|
185
|
+
Used by [Vetnio](https://mastra.ai/blog/vetnio), [Lua](https://mastra.ai/blog/lua-scaling)
|
|
186
|
+
|
|
187
|
+
Templates: [Docs Chatbot](https://mastra.ai/templates/docs-chatbot), [Slack Agent](https://mastra.ai/templates/slack-agent)
|
|
188
|
+
|
|
189
|
+
</details>
|
|
190
|
+
|
|
191
|
+
<details>
|
|
192
|
+
**Internal copilots**
|
|
193
|
+
|
|
194
|
+
Help employees work faster with AI that understands your domain, such as HR queries, clinical documentation, sales prep, or document generation.
|
|
195
|
+
|
|
196
|
+
Used by [Factorial](https://mastra.ai/blog/factorial-case-study), [Counsel Health](https://mastra.ai/blog/counsel-health), [Cedar](https://mastra.ai/blog/cedar-case-study), [SoftBank](https://mastra.ai/blog/softbank-productivity-mastra-2025-08-20)
|
|
197
|
+
|
|
198
|
+
Templates: [Chat with PDF](https://mastra.ai/templates/chat-with-pdf), [Google Sheet Analysis](https://mastra.ai/templates/google-sheets-analysis)
|
|
199
|
+
|
|
200
|
+
</details>
|
|
201
|
+
|
|
202
|
+
<details>
|
|
203
|
+
**Data analysis agents**
|
|
204
|
+
|
|
205
|
+
Let users query databases and dashboards in natural language. Connect to your data sources and return answers, charts, or reports.
|
|
206
|
+
|
|
207
|
+
Used by [Index](https://mastra.ai/blog/index-case-study), [PLAID Japan](https://mastra.ai/blog/plaid-jpn-gcp-agents)
|
|
208
|
+
|
|
209
|
+
Templates: [Chat with Database](https://mastra.ai/templates/text-to-sql), [CSV to Questions](https://mastra.ai/templates/csv-to-questions)
|
|
210
|
+
|
|
211
|
+
</details>
|
|
212
|
+
|
|
213
|
+
<details>
|
|
214
|
+
**Content automation**
|
|
215
|
+
|
|
216
|
+
Generate, transform, and manage structured content at scale for a content management system, knowledge base, or documentation system.
|
|
217
|
+
|
|
218
|
+
Used by [Sanity](https://mastra.ai/blog/sanity)
|
|
219
|
+
|
|
220
|
+
Templates: [Chat with YouTube](https://mastra.ai/templates/chat-with-youtube), [Flash Cards from PDF](https://mastra.ai/templates/flash-cards-from-pdf)
|
|
221
|
+
|
|
222
|
+
</details>
|
|
223
|
+
|
|
224
|
+
<details>
|
|
225
|
+
**DevOps and engineering automation**
|
|
226
|
+
|
|
227
|
+
Automate deployments, debug production issues, manage infrastructure, and handle on-call workflows.
|
|
228
|
+
|
|
229
|
+
Used by [StarSling](https://mastra.ai/blog/starsling)
|
|
230
|
+
|
|
231
|
+
Templates: [GitHub PR Code Review](https://mastra.ai/templates/github-pr-code-review-agent), [Browser Agent](https://mastra.ai/templates/browsing-agent)
|
|
232
|
+
|
|
233
|
+
</details>
|
|
234
|
+
|
|
235
|
+
<details>
|
|
236
|
+
**Sales and go-to-market workflows**
|
|
237
|
+
|
|
238
|
+
Turn customer conversations into structured tasks, generate investment memos, or automate outreach sequences.
|
|
239
|
+
|
|
240
|
+
Used by [Kestral](https://mastra.ai/blog/kestral), [Orange Collective](https://mastra.ai/blog/orange-collective-vc-operating-system), [WorkOS](https://mastra.ai/blog/workos-teaching-mastra)
|
|
241
|
+
|
|
242
|
+
Templates: [Customer Feedback Summarization](https://mastra.ai/templates/customer-feedback-summarization)
|
|
243
|
+
|
|
244
|
+
</details>
|
|
245
|
+
|
|
246
|
+
> **Video:** [A quick tour of the Mastra platform](https://www.youtube.com/watch?v=NosES9aJxCc) shows how the pieces fit together.
|
|
@@ -245,7 +245,7 @@ On startup, this discovers every registered durable agent with runs stuck in `ru
|
|
|
245
245
|
|
|
246
246
|
### Manual recovery
|
|
247
247
|
|
|
248
|
-
If you need finer control
|
|
248
|
+
If you need finer control, such as gating recovery behind a leader election or running it on a schedule, call the methods directly:
|
|
249
249
|
|
|
250
250
|
```typescript
|
|
251
251
|
// Recover all durable agents
|
|
@@ -261,7 +261,7 @@ await durableAgent.recoverActiveRuns({ runId: 'run-abc-123' })
|
|
|
261
261
|
|
|
262
262
|
### Multi-instance deployments
|
|
263
263
|
|
|
264
|
-
|
|
264
|
+
Mastra doesn't provide a distributed lease or lock yet. In multi-replica deployments, every replica that starts with `recovery.durableAgents: 'auto'` will race to recover the same runs. For now, either gate recovery behind your own leader election or run it from a single replica.
|
|
265
265
|
|
|
266
266
|
## Related
|
|
267
267
|
|
|
@@ -10,7 +10,7 @@ The [Mastra platform](https://projects.mastra.ai) provides three products for de
|
|
|
10
10
|
|
|
11
11
|
Deploy with a single command, [`mastra deploy`](https://mastra.ai/docs/mastra-platform/deploy), or connect a GitHub repository for push-to-deploy. See the [GitHub integration](https://mastra.ai/docs/mastra-platform/github) for the repository-linked flow.
|
|
12
12
|
|
|
13
|
-
Each project can run multiple [**Environments**](https://mastra.ai/docs/mastra-platform/environments) (for example `production` and `staging`), provision [**Hosted databases**](https://mastra.ai/docs/mastra-platform/database) from the CLI or project settings to persist application data, and get a managed [**
|
|
13
|
+
Each project can run multiple [**Environments**](https://mastra.ai/docs/mastra-platform/environments) (for example `production` and `staging`), provision [**Hosted databases**](https://mastra.ai/docs/mastra-platform/database) from the CLI or project settings to persist application data, and get a managed [**Workspaces**](https://mastra.ai/docs/mastra-platform/workspaces) per environment that gives agents a filesystem and a sandbox with no manual configuration.
|
|
14
14
|
|
|
15
15
|
[**Trace Intelligence**](https://mastra.ai/docs/mastra-platform/trace-intelligence) finds recurring goals, outcomes, behaviors, and sentiment across your agent traces. Trace Intelligence is available in private beta for selected projects.
|
|
16
16
|
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Workspaces
|
|
4
|
+
|
|
5
|
+
A workspace is a set of runtime resources the Mastra platform provisions and hands to your agents at deploy time. Each environment gets its own workspace so `production` and `staging` stay isolated.
|
|
6
|
+
|
|
7
|
+
Every workspace exposes two capabilities:
|
|
8
|
+
|
|
9
|
+
- One **bucket** for filesystem storage, wrapped by [`PlatformFilesystem`](https://mastra.ai/reference/workspace/platform-filesystem). The bucket is a durable, environment-scoped store agents read from and write to across runs.
|
|
10
|
+
- A pool of **on-demand sandboxes** for command execution, wrapped by [`PlatformSandbox`](https://mastra.ai/reference/workspace/platform-sandbox). Each `PlatformSandbox` instance provisions its own remote sandbox on `start()` and destroys it on `destroy()`. Agents typically spin up many sandboxes per session, use them for a task, and let them go.
|
|
11
|
+
|
|
12
|
+
Workspaces are scoped to a single [environment](https://mastra.ai/docs/mastra-platform/environments), so `production` and `staging` don't share buckets or sandbox pools. The platform manages provisioning, authentication, and idle cleanup.
|
|
13
|
+
|
|
14
|
+
## When workspaces are provisioned
|
|
15
|
+
|
|
16
|
+
New projects have workspaces enabled by default. When you create an environment, the platform provisions a bucket for it automatically. The sandbox base image is warmed in the background so the first `PlatformSandbox` call starts quickly.
|
|
17
|
+
|
|
18
|
+
Existing projects that haven't opted in show an **Enable workspaces** action in the Workspaces tab. Enabling provisions a bucket for every environment on the project.
|
|
19
|
+
|
|
20
|
+
If provisioning fails for an environment, for example while the sandbox provider is under load, the Workspaces tab shows the failure and offers a retry. The environment itself is still created. Only the workspace is unavailable until you retry.
|
|
21
|
+
|
|
22
|
+
## Use the workspace from your code
|
|
23
|
+
|
|
24
|
+
Install the provider package:
|
|
25
|
+
|
|
26
|
+
**npm**:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install @mastra/platform-workspace
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**pnpm**:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pnpm add @mastra/platform-workspace
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Yarn**:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
yarn add @mastra/platform-workspace
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Bun**:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
bun add @mastra/platform-workspace
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Compose the providers into a workspace and register it with Mastra:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { Workspace } from '@mastra/core/workspace'
|
|
54
|
+
import { PlatformFilesystem, PlatformSandbox } from '@mastra/platform-workspace'
|
|
55
|
+
|
|
56
|
+
export const workspace = new Workspace({
|
|
57
|
+
filesystem: new PlatformFilesystem(),
|
|
58
|
+
sandbox: new PlatformSandbox(),
|
|
59
|
+
})
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { Mastra } from '@mastra/core'
|
|
64
|
+
import { workspace } from './workspace'
|
|
65
|
+
|
|
66
|
+
export const mastra = new Mastra({
|
|
67
|
+
workspace,
|
|
68
|
+
})
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`PlatformFilesystem` and `PlatformSandbox` read their configuration from environment variables, so you don't pass any options on the platform. The platform injects them at deploy time. See [Environment variables](#environment-variables).
|
|
72
|
+
|
|
73
|
+
## One bucket, many sandboxes
|
|
74
|
+
|
|
75
|
+
`PlatformFilesystem` and `PlatformSandbox` have different lifecycles, which matters when you design agents.
|
|
76
|
+
|
|
77
|
+
**`PlatformFilesystem` is a long-lived handle to the environment's bucket.** All requests, all agents, and all sandboxes in the environment read and write the same object storage. Anything an agent writes is visible on the next request unless you explicitly delete it.
|
|
78
|
+
|
|
79
|
+
**`PlatformSandbox` is a client for provisioning ephemeral sandboxes.** Each `PlatformSandbox` instance owns one remote sandbox:
|
|
80
|
+
|
|
81
|
+
- `start()` provisions a fresh sandbox (or reattaches when you passed `sandboxId`).
|
|
82
|
+
- `executeCommand()` runs commands against it.
|
|
83
|
+
- `destroy()` tears the sandbox down. `stop()` is an alias.
|
|
84
|
+
|
|
85
|
+
The `sandbox` you pass to `Workspace` provides the tools an agent uses inside its own request. When your agent needs another isolated environment, for example a per-task workspace, a per-user tenant, or a background job that shouldn't touch the caller's shell state, construct another `PlatformSandbox`:
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { PlatformSandbox } from '@mastra/platform-workspace'
|
|
89
|
+
|
|
90
|
+
export async function runInFreshSandbox(command: string) {
|
|
91
|
+
const sandbox = new PlatformSandbox()
|
|
92
|
+
await sandbox.start()
|
|
93
|
+
try {
|
|
94
|
+
return await sandbox.executeCommand(command)
|
|
95
|
+
} finally {
|
|
96
|
+
await sandbox.destroy()
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Or clone a configured sandbox as the template for a fleet, so the clones inherit credentials, environment, network isolation, and defaults without repeating them:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
const template = new PlatformSandbox({ networkIsolation: 'PRIVATE' })
|
|
105
|
+
|
|
106
|
+
const perProjectSandbox = template.clone({ id: `project-${projectId}` })
|
|
107
|
+
await perProjectSandbox.start()
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
See [`PlatformSandbox` reference](https://mastra.ai/reference/workspace/platform-sandbox) for the full lifecycle, checkpoint recovery, reattachment, and clone options.
|
|
111
|
+
|
|
112
|
+
## Environment variables
|
|
113
|
+
|
|
114
|
+
Every deploy that runs on a platform environment with a workspace receives these variables automatically:
|
|
115
|
+
|
|
116
|
+
| Variable | Contents |
|
|
117
|
+
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
118
|
+
| `MASTRA_PLATFORM_ACCESS_TOKEN` | Platform-issued JSON Web Token (JWT) the workspace providers use to authenticate. The token is scoped to the deploy's organization and project. |
|
|
119
|
+
| `MASTRA_PROJECT_ID` | Project the deploy belongs to. |
|
|
120
|
+
| `MASTRA_ENVIRONMENT_ID` | Environment the deploy belongs to. Selects which sandbox pool the platform uses. |
|
|
121
|
+
| `MASTRA_PLATFORM_BUCKET_NAME` | Bucket name attached to the environment. Selects which bucket `PlatformFilesystem` reads and writes. |
|
|
122
|
+
|
|
123
|
+
These names are reserved. If your project sets any of them explicitly, the platform-managed values take precedence.
|
|
124
|
+
|
|
125
|
+
## Local development
|
|
126
|
+
|
|
127
|
+
Reuse the same providers locally by putting the four variables in your `.env` file. Get the project, environment, and bucket values from your project's **Workspaces** tab. For `MASTRA_PLATFORM_ACCESS_TOKEN`, create an `sk_` API token on your organization's settings page under **API Tokens**. Platform deploys use an injected JWT instead.
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
MASTRA_PLATFORM_ACCESS_TOKEN=sk_your-api-token
|
|
131
|
+
MASTRA_PROJECT_ID=your-project-id
|
|
132
|
+
MASTRA_ENVIRONMENT_ID=your-environment-id
|
|
133
|
+
MASTRA_PLATFORM_BUCKET_NAME=your-bucket-name
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
`PlatformFilesystem` and `PlatformSandbox` behave the same locally as on the platform, they connect to the same bucket and sandbox pool for that environment. Use a `staging` or `preview` environment's variables for local runs if you want to keep production data isolated.
|
|
137
|
+
|
|
138
|
+
For a purely offline loop that never touches the platform, swap the providers for [`LocalFilesystem`](https://mastra.ai/reference/workspace/local-filesystem) and [`LocalSandbox`](https://mastra.ai/reference/workspace/local-sandbox) in a local build.
|
|
139
|
+
|
|
140
|
+
## Inspect the workspace
|
|
141
|
+
|
|
142
|
+
The Workspaces tab in your platform project shows, per environment:
|
|
143
|
+
|
|
144
|
+
- Bucket status and its contents, with upload, download, and delete actions.
|
|
145
|
+
- Recent sandbox sessions with their command, exit code, and duration.
|
|
146
|
+
- Provisioning failures with a **Retry** action.
|
|
147
|
+
|
|
148
|
+
## See also
|
|
149
|
+
|
|
150
|
+
- [`PlatformFilesystem`](https://mastra.ai/reference/workspace/platform-filesystem): reference for the filesystem provider.
|
|
151
|
+
- [`PlatformSandbox`](https://mastra.ai/reference/workspace/platform-sandbox): reference for the sandbox provider, including checkpoint recovery and cloning.
|
|
152
|
+
- [Environments](https://mastra.ai/docs/mastra-platform/environments): how environments scope workspaces, variables, and databases.
|
|
@@ -94,7 +94,7 @@ See [configuration options](https://mastra.ai/reference/memory/observational-mem
|
|
|
94
94
|
>
|
|
95
95
|
> For an AI SDK example, see [Using Mastra Memory](https://mastra.ai/guides/build-your-ui/ai-sdk-ui).
|
|
96
96
|
|
|
97
|
-
> **Note:** OM currently only supports `@mastra/pg`, `@mastra/libsql`, `@mastra/mongodb`, and `@mastra/convex` storage adapters. It uses background agents for managing memory. When no model is set, the default model is `google/gemini-2.5-flash`.
|
|
97
|
+
> **Note:** OM currently only supports `@mastra/pg`, `@mastra/libsql`, `@mastra/mysql`, `@mastra/mongodb`, and `@mastra/convex` storage adapters. It uses background agents for managing memory. When no model is set, the default model is `google/gemini-2.5-flash`.
|
|
98
98
|
|
|
99
99
|
## Temporal gap markers
|
|
100
100
|
|
|
@@ -378,7 +378,7 @@ new Agent({
|
|
|
378
378
|
})
|
|
379
379
|
```
|
|
380
380
|
|
|
381
|
-
You can also pass an allowlist of mimeType globs (for example `['image/*']`) to forward only the kinds the Observer can handle.
|
|
381
|
+
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'` to let Mastra decide from the provider capabilities registry: attachments are forwarded when the Observer model supports multimodal input and dropped otherwise, falling back to `true` when no capability data is available for the model.
|
|
382
382
|
|
|
383
383
|
```md
|
|
384
384
|
Date: 2026-01-15
|
|
@@ -399,12 +399,29 @@ Example: An agent using Playwright MCP might see 50,000+ tokens per page snapsho
|
|
|
399
399
|
|
|
400
400
|
When observations exceed their threshold (default: 40,000 tokens), the Reflector condenses them and combines related items, plus reflects on patterns.
|
|
401
401
|
|
|
402
|
+
Reflections don't accumulate as a separate, ever-growing layer. Each reflection rewrites the entire observation log. The Reflector's output becomes the new log, and new observations append after it. When the log next hits the threshold, the Reflector re-processes everything, including earlier reflections. It condenses older information more aggressively while keeping recent detail. Memory stays bounded around the reflection threshold no matter how long the conversation runs.
|
|
403
|
+
|
|
402
404
|
The result is a three-tier system:
|
|
403
405
|
|
|
404
406
|
1. **Recent messages**: Exact conversation history for the current task
|
|
405
407
|
2. **Observations**: A log of what the Observer has seen
|
|
406
408
|
3. **Reflections**: Condensed observations when memory becomes too long
|
|
407
409
|
|
|
410
|
+
### How context changes over time
|
|
411
|
+
|
|
412
|
+
With default settings, the context window doesn't grow unbounded. It oscillates through an observe-and-shrink cycle:
|
|
413
|
+
|
|
414
|
+

|
|
415
|
+
|
|
416
|
+
1. **0 → 30k tokens**: Message history grows normally. In the background, the Observer buffers observations every \~6k tokens (`bufferTokens: 0.2`).
|
|
417
|
+
2. **30k reached**: Buffered observations activate instantly. Observed messages are removed from the context window and only \~6k tokens of recent history remain (`bufferActivation: 0.8` retains 20% of the threshold). The \~24k tokens of removed messages become roughly 1-5k tokens of observations at typical 5-40x compression.
|
|
418
|
+
3. **Repeat**: History grows from \~6k back toward 30k and shrinks again. Each cycle appends to the observation log, which grows much more slowly than raw history.
|
|
419
|
+
4. **Observations reach 40k**: The Reflector creates a smaller log from the current observations and any earlier reflections.
|
|
420
|
+
|
|
421
|
+
In the normal buffered cycle, raw history oscillates between roughly 6k and 30k tokens. The observation log stays around 40k tokens, however long the conversation runs. These are activation thresholds rather than hard caps. If background buffering doesn't keep pace, history can grow past the threshold until `blockAfter` (default `1.2`) forces a synchronous observation at \~36k tokens (\~48k for reflection) as a safety ceiling.
|
|
422
|
+
|
|
423
|
+
With [`shareTokenBudget`](https://mastra.ai/reference/memory/observational-memory) enabled, the two budgets pool together. While the observation log is small, message history can expand into the unused observation space (up to \~70k tokens with the defaults) before observation triggers. It then shrinks as observations accumulate.
|
|
424
|
+
|
|
408
425
|
### Retrieval mode
|
|
409
426
|
|
|
410
427
|
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. When the agent needs exact wording, tool output, or chronology that the summary compressed away, it can call a `recall` tool to page through the source messages.
|
|
@@ -459,6 +476,29 @@ const memory = new Memory({
|
|
|
459
476
|
})
|
|
460
477
|
```
|
|
461
478
|
|
|
479
|
+
#### Custom recall guidance
|
|
480
|
+
|
|
481
|
+
Mastra injects scope-aware instructions that teach the agent when to search, list threads, or read a specific thread. Use `instructions` to append application-specific guidance after those built-in instructions. The built-in instructions are never replaced:
|
|
482
|
+
|
|
483
|
+
```typescript
|
|
484
|
+
const memory = new Memory({
|
|
485
|
+
options: {
|
|
486
|
+
observationalMemory: {
|
|
487
|
+
model: 'google/gemini-2.5-flash',
|
|
488
|
+
retrieval: {
|
|
489
|
+
vector: true,
|
|
490
|
+
instructions: `
|
|
491
|
+
Prefer the current conversation when it already contains the answer.
|
|
492
|
+
For an initial scan, use a small limit with detail="low".
|
|
493
|
+
`,
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
},
|
|
497
|
+
})
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
This keeps recall-specific guidance attached to the recall tool instead of the agent's global instructions, so it doesn't affect unrelated tasks.
|
|
501
|
+
|
|
462
502
|
#### What retrieval enables
|
|
463
503
|
|
|
464
504
|
With retrieval mode enabled, OM:
|
|
@@ -684,7 +724,7 @@ Reflection works similarly, the Reflector runs in the background when observatio
|
|
|
684
724
|
| ------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
685
725
|
| `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`). |
|
|
686
726
|
| `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. |
|
|
687
|
-
| `observation.blockAfter` | `1.2` | Safety
|
|
727
|
+
| `observation.blockAfter` | `1.2` | Safety net if buffering can't keep up. Values from 1 up to (but not including) 100 multiply `messageTokens`: at `1.2`, synchronous observation is forced at 36k tokens (1.2 × 30k). Values of 100 or more are absolute token counts (e.g. `50_000`). |
|
|
688
728
|
| `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. |
|
|
689
729
|
| `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. |
|
|
690
730
|
| `reflection.bufferActivation` | `0.5` | When to start background reflection. `0.5` means reflection begins when observations reach 50% of the `observationTokens` threshold. |
|
|
@@ -696,16 +736,16 @@ If you're relying on prompt caching, set `activateAfterIdle` to `"auto"` or to a
|
|
|
696
736
|
|
|
697
737
|
With `"auto"`, Mastra chooses an idle activation TTL from the active model provider:
|
|
698
738
|
|
|
699
|
-
| Provider
|
|
700
|
-
|
|
|
701
|
-
| Anthropic, OpenRouter, unknown providers, xAI
|
|
702
|
-
| DeepSeek
|
|
703
|
-
| Google Gemini
|
|
704
|
-
| Groq
|
|
705
|
-
| OpenAI with `providerOptions.openai.promptCacheRetention: "24h"`
|
|
706
|
-
| OpenAI with `providerOptions.openai.promptCacheRetention: "in_memory"`
|
|
707
|
-
| OpenAI `gpt-4*`, `gpt-5`, `gpt-5-*`, `gpt-5.1
|
|
708
|
-
| Other OpenAI models
|
|
739
|
+
| Provider | Auto TTL |
|
|
740
|
+
| ------------------------------------------------------------------------------------------------------ | --------- |
|
|
741
|
+
| Anthropic, OpenRouter, unknown providers, xAI | 5 minutes |
|
|
742
|
+
| DeepSeek | 1 hour |
|
|
743
|
+
| Google Gemini | 24 hours |
|
|
744
|
+
| Groq | 2 hours |
|
|
745
|
+
| OpenAI with `providerOptions.openai.promptCacheRetention: "24h"` | 1 hour |
|
|
746
|
+
| OpenAI with `providerOptions.openai.promptCacheRetention: "in_memory"` | 5 minutes |
|
|
747
|
+
| OpenAI `gpt-4*`, `gpt-5`, `gpt-5-*`, and `gpt-5.1` through `gpt-5.4` (including `-` suffixed variants) | 5 minutes |
|
|
748
|
+
| Other OpenAI models | 1 hour |
|
|
709
749
|
|
|
710
750
|
```typescript
|
|
711
751
|
const memory = new Memory({
|
|
@@ -172,6 +172,20 @@ export const memoryAgent = new Agent({
|
|
|
172
172
|
|
|
173
173
|
See [Observational Memory](https://mastra.ai/docs/memory/observational-memory) for details on how observations and reflections work, and [the reference](https://mastra.ai/reference/memory/observational-memory) for all configuration options.
|
|
174
174
|
|
|
175
|
+
## What the model sees
|
|
176
|
+
|
|
177
|
+
Each memory feature is added to either the system messages or the conversation messages in the request sent to the model. The layers depend on the features you've enabled. Working memory and semantic recall only appear when configured. The same applies to Observational Memory, while message history is on by default. The diagram shows where each enabled layer is placed in the request. The list below describes what each layer contributes:
|
|
178
|
+
|
|
179
|
+

|
|
180
|
+
|
|
181
|
+
- [Working memory](https://mastra.ai/docs/memory/working-memory) is injected as a system message containing the template and the stored data. With `useStateSignals`, it's delivered as a state signal instead.
|
|
182
|
+
- [Semantic recall](https://mastra.ai/docs/memory/semantic-recall) matches from the current thread are inserted as regular messages and interleave with message history by timestamp. Matches from other threads are formatted into a system message instead.
|
|
183
|
+
- [Message history](https://mastra.ai/docs/memory/message-history) adds the last N messages in chronological order. Your new message always comes last.
|
|
184
|
+
- [Observational Memory](https://mastra.ai/docs/memory/observational-memory) replaces old raw history: reflections and observations live in a system message, and only messages that haven't been observed yet remain in the conversation. A short continuation reminder is placed at the start of the conversation messages.
|
|
185
|
+
- Context messages are the optional `context` array passed on a call, for example `agent.generate(msg, { context: [...] })`. Use them for one-off background such as app state or your own RAG results. They appear as regular conversation messages for that request only and are never saved to memory.
|
|
186
|
+
|
|
187
|
+
Conversation messages are ordered by timestamp and deduplicated by message ID, so recalled older messages appear before recent history. Context messages passed at call time are stamped with the current time, which places them after history and recall but before your new message. To inspect the exact context for a real request, use [Tracing](https://mastra.ai/docs/observability/tracing/overview) and open the LLM call spans, see [Observability](#observability) below.
|
|
188
|
+
|
|
175
189
|
## Memory in multi-agent systems
|
|
176
190
|
|
|
177
191
|
When a [supervisor agent](https://mastra.ai/docs/agents/supervisor-agents) delegates to a subagent, Mastra isolates subagent memory automatically. No flag enables this as it happens on every delegation. Understanding how this scoping works lets you decide what stays private and what to share intentionally.
|
|
@@ -57,7 +57,7 @@ services:
|
|
|
57
57
|
orchestration-worker:
|
|
58
58
|
environment:
|
|
59
59
|
MASTRA_WORKER_AUTH_TOKEN: ${WORKER_TOKEN}
|
|
60
|
-
MASTRA_STEP_EXECUTION_URL: http://api:4111/api
|
|
60
|
+
MASTRA_STEP_EXECUTION_URL: http://api:4111/api # Use HTTPS in production
|
|
61
61
|
# ... other env vars
|
|
62
62
|
```
|
|
63
63
|
|
|
@@ -65,6 +65,8 @@ services:
|
|
|
65
65
|
WORKER_TOKEN=sk-worker-secret-token
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
+
These examples use `http://` for local development. In production, use HTTPS URLs and terminate TLS with a service mesh or ingress controller. See [Security recommendations](#security-recommendations).
|
|
69
|
+
|
|
68
70
|
The orchestration worker reads `MASTRA_WORKER_AUTH_TOKEN` and sends it as a `Bearer` token in the `Authorization` header on every step execution request.
|
|
69
71
|
|
|
70
72
|
## Auth credential types
|
|
@@ -87,7 +89,7 @@ Send the credential as `x-worker-api-key` instead of `Authorization`:
|
|
|
87
89
|
import { HttpRemoteStrategy } from '@mastra/core/worker'
|
|
88
90
|
|
|
89
91
|
const strategy = new HttpRemoteStrategy({
|
|
90
|
-
serverUrl: 'http://api:4111/api',
|
|
92
|
+
serverUrl: 'http://api:4111/api', // Use HTTPS in production
|
|
91
93
|
auth: { type: 'api-key', key: process.env.WORKER_API_KEY! },
|
|
92
94
|
})
|
|
93
95
|
```
|
|
@@ -102,7 +104,7 @@ Use any header name and value:
|
|
|
102
104
|
import { HttpRemoteStrategy } from '@mastra/core/worker'
|
|
103
105
|
|
|
104
106
|
const strategy = new HttpRemoteStrategy({
|
|
105
|
-
serverUrl: 'http://api:4111/api',
|
|
107
|
+
serverUrl: 'http://api:4111/api', // Use HTTPS in production
|
|
106
108
|
auth: {
|
|
107
109
|
type: 'header',
|
|
108
110
|
name: 'X-Internal-Service-Key',
|
|
@@ -111,7 +113,7 @@ const strategy = new HttpRemoteStrategy({
|
|
|
111
113
|
})
|
|
112
114
|
```
|
|
113
115
|
|
|
114
|
-
## Push-mode broker
|
|
116
|
+
## Push-mode broker auth
|
|
115
117
|
|
|
116
118
|
When using a push-mode PubSub (like Google Cloud Pub/Sub), the broker POSTs events directly to the `/api/workflows/events` endpoint. The broker attaches its own credentials. For example, Google Cloud Pub/Sub sends a Google-signed OIDC token.
|
|
117
119
|
|
|
@@ -121,7 +123,7 @@ Your auth provider's `authenticateToken` callback must recognize whatever creden
|
|
|
121
123
|
|
|
122
124
|
- **Use different tokens for different worker types.** This lets you revoke access to one worker without affecting others.
|
|
123
125
|
- **Rotate tokens on a schedule.** Update the `WORKER_TOKEN` environment variable and restart the affected containers.
|
|
124
|
-
- **Use TLS in production.** Worker-to-API communication should go over HTTPS to protect tokens in transit.
|
|
126
|
+
- **Use TLS in production.** Worker-to-API communication should go over HTTPS to protect tokens in transit. This applies to all environments, including Kubernetes clusters and Docker networks. Use a service mesh (e.g., Istio, Linkerd) or TLS-terminating ingress to encrypt internal traffic.
|
|
125
127
|
- **Restrict network access.** The step execution and event endpoints are internal. If possible, keep them off the public internet using network policies or firewall rules.
|
|
126
128
|
|
|
127
129
|
## Related
|