@mastra/mcp-docs-server 1.3.6-alpha.1 → 1.3.6-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.
Files changed (140) hide show
  1. package/.docs/docs/agents/human-in-the-loop.md +5 -3
  2. package/.docs/docs/agents/processors.md +13 -8
  3. package/.docs/docs/agents/tools.md +24 -0
  4. package/.docs/docs/browser.md +0 -2
  5. package/.docs/docs/guides/authentication-identity.md +1 -1
  6. package/.docs/docs/harness/agent-controller.md +29 -0
  7. package/.docs/docs/harness/signals.md +12 -0
  8. package/.docs/docs/memory/memory-processors.md +2 -5
  9. package/.docs/docs/memory/message-history.md +15 -8
  10. package/.docs/docs/memory/observational-memory.md +33 -4
  11. package/.docs/docs/memory/semantic-recall.md +2 -2
  12. package/.docs/docs/memory/working-memory.md +16 -0
  13. package/.docs/docs/observability/tracing/overview.md +1 -1
  14. package/.docs/docs/subagents.md +11 -8
  15. package/.docs/docs/workflows/control-flow.md +1 -1
  16. package/.docs/docs/workflows/time-travel.md +5 -3
  17. package/.docs/integrations/agentic-ui/ai-sdk-ui.md +60 -0
  18. package/.docs/integrations/deploy/temporal.md +23 -0
  19. package/.docs/integrations/sandboxes/docker.md +61 -0
  20. package/.docs/integrations/sandboxes/e2b.md +37 -0
  21. package/.docs/models/embeddings.md +1 -1
  22. package/.docs/models/environment-variables.md +2 -1
  23. package/.docs/models/gateways/merge-gateway.md +4 -1
  24. package/.docs/models/gateways/netlify.md +4 -5
  25. package/.docs/models/gateways/openrouter.md +4 -14
  26. package/.docs/models/gateways/vercel.md +4 -5
  27. package/.docs/models/index.md +3 -2
  28. package/.docs/models/providers/alibaba.md +1 -1
  29. package/.docs/models/providers/ambient.md +17 -15
  30. package/.docs/models/providers/anthropic.md +4 -3
  31. package/.docs/models/providers/berget.md +1 -1
  32. package/.docs/models/providers/cloudflare-workers-ai.md +2 -1
  33. package/.docs/models/providers/coralbricks.md +1 -2
  34. package/.docs/models/providers/cortecs.md +5 -2
  35. package/.docs/models/providers/crossmodel.md +2 -1
  36. package/.docs/models/providers/deepinfra.md +2 -3
  37. package/.docs/models/providers/digitalocean.md +2 -1
  38. package/.docs/models/providers/edenai.md +18 -7
  39. package/.docs/models/providers/huggingface.md +7 -4
  40. package/.docs/models/providers/hyper.md +4 -6
  41. package/.docs/models/providers/kilo.md +37 -46
  42. package/.docs/models/providers/llmgateway-providers.md +10 -2
  43. package/.docs/models/providers/llmgateway.md +4 -2
  44. package/.docs/models/providers/lowrouter.md +84 -0
  45. package/.docs/models/providers/mistral.md +10 -17
  46. package/.docs/models/providers/nano-gpt.md +33 -31
  47. package/.docs/models/providers/neuralwatt.md +3 -1
  48. package/.docs/models/providers/novita-ai.md +43 -66
  49. package/.docs/models/providers/ofox.md +2 -1
  50. package/.docs/models/providers/ollama-cloud.md +2 -1
  51. package/.docs/models/providers/opencode-go.md +7 -5
  52. package/.docs/models/providers/opencode.md +3 -2
  53. package/.docs/models/providers/ovhcloud.md +1 -2
  54. package/.docs/models/providers/requesty.md +7 -4
  55. package/.docs/models/providers/tinfoil.md +1 -2
  56. package/.docs/models/providers/vivgrid.md +2 -1
  57. package/.docs/models/providers.md +2 -1
  58. package/.docs/reference/agent-controller/agent-controller-class.md +15 -1
  59. package/.docs/reference/agent-controller/session.md +17 -6
  60. package/.docs/reference/agents/generate.md +1 -1
  61. package/.docs/reference/agents/inngest-agent.md +1 -1
  62. package/.docs/reference/ai-sdk/to-ai-sdk-v4-messages.md +3 -3
  63. package/.docs/reference/classifier/classifier.md +35 -35
  64. package/.docs/reference/client-js/memory.md +13 -1
  65. package/.docs/reference/coding-agent/create-coding-agent.md +2 -2
  66. package/.docs/reference/configuration.md +2 -2
  67. package/.docs/reference/connect/providers.md +118 -112
  68. package/.docs/reference/core/getClassifier.md +1 -1
  69. package/.docs/reference/datasets/updateItem.md +10 -0
  70. package/.docs/reference/deployer/vercel.md +1 -1
  71. package/.docs/reference/deployer.md +7 -14
  72. package/.docs/reference/editor/blob-store-provider.md +2 -1
  73. package/.docs/reference/editor/browser-provider.md +3 -2
  74. package/.docs/reference/editor/filesystem-provider.md +2 -1
  75. package/.docs/reference/editor/processor-provider.md +2 -2
  76. package/.docs/reference/editor/sandbox-provider.md +2 -1
  77. package/.docs/reference/editor/storage-workspace-ref.md +27 -2
  78. package/.docs/reference/evals/answer-relevancy.md +4 -2
  79. package/.docs/reference/evals/answer-similarity.md +1 -1
  80. package/.docs/reference/evals/bias.md +3 -1
  81. package/.docs/reference/evals/content-similarity.md +1 -1
  82. package/.docs/reference/evals/context-recall.md +1 -1
  83. package/.docs/reference/evals/context-relevance.md +6 -6
  84. package/.docs/reference/evals/create-classifier-scorer.md +5 -5
  85. package/.docs/reference/evals/hallucination.md +7 -8
  86. package/.docs/reference/evals/keyword-coverage.md +4 -4
  87. package/.docs/reference/evals/noise-sensitivity.md +6 -6
  88. package/.docs/reference/evals/prompt-alignment.md +1 -1
  89. package/.docs/reference/evals/run-evals.md +1 -1
  90. package/.docs/reference/evals/scorer-utils.md +8 -8
  91. package/.docs/reference/evals/tone-consistency.md +23 -24
  92. package/.docs/reference/evals/tool-call-accuracy.md +19 -15
  93. package/.docs/reference/evals/toxicity.md +3 -1
  94. package/.docs/reference/index.md +2 -0
  95. package/.docs/reference/logging/pino-logger.md +4 -4
  96. package/.docs/reference/memory/deleteMessages.md +1 -1
  97. package/.docs/reference/memory/memory-class.md +2 -2
  98. package/.docs/reference/memory/observational-memory.md +8 -4
  99. package/.docs/reference/memory/summarizeConversation.md +1 -1
  100. package/.docs/reference/migrations/ai-sdk-v4-to-v5.md +2 -2
  101. package/.docs/reference/migrations/upgrade-to-v1/mcp.md +2 -0
  102. package/.docs/reference/migrations/upgrade-to-v1/memory.md +1 -1
  103. package/.docs/reference/migrations/upgrade-to-v1/tools.md +1 -1
  104. package/.docs/reference/observability/tracing/configuration.md +10 -1
  105. package/.docs/reference/observability/tracing/instances.md +1 -1
  106. package/.docs/reference/observability/tracing/interfaces.md +1 -1
  107. package/.docs/reference/processors/batch-parts-processor.md +1 -1
  108. package/.docs/reference/processors/classifier-processor.md +6 -6
  109. package/.docs/reference/processors/file-upload-processor.md +236 -0
  110. package/.docs/reference/processors/message-history-processor.md +3 -2
  111. package/.docs/reference/processors/model-selection-processor.md +11 -11
  112. package/.docs/reference/processors/processor-interface.md +2 -0
  113. package/.docs/reference/processors/response-cache.md +1 -1
  114. package/.docs/reference/processors/semantic-recall-processor.md +2 -3
  115. package/.docs/reference/processors/stream-error-retry-processor.md +1 -1
  116. package/.docs/reference/processors/unicode-normalizer.md +1 -1
  117. package/.docs/reference/processors/unsupported-file-handler.md +69 -0
  118. package/.docs/reference/processors/working-memory-processor.md +3 -2
  119. package/.docs/reference/project-structure.md +11 -13
  120. package/.docs/reference/pubsub/unix-socket-pubsub.md +6 -2
  121. package/.docs/reference/rag/chunk.md +2 -2
  122. package/.docs/reference/rag/chunking-and-embedding.md +1 -1
  123. package/.docs/reference/rag/database-config.md +14 -2
  124. package/.docs/reference/rag/document.md +7 -2
  125. package/.docs/reference/rag/extract-params.md +5 -5
  126. package/.docs/reference/rag/graph-rag-guide.md +1 -1
  127. package/.docs/reference/rag/metadata-filters.md +1 -1
  128. package/.docs/reference/rag/rerank.md +5 -4
  129. package/.docs/reference/rag/rerankWithScorer.md +2 -2
  130. package/.docs/reference/rag/retrieval.md +7 -5
  131. package/.docs/reference/rag/vector-databases.md +1 -1
  132. package/.docs/reference/server/mastra-server.md +2 -2
  133. package/.docs/reference/streaming/agents/stream.md +1 -1
  134. package/.docs/reference/tools/isolated-vm-transport.md +0 -2
  135. package/.docs/reference/tools/mcp-client.md +5 -0
  136. package/.docs/reference/tools/quickjs-transport.md +0 -2
  137. package/.docs/reference/workflows/run-methods/restart.md +6 -0
  138. package/.docs/reference/workflows/step.md +1 -1
  139. package/.docs/reference/workspace/platform-sandbox.md +36 -2
  140. package/package.json +6 -6
@@ -125,7 +125,7 @@ import { agent } from './agent'
125
125
 
126
126
  const approvalClassifier = new Classifier({
127
127
  id: 'tool-approval-classifier',
128
- model: typeSafeAi.evaluationModel('jev-latest'),
128
+ model: typeSafeAi.decisionModel('jev-latest'),
129
129
  questions: {
130
130
  requiresApproval: {
131
131
  type: 'boolean',
@@ -137,7 +137,7 @@ const approvalClassifier = new Classifier({
137
137
 
138
138
  const stream = await agent.stream('Clean up old records', {
139
139
  requireToolApproval: async ({ toolName, args }) => {
140
- const result = await approvalClassifier.evaluate({
140
+ const result = await approvalClassifier.decide({
141
141
  state: {
142
142
  toolName,
143
143
  argumentNames: Object.keys(args),
@@ -149,7 +149,7 @@ const stream = await agent.stream('Clean up old records', {
149
149
  })
150
150
  ```
151
151
 
152
- The example sends argument names rather than values because the classifier forwards its state to the configured evaluation model. If the decision requires argument values, redact sensitive data first or use an evaluation model and provider that meet the protected tool's data-handling requirements.
152
+ The example sends argument names rather than values because the classifier forwards its state to the configured decision model. If the decision requires argument values, redact sensitive data first or use a decision model and provider that meet the protected tool's data-handling requirements.
153
153
 
154
154
  Returning `true` pauses the tool call for human approval. It doesn't approve or decline the call automatically. Choose a threshold that matches the risk of the tools available to the agent. If this `requireToolApproval` function throws, it defaults to requiring approval.
155
155
 
@@ -260,6 +260,8 @@ const weatherTool = createTool({
260
260
 
261
261
  > **Note:** `suspend()` doesn't throw, return immediately after calling it (e.g. `return await suspend({ ... })`). Code after `await suspend(...)` still runs before the tool pauses.
262
262
 
263
+ Use `suspend()` instead of a tool without `execute` when the tool needs a structured answer from the user and also runs inside a subagent: subagents can't run client tools, but suspension propagates through the supervisor. To resume from AI SDK `useChat()`, see [resuming a suspended tool from `useChat()`](https://mastra.ai/integrations/agentic-ui/ai-sdk-ui).
264
+
263
265
  ## Tool approval with `generate()`
264
266
 
265
267
  Tool approval also works with `generate()` for non-streaming use cases. When a tool requires approval, `generate()` returns immediately with `finishReason: 'suspended'`, a `suspendPayload` containing the tool call details (`toolCallId`, `toolName`, `args`), and a `runId`:
@@ -116,13 +116,14 @@ const agent = new Agent({
116
116
 
117
117
  ### Error processors are enabled by default
118
118
 
119
- Every agent adds whichever of these three your `errorProcessors` list doesn't already contain:
119
+ Every agent adds whichever of these four your `errorProcessors` list doesn't already contain:
120
120
 
121
121
  1. `ProviderHistoryCompat`: repairs provider-specific history incompatibilities in the outbound prompt
122
122
  2. `PrefillErrorHandler`: recovers from assistant-response prefill rejections
123
- 3. `StreamErrorRetryProcessor`: retries transient API and stream failures
123
+ 3. [`UnsupportedFileHandler`](https://mastra.ai/reference/processors/unsupported-file-handler): takes a file the model rejects out of the prompt, uploads it to the agent's sandbox when there is one, and calls the model again
124
+ 4. `StreamErrorRetryProcessor`: retries transient API and stream failures
124
125
 
125
- A default is only added when nothing in your list carries its `id`, so your own instance always wins and is never duplicated. An added default is placed at the position its `id` gives it among the defaults, so naming only a later one doesn't invert the pair. Supplying only your own `StreamErrorRetryProcessor` still resolves with `ProviderHistoryCompat` and `PrefillErrorHandler` ahead of it.
126
+ A default is only added when nothing in your list carries its `id`, so your own instance always wins and is never duplicated. An added default is placed at the position its `id` gives it among the defaults, so naming only a later one doesn't invert the pair. Supplying only your own `StreamErrorRetryProcessor` still resolves with `ProviderHistoryCompat`, `PrefillErrorHandler`, and `UnsupportedFileHandler` ahead of it.
126
127
 
127
128
  Error processors stop at the first one that returns `{ retry: true }`, so that relative order decides which repair runs. The default order puts the repairs ahead of the retrying processor. Placed earlier, an instance with broad matchers (the bad-request matcher matches any `400`, for example) would claim a request the repairs could have fixed and resend it unchanged. The default instance retries only transient failures: connection resets, retryable OpenAI stream errors, and errors the provider marks as retryable. Your own instance can be configured with broader matchers. The order keeps repairs ahead of it too.
128
129
 
@@ -144,11 +145,11 @@ const agent = new Agent({
144
145
  })
145
146
  ```
146
147
 
147
- The `StreamErrorRetryProcessor` above is the only stream-retry processor on the agent, and it resolves in its usual position: last, behind the `ProviderHistoryCompat` and `PrefillErrorHandler` defaults your list never names. Pass all three ids to run a completely custom set.
148
+ The `StreamErrorRetryProcessor` above is the only stream-retry processor on the agent, and it resolves in its usual position: last, behind the `ProviderHistoryCompat`, `PrefillErrorHandler`, and `UnsupportedFileHandler` defaults your list never names. Pass all four ids to run a completely custom set.
148
149
 
149
150
  A processor's `maxRetries` can't raise the agent's limit. Without `maxProcessorRetries`, error-processor retries stop after `3` (see [Error processor retry limits](#error-processor-retry-limits)), so set it when a processor needs more.
150
151
 
151
- An empty `errorProcessors` list merges like any other, so it still gets the three defaults. To turn the defaults off, set `errorProcessorDefaults: false`. The agent then runs only the processors you configure, or none when you configure none:
152
+ An empty `errorProcessors` list merges like any other, so it still gets the four defaults. To turn the defaults off, set `errorProcessorDefaults: false`. The agent then runs only the processors you configure, or none when you configure none:
152
153
 
153
154
  ```typescript
154
155
  new Agent({
@@ -572,14 +573,18 @@ Pass `scope: null` to deliberately share entries across all callers. Only use th
572
573
 
573
574
  ### Custom cache backend
574
575
 
575
- `ResponseCache` accepts any `MastraServerCache`. For production, use `RedisCache` from `@mastra/redis`:
576
+ `ResponseCache` accepts any `MastraServerCache`. For production, use `RedisServerCache` from `@mastra/redis`:
576
577
 
577
578
  ```typescript
578
579
  import { Agent } from '@mastra/core/agent'
579
580
  import { ResponseCache } from '@mastra/core/processors'
580
- import { RedisCache } from '@mastra/redis'
581
+ import { RedisServerCache } from '@mastra/redis'
582
+ import { createClient } from 'redis'
581
583
 
582
- const cache = new RedisCache({ url: process.env.REDIS_URL })
584
+ const client = createClient({ url: process.env.REDIS_URL })
585
+ await client.connect()
586
+
587
+ const cache = new RedisServerCache({ client })
583
588
 
584
589
  export const agent = new Agent({
585
590
  id: 'cached-agent',
@@ -300,6 +300,30 @@ export const weatherTool = createTool({
300
300
 
301
301
  `toModelOutput` also works with client-side tools. For tools passed through `clientTools`, the mapping runs on the client after the tool executes, and the transformed output is sent back to the server alongside the raw result. For tools defined on the server without an `execute` function (the browser runs the tool and sends the result back on the next request), the server definition's `toModelOutput` is applied to the incoming result. The model receives the transformed content instead of the raw tool result.
302
302
 
303
+ ## Tools that run on the client
304
+
305
+ A tool without an `execute` function is a client tool: the server can't run it. The agent stops at the step where the model called it. The run ends with `finishReason: 'tool-calls'`, and the model doesn't produce more text until the tool has a result. Pick the pattern that matches what the model needs back:
306
+
307
+ - **The client runs the tool and the model needs its result**: Leave out `execute`. The client runs the tool, adds the result to the conversation, and sends a new request so the agent continues. With AI SDK `useChat()`, see [client tools with `useChat()`](https://mastra.ai/integrations/agentic-ui/ai-sdk-ui).
308
+ - **The client only renders the call** (for example a product card): Give the tool an `execute` that returns a short acknowledgement. The agent continues in the same run, and the client renders the tool part from its input. Return a small value instead of echoing the input so the model context and stored messages stay small.
309
+ - **The tool needs a structured answer from the user** (for example a confirmed cart write): Call `suspend()` in `execute`, and resume with the user's answer. See [runtime suspension with `suspend()`](https://mastra.ai/docs/agents/human-in-the-loop).
310
+
311
+ ```typescript
312
+ import { createTool } from '@mastra/core/tools'
313
+ import { z } from 'zod'
314
+
315
+ export const showProductTool = createTool({
316
+ id: 'show-product',
317
+ description: 'Shows a product card to the user',
318
+ inputSchema: z.object({
319
+ productId: z.string(),
320
+ }),
321
+ execute: async () => ({ rendered: true }),
322
+ })
323
+ ```
324
+
325
+ Subagents can't run client tools. When a subagent calls a tool without `execute`, its run stops and the supervisor receives the unresolved calls in `subAgentPendingToolCalls` on the delegation result. Give client tools to the supervisor, or use `suspend()` in the subagent's tool. Suspension propagates through the supervisor, see [use `suspend()` in supervisor agents](https://mastra.ai/docs/agents/human-in-the-loop).
326
+
303
327
  ## Transform tool payloads for UI and transcripts
304
328
 
305
329
  Use `transform` when a tool returns raw data your application needs, but browser-facing streams or user-visible transcript messages should receive a smaller or safer shape. `transform` is separate from `toModelOutput`: `toModelOutput` shapes the payload sent back to the model, while `transform` shapes tool input, output, errors, approval payloads, and suspension payloads for `display` and `transcript` targets.
@@ -178,8 +178,6 @@ const browser = new AgentBrowser({
178
178
 
179
179
  ## Record browser sessions
180
180
 
181
- > **Beta:** Breaking changes may occur without a major version bump until the API is stable.
182
-
183
181
  AgentBrowser and StagehandBrowser can opt into recording for reviewing, sharing, or debugging browser runs. Configure `outputDir` to add the recording tools:
184
182
 
185
183
  ```typescript
@@ -215,7 +215,7 @@ This example uses the default bridge. Mastra first preserves any `req.auth` valu
215
215
 
216
216
  Return only the data the model needs. Remove credentials and sensitive upstream fields before returning a tool result.
217
217
 
218
- `RequestContext.serializeForSpan()` redacts `MASTRA_AUTH_TOKEN_KEY` when context is attached to tracing spans. Application logs and custom telemetry must apply the same principle to other credentials and sensitive identity fields.
218
+ Reserved Mastra keys (those starting with `mastra__` or `__mastra_`, including `MASTRA_AUTH_TOKEN_KEY`) are omitted when request context is attached to tracing spans or saved on score records. Application logs and custom telemetry must apply the same principle to other credentials and sensitive identity fields.
219
219
 
220
220
  ## Add authorization after authentication
221
221
 
@@ -201,6 +201,35 @@ await session.model.switch('anthropic/claude-sonnet-4-6')
201
201
  console.log(session.model.get())
202
202
  ```
203
203
 
204
+ ### Select Observational Memory models
205
+
206
+ Observer and reflector model choices are independent. Each role can use an explicit model or an automatic selection that the host resolves from the active main model and session state.
207
+
208
+ Configure automatic selection with a synchronous resolver that returns a concrete model ID:
209
+
210
+ ```typescript
211
+ const controller = new AgentController({
212
+ // ...
213
+ omConfig: {
214
+ observerModel: 'auto',
215
+ reflectorModel: 'auto',
216
+ defaultObserverModelId: 'openai/gpt-5-mini',
217
+ defaultReflectorModelId: 'openai/gpt-5-mini',
218
+ resolveAutoModelId: ({ currentModelId }) => currentModelId,
219
+ },
220
+ })
221
+ ```
222
+
223
+ `session.om.observer.model()` returns `'auto'` or a concrete model ID. `session.om.observer.modelId()` returns the effective concrete model. A host can therefore change the main model without rewriting automatic role settings.
224
+
225
+ Reset one role to automatic selection without changing the other:
226
+
227
+ ```typescript
228
+ await session.om.observer.switchModel({ modelId: 'auto' })
229
+ ```
230
+
231
+ If the resolver returns `undefined` or throws, the role uses its concrete `defaultObserverModelId` or `defaultReflectorModelId` fallback. See the [`Session` Observational Memory API](https://mastra.ai/reference/agent-controller/session) for explicit selection.
232
+
204
233
  ## Manage threads and state
205
234
 
206
235
  List stored conversations with [`session.thread.list()`](https://mastra.ai/reference/agent-controller/session):
@@ -48,6 +48,18 @@ for await (const chunk of subscription.stream) {
48
48
 
49
49
  When the thread has a running agent stream, `sendMessage()` becomes new input inside that agent loop. When the thread is idle, Mastra starts a stream with the message as the first input.
50
50
 
51
+ ### Input during reasoning
52
+
53
+ In the default agent loop, accepted pending messages and signals interrupt a model request that has produced only reasoning or metadata. This includes the wait for its first token. Mastra cancels that request, discards its response from model history and memory, and includes queued input in the next request within the same run. Earlier completed responses stay in history.
54
+
55
+ Once text, tool calls, or other response content starts, signals wait for the next loop boundary. Running tools aren't cancelled or repeated. If the run reaches `maxSteps`, queued input may be saved without a response. `queueMessage()` still waits for the active run to finish. Signals that processors write directly to the message history don't interrupt their own request.
56
+
57
+ Interrupted requests don't count toward `maxSteps` or advance `stepNumber`. The next request uses the same logical step, so `maxSteps: 1` still allows a replacement response. Mastra doesn't set a separate interruption limit. Repeated signals can keep restarting reasoning until a request completes, the run is cancelled, or its total timeout expires.
58
+
59
+ Already-streamed reasoning may remain visible until the client reloads history. When input arrives while per-step input processors (`processInputStep`) run, the processors finish and Mastra cancels the model request they prepared. Custom output processors also keep running after a cancellation, and the next request waits for their in-flight work to settle. Mastra discards framework-owned response buffers, but doesn't undo processor state, data that processors write while the cancelled request settles, or external side effects. Usage totals exclude interrupted requests, including any usage the provider reports for them. Providers may still bill for those requests.
60
+
61
+ This reasoning interruption applies to the default loop, not the experimental durable or evented agents or the Inngest engine.
62
+
51
63
  ## Message input
52
64
 
53
65
  ### Send a message now
@@ -99,7 +99,7 @@ import { Agent } from '@mastra/core/agent'
99
99
  import { Memory } from '@mastra/memory'
100
100
  import { LibSQLStore } from '@mastra/libsql'
101
101
  import { PineconeVector } from '@mastra/pinecone'
102
- import { OpenAIEmbedder } from '@mastra/openai'
102
+ import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
103
103
  import { openai } from '@ai-sdk/openai'
104
104
 
105
105
  const agent = new Agent({
@@ -115,10 +115,7 @@ const agent = new Agent({
115
115
  id: 'memory-vector',
116
116
  apiKey: process.env.PINECONE_API_KEY!,
117
117
  }),
118
- embedder: new OpenAIEmbedder({
119
- model: 'text-embedding-3-small',
120
- apiKey: process.env.OPENAI_API_KEY!,
121
- }),
118
+ embedder: new ModelRouterEmbeddingModel('openai/text-embedding-3-small'),
122
119
  semanticRecall: { enabled: true }, // SemanticRecall processor automatically added
123
120
  }),
124
121
  })
@@ -10,14 +10,6 @@ You can also retrieve message history to display past conversations in your UI.
10
10
 
11
11
  > **Note:** Each message belongs to a thread (the conversation) and a resource (the user or entity it's associated with). See [Threads and resources](#threads-and-resources) for more detail.
12
12
 
13
- > **Warning:** When you use memory with a client application, send **only the new message** from the client instead of the full conversation history.
14
- >
15
- > Sending the full history is redundant because Mastra loads messages from storage. Mastra filters client-echoed history before loading stored messages and uses the stored copy as the base when message IDs match, preserving stored timestamps and provider metadata while retaining new tool results.
16
- >
17
- > If you assemble the request input yourself and need it processed exactly as sent, set `retainFullInput: true` on `memory.options` for that call, or in the memory constructor options to apply it agent-wide. This disables the filtering described above. History still loads underneath. Every input message that isn't already stored is saved to the thread, including few-shot examples.
18
- >
19
- > For an AI SDK example, see [Using Mastra Memory](https://mastra.ai/integrations/agentic-ui/ai-sdk-ui).
20
-
21
13
  ## Threads and resources
22
14
 
23
15
  Mastra organizes conversations using two identifiers:
@@ -126,6 +118,21 @@ You can use this history in two ways:
126
118
 
127
119
  > **Note:** `lastMessages` counts every stored message, including tool calls, tool results, and [signals](https://mastra.ai/docs/harness/signals) of any kind, so a single turn can add several messages to the count. The window also slides forward on every request: once a thread grows past the limit, the oldest message leaves context on each turn, which changes the start of the prompt and invalidates the provider prompt cache. For long-running conversations, use [Observational Memory](https://mastra.ai/docs/memory/observational-memory), which keeps the prompt prefix stable.
128
120
 
121
+ ### Sending messages from a client
122
+
123
+ When you use memory with a client application, send **only the new message** instead of the full conversation history. Mastra loads previous messages from storage.
124
+
125
+ For an AI SDK example, see [Using Mastra Memory](https://mastra.ai/integrations/agentic-ui/ai-sdk-ui).
126
+
127
+ <details>
128
+ **Passing a full input history**
129
+
130
+ Mastra filters client-echoed history before loading stored messages. When message IDs match, it uses the stored copy as the base, preserving stored timestamps and provider metadata while retaining new tool results.
131
+
132
+ If you assemble the request input yourself and need it processed exactly as sent, set `retainFullInput: true` on `memory.options` for that call, or in the memory constructor options to apply it agent-wide. This disables input filtering, but stored history still loads. Every input message that isn't already stored is saved to the thread, including few-shot examples.
133
+
134
+ </details>
135
+
129
136
  ### Limit history by tokens
130
137
 
131
138
  Message count is a poor proxy for context size: a tool result can be a few tokens or thousands. Use `messageHistory` to keep recent history within a token budget instead:
@@ -76,7 +76,7 @@ console.log(secondResponse.text)
76
76
 
77
77
  The `resource` identifies the user or entity, while the `thread` identifies the conversation. Reuse both values to continue the same conversation. Observational Memory processes the stored history as it grows and replaces older messages with observations when its activation conditions are met.
78
78
 
79
- The agent now has humanlike long-term memory that persists across conversations. Setting `observationalMemory: true` uses `google/gemini-2.5-flash` by default. To use a different model, pass it in the config object:
79
+ The agent now has humanlike long-term memory that persists across conversations. Setting `observationalMemory: true` uses automatic model selection. To use a specific model, pass it in the config object:
80
80
 
81
81
  ```typescript
82
82
  const memory = new Memory({
@@ -98,7 +98,17 @@ See [configuration options](https://mastra.ai/reference/memory/observational-mem
98
98
  >
99
99
  > For an AI SDK example, see [Using Mastra Memory](https://mastra.ai/integrations/agentic-ui/ai-sdk-ui).
100
100
 
101
- > **Note:** OM currently only supports `@mastra/pg`, `@mastra/libsql`, `@mastra/mysql`, `@mastra/mongodb`, `@mastra/convex`, and `@mastra/oracledb` storage adapters. It uses background agents for managing memory. When no model is set, the default model is `google/gemini-2.5-flash`.
101
+ > **Note:** OM currently only supports `@mastra/pg`, `@mastra/libsql`, `@mastra/mysql`, `@mastra/mongodb`, `@mastra/convex`, and `@mastra/oracledb` storage adapters. It uses background agents for managing memory. When no model is set, the default is `model: 'auto'`.
102
+
103
+ ### Automatic models in Mastra Code and Factory
104
+
105
+ Mastra Code and Factory surface the same automatic selection as a per-role **Auto** option in their settings.
106
+
107
+ An automatic Observer or Reflector follows the active main model provider. Mastra Code uses that provider's built-in low-cost Observational Memory model when one is configured. For custom providers and providers without a built-in choice, it uses the active main model. The effective model is resolved when the role runs, so changing the main model doesn't rewrite the saved automatic selection.
108
+
109
+ Select an explicit model to pin one role independently. Reset that role to **Auto** to resume following the main model provider. Existing saved concrete model IDs remain explicit until you reset them.
110
+
111
+ Factory stores automatic intent separately from the effective model shown in settings. A missing provider credential can mark that effective model unavailable, but it doesn't replace the saved selection or prevent Factory from starting.
102
112
 
103
113
  ## Temporal gap markers
104
114
 
@@ -570,11 +580,30 @@ The progress bars update live while the agent is observing or reflecting, showin
570
580
 
571
581
  ## Models
572
582
 
573
- The Observer and Reflector run in the background. Any model that works with Mastra's [model routing](https://mastra.ai/models) (`provider/model`) can be used. When no model is set, the default model is `google/gemini-2.5-flash`.
583
+ The Observer and Reflector run in the background. Any model that works with Mastra's [model routing](https://mastra.ai/models) (`provider/model`) can be used. When no model is set, the default is `model: 'auto'`.
584
+
585
+ Automatic selection uses `google/gemini-2.5-flash` when `GOOGLE_GENERATIVE_AI_API_KEY` is configured. Otherwise, it selects a low-cost model for the active main model's provider, then falls back to the active main model. Observer and Reflector resolve independently before each invocation.
586
+
587
+ Automatic selection reads the main model's `provider/model` ID. Models created from a plain model string carry that ID, and a dynamic model function can label a custom model by returning `{ model, id }`. When the ID is unknown, such as a model with a custom URL, API key, headers, or gateway, automatic selection reuses the main model itself because a sibling model isn't known to share that route. Pass a concrete model ID to the role to override either behavior.
588
+
589
+ Use `autoModels` to change the model picked for a provider, and `resolveModel` to create the picked model with your own credentials or routing:
590
+
591
+ ```typescript
592
+ const memory = new Memory({
593
+ options: {
594
+ observationalMemory: {
595
+ autoModels: { openai: 'openai/gpt-5-nano' },
596
+ resolveModel: (modelId, { requestContext }) => createRoutedModel(modelId, requestContext),
597
+ },
598
+ },
599
+ })
600
+ ```
601
+
602
+ `resolveAutoModelId(mainModelId, { autoModels })` from `@mastra/memory` returns the model automatic selection would pick, which is useful for showing the effective model in a settings UI.
574
603
 
575
604
  Mastra recommends using a model that has a large context window (128K+ tokens) and is fast enough to run in the background without slowing down your actions.
576
605
 
577
- If you're unsure which model to use, start with the default `google/gemini-2.5-flash`. We've also successfully tested `openai/gpt-5-mini`, `anthropic/claude-haiku-4-5`, `deepseek/deepseek-reasoner`, `deepseek/deepseek-v4-pro`, `deepseek/deepseek-v4-flash`, `xai/grok-4-1-fast`, `qwen3`, and `glm-4.7`.
606
+ To pin a model instead, set a concrete model ID. We've also successfully tested `openai/gpt-5-mini`, `anthropic/claude-haiku-4-5`, `deepseek/deepseek-reasoner`, `deepseek/deepseek-v4-pro`, `deepseek/deepseek-v4-flash`, `xai/grok-4-1-fast`, `qwen3`, and `glm-4.7`.
578
607
 
579
608
  ```typescript
580
609
  const memory = new Memory({
@@ -411,11 +411,11 @@ PostgreSQL supports both IVFFlat and HNSW indexes. By default, Mastra creates an
411
411
 
412
412
  ```typescript
413
413
  import { Memory } from '@mastra/memory'
414
- import { PgStore, PgVector } from '@mastra/pg'
414
+ import { PostgresStore, PgVector } from '@mastra/pg'
415
415
 
416
416
  const agent = new Agent({
417
417
  memory: new Memory({
418
- storage: new PgStore({
418
+ storage: new PostgresStore({
419
419
  id: 'agent-storage',
420
420
  connectionString: process.env.DATABASE_URL,
421
421
  }),
@@ -272,6 +272,22 @@ Schema-based working memory uses **merge semantics**, meaning the agent only nee
272
272
  - **Set a field to `null` to delete it:** This explicitly removes the field from memory
273
273
  - **Arrays are replaced entirely:** When an array field is provided, it replaces the existing array (arrays aren't merged element-by-element)
274
274
 
275
+ ### Concurrent updates
276
+
277
+ With `scope: 'resource'` and a storage adapter that supports atomic merges (currently `@mastra/pg`), each merge runs inside a row-locked database transaction. Concurrent updates to different fields from separate processes are all kept. Other adapters merge in the application, which only serializes writers inside a single process.
278
+
279
+ To merge a partial update from your own code, call `memory.mergeWorkingMemory()`:
280
+
281
+ ```typescript
282
+ await memory.mergeWorkingMemory({
283
+ threadId: 'thread-1',
284
+ resourceId: 'user-123',
285
+ workingMemory: { preferences: { tone: 'formal' } },
286
+ })
287
+ ```
288
+
289
+ It throws if working memory isn't schema-based and resource-scoped, or if the storage adapter doesn't support atomic merges. Check `await memory.supportsAtomicWorkingMemoryMerge()` first if you need to fall back.
290
+
275
291
  ## Choosing between template and schema
276
292
 
277
293
  - 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.
@@ -450,7 +450,7 @@ Span processors transform, filter, or enrich trace data before it's exported. Th
450
450
  You can create custom span processors by implementing the `SpanOutputProcessor` interface. Here's a basic example that converts all input text in spans to lowercase:
451
451
 
452
452
  ```ts
453
- import type { SpanOutputProcessor, AnySpan } from '@mastra/observability'
453
+ import type { SpanOutputProcessor, AnySpan } from '@mastra/core/observability'
454
454
 
455
455
  export class LowercaseInputProcessor implements SpanOutputProcessor {
456
456
  name = 'lowercase-processor'
@@ -73,6 +73,7 @@ Called before the parent agent delegates to a subagent. Return an object to cont
73
73
  - `proceed: false`: Reject the delegation with a `rejectionReason`
74
74
  - `modifiedPrompt`: Rewrite the prompt sent to the subagent
75
75
  - `modifiedMaxSteps`: Limit the subagent's iteration count
76
+ - `threadMetadata`: Attach metadata (for example a `tenantId`) to the subagent's thread when it's created, so you can filter threads with `memory.listThreads({ filter: { metadata } })`
76
77
 
77
78
  ```typescript
78
79
  const stream = await parentAgent.stream('Research AI trends', {
@@ -163,14 +164,14 @@ const stream = await parentAgent.stream('Research AI trends', {
163
164
 
164
165
  The `context` object includes:
165
166
 
166
- | Property | Description |
167
- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
168
- | `primitiveId` | The ID of the subagent that ran |
169
- | `result` | The subagent's response, including `text`, `usage`, `finishReason`, `subAgentToolResults`, `subAgentThreadId`, and `subAgentResourceId` when available |
170
- | `success` | Whether the delegation succeeded |
171
- | `error` | The original error if the delegation failed |
172
- | `messages` | The collected subagent transcript, including partial messages when available |
173
- | `bail()` | Function to stop the parent agent's loop |
167
+ | Property | Description |
168
+ | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
169
+ | `primitiveId` | The ID of the subagent that ran |
170
+ | `result` | The subagent's response, including `text`, `usage`, `finishReason`, `subAgentToolResults`, `subAgentPendingToolCalls`, `subAgentThreadId`, and `subAgentResourceId` when available |
171
+ | `success` | Whether the delegation succeeded |
172
+ | `error` | The original error if the delegation failed |
173
+ | `messages` | The collected subagent transcript, including partial messages when available |
174
+ | `bail()` | Function to stop the parent agent's loop |
174
175
 
175
176
  #### Failed delegations
176
177
 
@@ -261,6 +262,8 @@ Application code and UI integrations can still inspect `subAgentToolResults` and
261
262
 
262
263
  This keeps debugging and display data available without sending nested tool arguments or outputs back into the parent agent's next model call.
263
264
 
265
+ Subagents can't run client tools (tools without an `execute` function). If a subagent calls one, its run stops at that step with `finishReason: 'tool-calls'`. The delegation result lists the unresolved calls in `subAgentPendingToolCalls`, the parent agent's model is told which tools were never run, and Mastra logs a warning. Give client tools to the parent agent, or use [`suspend()`](https://mastra.ai/docs/agents/human-in-the-loop) in the subagent's tool when it needs input from the user.
266
+
264
267
  Set `includeSubAgentToolResultsInModelContext` to include the full subagent result, including nested tool results and subagent metadata, in the parent agent's model context.
265
268
 
266
269
  ```typescript
@@ -261,7 +261,7 @@ import { z } from 'zod'
261
261
 
262
262
  const router = new Classifier({
263
263
  id: 'ticket-router',
264
- model: typeSafeAi.evaluationModel('jev-latest'),
264
+ model: typeSafeAi.decisionModel('jev-latest'),
265
265
  questions: {
266
266
  route: {
267
267
  type: 'choice',
@@ -104,7 +104,7 @@ const result = await run.timeTravel({
104
104
 
105
105
  The context object contains step results keyed by step ID. Each step result includes:
106
106
 
107
- - `status`: The step's execution status (`success`, `failed`, `suspended`)
107
+ - `status`: The step's execution status. Commonly `success`, `failed`, or `suspended`, but any workflow run status is accepted: `running`, `success`, `failed`, `tripwire`, `suspended`, `waiting`, `pending`, `canceled`, `bailed`, `paused`, or `skipped`
108
108
  - `payload`: The input data passed to the step
109
109
  - `output`: The step's output data (for successful steps)
110
110
  - `startedAt`: Timestamp when the step started
@@ -213,16 +213,18 @@ try {
213
213
 
214
214
  ### Invalid step ID
215
215
 
216
- Time travel throws if the target step doesn't exist in the workflow:
216
+ Time travel throws if the target step doesn't exist in the current workflow definition:
217
217
 
218
218
  ```typescript
219
219
  try {
220
220
  await run.timeTravel({ step: 'nonExistentStep' })
221
221
  } catch (error) {
222
- // "Time travel target step not found in execution graph: 'nonExistentStep'. Verify the step id/path."
222
+ // "Cannot time travel to step 'nonExistentStep': the step does not exist in the current execution graph. ..."
223
223
  }
224
224
  ```
225
225
 
226
+ The error also lists up to 10 of the step IDs recorded in the run's snapshot (with a count of any remaining IDs), and confirms that the stored snapshot wasn't modified. If the run has no recorded step results, the error reads `Time travel target step not found in execution graph: 'nonExistentStep'. Verify the step id/path.` instead.
227
+
226
228
  ### Invalid input data
227
229
 
228
230
  When `validateInputs` is enabled, time travel validates the input data against the step's schema:
@@ -243,6 +243,66 @@ export default function Chat() {
243
243
 
244
244
  Use [`prepareSendMessagesRequest`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat#transport.default-chat-transport.prepare-send-messages-request) to customize the request sent to the chat route, for example to pass additional configuration to the agent.
245
245
 
246
+ ### Client tools with `useChat()`
247
+
248
+ A tool without an `execute` function runs on the client. When the model calls it, the agent's run ends at that step and the stream finishes with a `tool-{toolKey}` part in the `input-available` state. To let the agent continue, run the tool in the browser, add its result with `addToolOutput()`, and send the conversation back. `sendAutomaticallyWhen` sends the next request once every tool call in the last assistant message has a result:
249
+
250
+ ```tsx
251
+ import { useChat } from '@ai-sdk/react'
252
+ import { DefaultChatTransport, lastAssistantMessageIsCompleteWithToolCalls } from 'ai'
253
+
254
+ export default function Chat() {
255
+ const { messages, sendMessage, addToolOutput } = useChat({
256
+ transport: new DefaultChatTransport({
257
+ api: 'http://localhost:4111/chat',
258
+ }),
259
+ sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
260
+ async onToolCall({ toolCall }) {
261
+ if (toolCall.toolName === 'addToCart') {
262
+ const input = toolCall.input as { productId: string }
263
+ const cart = await addToCartInBrowser(input.productId)
264
+
265
+ // Don't await addToolOutput inside onToolCall to avoid deadlocks
266
+ addToolOutput({ tool: 'addToCart', toolCallId: toolCall.toolCallId, output: cart })
267
+ }
268
+ },
269
+ })
270
+
271
+ // ...render messages and call sendMessage()
272
+ }
273
+ ```
274
+
275
+ If the client only needs to render the tool call and the model doesn't need a result, give the tool an `execute` that returns a short acknowledgement instead. The agent then keeps generating in the same request. See [tools that run on the client](https://mastra.ai/docs/agents/tools).
276
+
277
+ Subagents can't run client tools: the browser never sees a subagent's tool calls. Define client tools on the agent the chat route talks to.
278
+
279
+ ### Resuming a suspended tool from `useChat()`
280
+
281
+ When a tool calls `suspend()`, the stream includes a `data-tool-call-suspended` part with the `runId`, `toolCallId`, and `suspendPayload`. To resume, send `resumeData` (matching the tool's `resumeSchema`) and the `runId` in the request body. `handleChatStream()` and `chatRoute()` then call `agent.resumeStream()` instead of starting a new run:
282
+
283
+ ```tsx
284
+ const { messages, sendMessage } = useChat({
285
+ transport: new DefaultChatTransport({
286
+ api: 'http://localhost:4111/chat',
287
+ prepareSendMessagesRequest: ({ messages, body }) => {
288
+ const resume = body?.resume as { runId: string; resumeData: unknown } | undefined
289
+ if (resume) {
290
+ return { body: { messages, runId: resume.runId, resumeData: resume.resumeData } }
291
+ }
292
+ return { body: { messages } }
293
+ },
294
+ }),
295
+ })
296
+
297
+ // When the user confirms the suspended tool call:
298
+ sendMessage(
299
+ { text: 'Confirmed' },
300
+ { body: { resume: { runId: suspended.runId, resumeData: { confirmed: true } } } },
301
+ )
302
+ ```
303
+
304
+ `suspended` is the `data` of the latest `data-tool-call-suspended` part in `messages`.
305
+
246
306
  ## Using Mastra Memory
247
307
 
248
308
  When your agent has [memory](https://mastra.ai/docs/memory/overview) configured, Mastra loads conversation history from storage on the server. Send only the new message from the client instead of the full conversation history.
@@ -71,6 +71,29 @@ export const { createWorkflow, createStep } = init({
71
71
 
72
72
  `loadClientConnectConfig()` reads standard Temporal environment variables such as `TEMPORAL_ADDRESS`, `TEMPORAL_NAMESPACE`, and mTLS settings. See the [Temporal envconfig docs](https://docs.temporal.io/develop/typescript/temporal-clients) for the full list.
73
73
 
74
+ ### Configure activity retries
75
+
76
+ Pass `retry` to `init()` to set a Temporal activity retry policy for workflows created by these helpers. For example, add the following options to the initialization above to limit a failing activity to five total attempts:
77
+
78
+ ```ts
79
+ export const { createWorkflow, createStep } = init({
80
+ client,
81
+ taskQueue: 'mastra',
82
+ startToCloseTimeout: '5 minutes',
83
+ retry: {
84
+ initialInterval: '5 seconds',
85
+ backoffCoefficient: 2,
86
+ maximumInterval: '5 minutes',
87
+ maximumAttempts: 5,
88
+ nonRetryableErrorTypes: ['ValidationError'],
89
+ },
90
+ })
91
+ ```
92
+
93
+ The policy applies to all generated activities, including steps, mappings, and conditions. Set `maximumAttempts: 1` to disable retries. Omitting `retry` preserves Temporal's default policy, which allows unlimited attempts. Mastra's workflow `retryConfig` doesn't configure Temporal activity retries.
94
+
95
+ Keep retry options in the statically analyzable `init()` configuration so the worker build can include them. Inline object literal spreads are supported. Spreads of variables or function results are skipped during activity option extraction, so `retry` and `startToCloseTimeout` inside those spreads aren't forwarded to the generated workflow. Provide these options directly in `init()` or in an inline object literal spread instead. Rebuild and restart the worker after changing the policy.
96
+
74
97
  ### Creating steps
75
98
 
76
99
  Define the individual steps that will compose your workflow. Each step becomes a Temporal activity.
@@ -57,6 +57,67 @@ const agent = new Agent({
57
57
  })
58
58
  ```
59
59
 
60
+ ### Repository templates
61
+
62
+ `createDockerRepoTemplate` builds an image that already holds a checkout of a repository and the output of its setup command, so a session starts from installed dependencies instead of a cold clone:
63
+
64
+ ```typescript
65
+ import { DockerSandbox, createDockerRepoTemplate } from '@mastra/docker'
66
+
67
+ const sandbox = new DockerSandbox({
68
+ id: sessionId,
69
+ template: createDockerRepoTemplate({
70
+ getRepositoryAccess: async () => ({
71
+ cloneUrl: 'https://github.com/octocat/hello-world.git',
72
+ }),
73
+ setupCommand: 'npm ci',
74
+ }),
75
+ })
76
+ ```
77
+
78
+ `getRepositoryAccess` supplies the clone URL and, for private repositories, a short-lived credential. The credential is passed to the clone step as a build secret and never enters the image, its layers or the image identity. When `getRepositoryAccess` is `undefined`, `createDockerRepoTemplate` returns `undefined`, which selects the provider's default image without a conditional at the call site.
79
+
80
+ The repository is cloned to `<workingDirectory>/<repo>` (default `/workspace`), which becomes the working directory of the sandbox. Pass `ref` to prepare a branch, tag or commit other than the default branch. Right before the build the resolver runs `git ls-remote` to pin the ref to a commit, which is part of the image identity: a moved branch yields a fresh image on the next new sandbox and an unmoved one reuses the cached image. If the head can't be resolved the resolver rejects rather than caching an unpinned clone.
81
+
82
+ `setupCommand` also accepts an array. Each entry runs as its own cached build step. A command cannot contain a bare newline, which would start a new Dockerfile instruction. End the line with `\` or pass separate commands instead.
83
+
84
+ #### Several repositories in one image
85
+
86
+ Pass `repos` instead of `getRepositoryAccess` to clone several repositories into one image, each with its own access resolver, `ref` and setup command (a string or an array, each entry its own build step):
87
+
88
+ ```typescript
89
+ const sandbox = new DockerSandbox({
90
+ id: sessionId,
91
+ template: createDockerRepoTemplate({
92
+ repos: [
93
+ {
94
+ getRepositoryAccess: async () => ({
95
+ cloneUrl: 'https://github.com/mastra-ai/template-docs-expert.git',
96
+ }),
97
+ setupCommand: 'npm install',
98
+ },
99
+ {
100
+ getRepositoryAccess: async () => ({
101
+ cloneUrl: 'https://github.com/mastra-ai/good-issue.git',
102
+ }),
103
+ ref: 'main',
104
+ },
105
+ ],
106
+ workspaceSetupCommand: 'npm install --global @mastra/mcp-docs-server',
107
+ continueOnSetupFailure: true,
108
+ workingDirectory: '/workspace',
109
+ }),
110
+ })
111
+ ```
112
+
113
+ Every repository is cloned to `<workingDirectory>/<repo>` and the working directory becomes the sandbox cwd. Public repositories are built before private ones, keeping the caller's order within each group. Each private credential is passed as a build secret to that repository's clone step only, so setup commands never see it.
114
+
115
+ `workspaceSetupCommand` runs at the working directory after every repository is set up. `continueOnSetupFailure` (default `false`) lets a failing setup command record its repository in `.mastra-sandbox/setup-failed` and continue instead of failing the build.
116
+
117
+ Markers tell a session what the image already ran: `.mastra-sandbox/repos/<repo>` per repository and `.mastra-sandbox/workspace-setup` after the workspace commands, all under the working directory. With `continueOnSetupFailure`, check `.mastra-sandbox/setup-failed` first.
118
+
119
+ If any entry's access or head can't be resolved, the whole resolution rejects and the sandbox falls back to its default template.
120
+
60
121
  ## Constructor parameters
61
122
 
62
123
  **id** (`string`): Unique identifier for this sandbox instance. Used for label-based reconnection. (Default: `Auto-generated`)