@mastra/core@1.13.0

mastra-ai/mastra@mastra/core@1.13.0Mar 17, 2026by PaulieScanlon

AI Summary

Introduced a comprehensive Observability Storage Domain with schemas and in-memory implementations, launched a new persistent filesystem `@mastra/agentfs`, and upgraded the observability pipeline with batching.

Key Highlights

  • Observability Storage Domain with zod-based schemas and in-memory implementations.
  • New `AgentFSFilesystem` workspace provider using Turso/SQLite for persistent file storage.
  • Type-safe server route inference via `@mastra/server/schemas`.
  • Observability pipeline upgrades including `EventBuffer` batching.

Breaking Changes

  • `MetricType` (counter/gauge/histogram) is deprecated in favor of raw events.
  • Score schemas now use `scorerId` instead of `scorerName`.
  • `ObservabilityBus` constructor changes: takes a config object instead of separate methods.

New Features

  • AgentFSFilesystem workspace provider
  • EventBuffer for batching non-tracing signals
  • Type-safe route inference utilities
  • Token budget optimization for Observational Memory

Full Release Notes

## Highlights

### Observability Storage Domain (schemas + in-memory implementations)
Mastra now ships zod-based storage schemas and in-memory implementations for all observability signals (scores, logs, feedback, metrics, discovery), with full type inference and a base `ObservabilityStorage` that includes default method implementations.

### New persistent Workspace filesystem: `@mastra/agentfs`
The new `AgentFSFilesystem` workspace provider adds Turso/SQLite-backed, database-persistent file storage for agents across sessions via `agentfs-sdk`.

### Observability pipeline upgrades: renamed types + `EventBuffer` batching
`@mastra/observability` exporters/event bus were updated to align with renamed core observability types, and an `EventBuffer` was added to batch non-tracing signals with configurable flush intervals.

### Type-safe server route inference via `@mastra/server/schemas`
A new `@mastra/server/schemas` export provides utility types (`RouteMap`, `InferPathParams`, `InferBody`, `InferResponse`, etc.) that automatically infer request/response types from `SERVER_ROUTES`, including routes added via `createRoute()`.

### Lower token costs for long-running Observational Memory
Observational Memory adds `observation.previousObserverTokens` to truncate the “Previous Observations” context to a token budget (or omit/disable truncation), reducing observer prompt size in long conversations.

### Breaking Changes
- `MetricType` (`counter`/`gauge`/`histogram`) is deprecated — metrics are now raw events with aggregation at query time
- Score schemas now use `scorerId` instead of `scorerName`
- `ObservabilityBus` constructor now takes a config object (`cardinalityFilter`, `autoExtractMetrics`); `setCardinalityFilter()` and `enableAutoExtractedMetrics()` were removed

## Changelog

### [@mastra/core@1.13.0](https://github.com/mastra-ai/mastra/blob/@mastra/core@1.13.0//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/packages/core/CHANGELOG.md)
#### Minor Changes

- **Added observability storage domain schemas and implementations** ([#14214](https://github.com/mastra-ai/mastra/pull/14214))

  Introduced comprehensive storage schemas and in-memory implementations for all observability signals (scores, logs, feedback, metrics, discovery). All schemas are zod-based with full type inference. The `ObservabilityStorage` base class includes default implementations for all new methods.

  **Breaking changes:**
  - `MetricType` (`counter`/`gauge`/`histogram`) is deprecated — metrics are now raw events with aggregation at query time
  - Score schemas use `scorerId` instead of `scorerName` for scorer identification

#### Patch Changes

- Update provider registry and model documentation with latest models and providers ([`ea86967`](https://github.com/mastra-ai/mastra/commit/ea86967449426e0a3673253bd1c2c052a99d970d))

- Fixed provider tools (e.g. `openai.tools.webSearch()`) being silently dropped when using a custom gateway that returns AI SDK v6 (V3) models. The router now remaps tool types from `provider-defined` to `provider` when delegating to V3 models, so provider tools work correctly through gateways. Fixes #13667. ([#13895](https://github.com/mastra-ai/mastra/pull/13895))

- Fixed TypeScript type errors in `onStepFinish` and `onFinish` callbacks, and resolved compatibility issues with `createOpenRouter()` across different AI SDK versions. ([#14229](https://github.com/mastra-ai/mastra/pull/14229))

- Fixed a bug where thread metadata (e.g. title, custom properties) passed via `options.memory.thread` was discarded when `MASTRA_THREAD_ID_KEY` was set in the request context. The thread ID from context still takes precedence, but all other user-provided thread properties are now preserved. ([#13146](https://github.com/mastra-ai/mastra/pull/13146))

- Fixed workspace tools such as `mastra_workspace_list_files` and `mastra_workspace_read_file` failing with `WorkspaceNotAvailableError` in some execution paths. ([#14228](https://github.com/mastra-ai/mastra/pull/14228))

  Workspace tools now work consistently across execution paths.

- Added observer context optimization for Observational Memory. The `observation.previousObserverTokens` field reduces Observer input token costs for long-running conversations: ([#13568](https://github.com/mastra-ai/mastra/pull/13568))
  - **previousObserverTokens** (default: `2000`): Truncates the 'Previous Observations' section to a token budget, keeping the most recent observations and automatically replacing already-reflected lines with the buffered reflection summary. Set to `0` to omit previous observations entirely, or `false` to disable truncation and keep the full observation history.

  ```typescript
  const memory = new Memory({
    options: {
      observationalMemory: {
        model: 'google/gemini-2.5-flash',
        observation: {
          previousObserverTokens: 10_000,
        },
      },
    },
  });
  ```

### [@mastra/agentfs@0.1.0](https://github.com/mastra-ai/mastra/blob/@mastra/agentfs@0.1.0//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/workspaces/agentfs/CHANGELOG.md)
#### Minor Changes

- Added AgentFSFilesystem workspace provider — a Turso/SQLite-backed filesystem via the agentfs-sdk that gives agents persistent, database-backed file storage across sessions. ([#13450](https://github.com/mastra-ai/mastra/pull/13450))

  **Basic usage**

  ```ts
  import { Workspace } from '@mastra/core/workspace';
  import { AgentFSFilesystem } from '@mastra/agentfs';

  const workspace = new Workspace({
    filesystem: new AgentFSFilesystem({
      agentId: 'my-agent',
    }),
  });
  ```

#### Patch Changes

### [@mastra/deployer@1.13.0](https://github.com/mastra-ai/mastra/blob/@mastra/deployer@1.13.0//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/packages/deployer/CHANGELOG.md)
#### Patch Changes

- Bump esbuild from ^0.25.10 to ^0.27.3 to resolve Go stdlib CVEs (CVE-2025-22871, CVE-2025-61729) flagged by npm audit in consumer projects. ([#13124](https://github.com/mastra-ai/mastra/pull/13124))

- Fixed Agent-to-Agent requests to return a clear error message when the agent ID parameter is missing. ([#14229](https://github.com/mastra-ai/mastra/pull/14229))

- Add dynamicPackages bundler config for runtime-loaded packages and auto-detect pino ([#11779](https://github.com/mastra-ai/mastra/pull/11779))

  Adds a new `dynamicPackages` bundler config option for packages that are loaded
  dynamically at runtime and cannot be detected by static analysis (e.g.,
  `pino.transport({ target: "pino-opentelemetry-transport" })`).

  **Usage:**

  ```typescript
  import { Mastra } from '@mastra/core';

  export const mastra = new Mastra({
    bundler: {
      dynamicPackages: ['my-custom-transport', 'some-plugin'],
    },
  });
  ```

  Additionally, pino transport targets are now automatically detected from the
  bundled code, so most pino users won't need any configuration.

  This keeps `externals` for its intended purpose (packages to not bundle) and
  provides a clear mechanism for dynamic packages that need to be in the output
  package.json.

  Fixes #10893

### [@mastra/mcp@1.2.1](https://github.com/mastra-ai/mastra/blob/@mastra/mcp@1.2.1//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/packages/mcp/CHANGELOG.md)
#### Patch Changes

- Fixed TypeScript compilation errors when using MCP resource methods in projects with pnpm workspaces. ([#14229](https://github.com/mastra-ai/mastra/pull/14229))

### [@mastra/memory@1.8.0](https://github.com/mastra-ai/mastra/blob/@mastra/memory@1.8.0//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/packages/memory/CHANGELOG.md)
#### Minor Changes

- Added observer context optimization for Observational Memory. The `observation.previousObserverTokens` field reduces Observer input token costs for long-running conversations: ([#13568](https://github.com/mastra-ai/mastra/pull/13568))
  - **previousObserverTokens** (default: `2000`): Truncates the 'Previous Observations' section to a token budget, keeping the most recent observations and automatically replacing already-reflected lines with the buffered reflection summary. Set to `0` to omit previous observations entirely, or `false` to disable truncation and keep the full observation history.

  ```typescript
  const memory = new Memory({
    options: {
      observationalMemory: {
        model: 'google/gemini-2.5-flash',
        observation: {
          previousObserverTokens: 10_000,
        },
      },
    },
  });
  ```

#### Patch Changes

### [@mastra/observability@1.5.0](https://github.com/mastra-ai/mastra/blob/@mastra/observability@1.5.0//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/observability/mastra/CHANGELOG.md)
#### Minor Changes

- Updated exporters and event bus to use renamed observability types from `@mastra/core`. Added `EventBuffer` for batching non-tracing signals with configurable flush intervals. ([#14214](https://github.com/mastra-ai/mastra/pull/14214))

  **Breaking changes:**
  - `ObservabilityBus` now takes a config object in its constructor (`cardinalityFilter`, `autoExtractMetrics`); `setCardinalityFilter()` and `enableAutoExtractedMetrics()` removed

#### Patch Changes

### [@mastra/playground-ui@16.1.0](https://github.com/mastra-ai/mastra/blob/@mastra/playground-ui@16.1.0//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/packages/playground-ui/CHANGELOG.md)
#### Minor Changes

- Added group-by-thread utility for the Observability tab. Traces can now be grouped by their conversation thread ID, making it easier to follow multi-turn agent conversations in Studio. See [#14004](https://github.com/mastra-ai/mastra/issues/14004). ([#14112](https://github.com/mastra-ai/mastra/pull/14112))

#### Patch Changes

- Fixed agent playground panels growing together when content overflows. Left and right columns now scroll independently. ([#14244](https://github.com/mastra-ai/mastra/pull/14244))

- Fixed an agent chat editor crash in Playground UI caused by duplicate CodeMirror state instances. ([#14241](https://github.com/mastra-ai/mastra/pull/14241))

- Improved studio loading performance by lazy-loading the Prettier code formatter. Prettier and its plugins are now loaded on-demand when formatting is triggered, rather than being bundled in the initial page load. ([#13934](https://github.com/mastra-ai/mastra/pull/13934))

- Improved list-style pages across the Playground UI (agents, datasets, MCPs, processors, prompt blocks, scorers, tools, workflows) with a new list layout and updated empty states. ([#14173](https://github.com/mastra-ai/mastra/pull/14173))

### [@mastra/schema-compat@1.2.2](https://github.com/mastra-ai/mastra/blob/@mastra/schema-compat@1.2.2//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/packages/schema-compat/CHANGELOG.md)
#### Patch Changes

- `@mastra/schema-compat`: patch ([#14195](https://github.com/mastra-ai/mastra/pull/14195))

  Fixed published `@mastra/schema-compat` types so AI SDK v5 schemas resolve correctly for consumers

- Fixed false `z.toJSONSchema is not available` errors for compatible Zod versions. ([#14264](https://github.com/mastra-ai/mastra/pull/14264))

  **What changed**
  - Improved Zod schema conversion detection so JSON Schema generation works more reliably across different runtime setups.

### [@mastra/server@1.13.0](https://github.com/mastra-ai/mastra/blob/@mastra/server@1.13.0//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/packages/server/CHANGELOG.md)
#### Minor Changes

- Added `@mastra/server/schemas` export with utility types that infer path params, query params, request body, and response types from any route in `SERVER_ROUTES`. When you add a new route via `createRoute()`, it automatically appears in the `RouteMap` type — no manual contract needed. ([#14008](https://github.com/mastra-ai/mastra/pull/14008))

  ```ts
  import type { RouteMap, RouteContract, InferPathParams, InferBody, InferResponse } from '@mastra/server/schemas';

  type GetAgentParams = InferPathParams<RouteMap['GET /agents/:agentId']>;
  // => { agentId: string }

  type GenerateBody = InferBody<RouteMap['POST /agents/:agentId/generate']>;
  // => { messages: CoreMessage[], ... }

  type AgentResponse = InferResponse<RouteMap['GET /agents/:agentId']>;
  // => { name: string, tools: ..., ... }
  ```

#### Patch Changes

- Fixed OpenAPI spec for custom route paths. Custom routes registered via `registerApiRoute` are served at the root path (e.g. `/health`), not under `/api`. The OpenAPI spec now correctly represents this so that API tools and clients using the spec will resolve them to the correct URL. ([#13930](https://github.com/mastra-ai/mastra/pull/13930))

- Fixed an unnecessary runtime dependency in `@mastra/server`, reducing install size for consumers. Moved `@mastra/schema-compat` from dependencies to devDependencies since it is only needed at build time. ([#14223](https://github.com/mastra-ai/mastra/pull/14223))

### Other updated packages

The following packages were updated with dependency changes only:

- [@mastra/agent-builder@1.0.13](https://github.com/mastra-ai/mastra/blob/@mastra/agent-builder@1.0.13//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/packages/agent-builder/CHANGELOG.md)
- [@mastra/arize@1.0.8](https://github.com/mastra-ai/mastra/blob/@mastra/arize@1.0.8//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/observability/arize/CHANGELOG.md)
- [@mastra/braintrust@1.0.8](https://github.com/mastra-ai/mastra/blob/@mastra/braintrust@1.0.8//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/observability/braintrust/CHANGELOG.md)
- [@mastra/client-js@1.8.2](https://github.com/mastra-ai/mastra/blob/@mastra/client-js@1.8.2//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/client-sdks/client-js/CHANGELOG.md)
- [@mastra/datadog@1.0.7](https://github.com/mastra-ai/mastra/blob/@mastra/datadog@1.0.7//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/observability/datadog/CHANGELOG.md)
- [@mastra/deployer-cloud@1.13.0](https://github.com/mastra-ai/mastra/blob/@mastra/deployer-cloud@1.13.0//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/deployers/cloud/CHANGELOG.md)
- [@mastra/deployer-cloudflare@1.1.10](https://github.com/mastra-ai/mastra/blob/@mastra/deployer-cloudflare@1.1.10//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/deployers/cloudflare/CHANGELOG.md)
- [@mastra/deployer-netlify@1.0.14](https://github.com/mastra-ai/mastra/blob/@mastra/deployer-netlify@1.0.14//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/deployers/netlify/CHANGELOG.md)
- [@mastra/deployer-vercel@1.1.4](https://github.com/mastra-ai/mastra/blob/@mastra/deployer-vercel@1.1.4//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/deployers/vercel/CHANGELOG.md)
- [@mastra/express@1.2.2](https://github.com/mastra-ai/mastra/blob/@mastra/express@1.2.2//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/server-adapters/express/CHANGELOG.md)
- [@mastra/fastify@1.2.2](https://github.com/mastra-ai/mastra/blob/@mastra/fastify@1.2.2//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/server-adapters/fastify/CHANGELOG.md)
- [@mastra/hono@1.2.2](https://github.com/mastra-ai/mastra/blob/@mastra/hono@1.2.2//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/server-adapters/hono/CHANGELOG.md)
- [@mastra/koa@1.3.2](https://github.com/mastra-ai/mastra/blob/@mastra/koa@1.3.2//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/server-adapters/koa/CHANGELOG.md)
- [@mastra/laminar@1.0.7](https://github.com/mastra-ai/mastra/blob/@mastra/laminar@1.0.7//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/observability/laminar/CHANGELOG.md)
- [@mastra/langfuse@1.0.7](https://github.com/mastra-ai/mastra/blob/@mastra/langfuse@1.0.7//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/observability/langfuse/CHANGELOG.md)
- [@mastra/langsmith@1.1.5](https://github.com/mastra-ai/mastra/blob/@mastra/langsmith@1.1.5//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/observability/langsmith/CHANGELOG.md)
- [@mastra/longmemeval@1.0.14](https://github.com/mastra-ai/mastra/blob/@mastra/longmemeval@1.0.14//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/explorations/longmemeval/CHANGELOG.md)
- [@mastra/mcp-docs-server@1.1.11](https://github.com/mastra-ai/mastra/blob/@mastra/mcp-docs-server@1.1.11//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/packages/mcp-docs-server/CHANGELOG.md)
- [@mastra/opencode@0.0.11](https://github.com/mastra-ai/mastra/blob/@mastra/opencode@0.0.11//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/integrations/opencode/CHANGELOG.md)
- [@mastra/otel-bridge@1.0.7](https://github.com/mastra-ai/mastra/blob/@mastra/otel-bridge@1.0.7//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/observability/otel-bridge/CHANGELOG.md)
- [@mastra/otel-exporter@1.0.7](https://github.com/mastra-ai/mastra/blob/@mastra/otel-exporter@1.0.7//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/observability/otel-exporter/CHANGELOG.md)
- [@mastra/posthog@1.0.8](https://github.com/mastra-ai/mastra/blob/@mastra/posthog@1.0.8//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/observability/posthog/CHANGELOG.md)
- [@mastra/react@0.2.12](https://github.com/mastra-ai/mastra/blob/@mastra/react@0.2.12//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/client-sdks/react/CHANGELOG.md)
- [@mastra/sentry@1.0.7](https://github.com/mastra-ai/mastra/blob/@mastra/sentry@1.0.7//private/var/folders/d4/mn8gvlx91cz80s_9c4gjr12r0000gn/T/mastra-mastra-ai-mastra-_mastra_core_1.13.0/observability/sentry/CHANGELOG.md)