Mastra `@mastra/core@1.41.0` adds per-request sandbox routing
`@mastra/core@1.41.0` introduces per-request Workspace sandbox routing for multi-tenant deployments, `sandboxCacheKey` for background process continuity, and a unified `untilIdle` option that deprecates the dedicated `*UntilIdle` methods.
Score breakdown
The per-request sandbox resolver and `sandboxCacheKey` together enable Mastra Workspaces to support multi-tenant agent deployments with isolated execution environments and reliable background-process continuity — capabilities the prior static sandbox config did not support.
- 01Workspace `sandbox` now accepts a resolver function `({ requestContext }) => WorkspaceSandbox` for per-request sandbox routing in multi-tenant deployments.
- 02`sandboxCacheKey` keeps background process tools (`execute_command` with `background: true`, `get_process_output`, `kill_process`) attached to the same sandbox across follow-up requests.
- 03Stable placeholder text is used in agent system prompts by default when a resolver is configured; opt into dynamic instructions via `instructions.dynamicSandbox`.
PaulieScanlon published `@mastra/core@1.41.0` on June 5, 2026, with three headline changes to the Mastra agent framework's Workspace and streaming APIs. The most significant addition is per-request sandbox routing: the Workspace `sandbox` config now accepts either a static `WorkspaceSandbox` instance or a resolver function `({ requestContext }) => WorkspaceSandbox`, allowing a single Workspace to provision isolated sandboxes per user or role. By default, building workspace instructions no longer invokes the resolver — instead, stable placeholder text is inserted into the agent's system prompt to keep it cache-friendly. Callers can opt into concrete per-request instructions via `instructions.dynamicSandbox: 'resolve'` or a custom function. When using a resolver, the caller owns the returned sandbox's lifecycle; `mounts` throws an `INVALID_CONFIG` error and `lsp: true` is disabled with a warning because both require a concrete sandbox instance upfront.
The second addition, `sandboxCacheKey`, solves continuity for background processes in dynamic-sandbox deployments.
The second addition, `sandboxCacheKey`, solves continuity for background processes in dynamic-sandbox deployments. Setting `sandboxCacheKey` to a stable identifier (such as a thread ID from `requestContext`) ensures that `execute_command({ background: true })`, `get_process_output`, and `kill_process` all attach to the same sandbox across follow-up requests. Failed resolver calls are automatically evicted from the cache so retries can succeed, and `workspace.clearSandboxCache(cacheKey)` is available for manual lifecycle management.
The third change consolidates streaming behavior: `stream()` and `resumeStream()` now accept `untilIdle: true` or `untilIdle: { maxIdleMs }` to keep streams open across background-task continuations. The previously dedicated `streamUntilIdle()` and `resumeStreamUntilIdle()` methods — and their `/stream-until-idle` and `/resume-stream-until-idle` server endpoints — are deprecated but continue to work internally by delegating to the new option. The same `untilIdle` field is supported across server endpoints and client SDKs. The release also includes a patch to `@mastra/acp@0.2.1` fixing ACP tools to keep their default session alive across executions. No breaking changes are noted in this release.
Key facts
- 01Workspace `sandbox` now accepts a resolver function `({ requestContext }) => WorkspaceSandbox` for per-request sandbox routing in multi-tenant deployments.
- 02`sandboxCacheKey` keeps background process tools (`execute_command` with `background: true`, `get_process_output`, `kill_process`) attached to the same sandbox across follow-up requests.
- 03Stable placeholder text is used in agent system prompts by default when a resolver is configured; opt into dynamic instructions via `instructions.dynamicSandbox`.
- 04`mounts` throws `INVALID_CONFIG` and `lsp: true` is disabled with a warning when a sandbox resolver is used.
- 05`stream()` and `resumeStream()` now accept `untilIdle: true` or `untilIdle: { maxIdleMs }` to keep streams open across background-task continuations.
- 06`streamUntilIdle()`, `resumeStreamUntilIdle()`, and their dedicated server endpoints are deprecated in favor of the new `untilIdle` option.
- 07`@mastra/acp@0.2.1` patches ACP tools to maintain their default session across executions.
Topics
Summary and scoring are generated automatically from the original article. We always link back to the publisher and never republish images or paywalled content. Last processed Jun 9, 2026 · 17:05 UTC. How this works →