@mastra/pg 1.15.1 → 1.16.0-alpha.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @mastra/pg
2
2
 
3
+ ## 1.16.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added atomic caller-defined dataset IDs for idempotent dataset creation across built-in storage adapters. Supplying `id` to `mastra.datasets.create()` now creates the dataset once and resolves compatible retries to the persisted record; incompatible immutable identity fields throw `DATASET_ID_CONFLICT`. ([#19370](https://github.com/mastra-ai/mastra/pull/19370))
8
+
9
+ - Added caller-defined dataset item identities for safe retries across all dataset storage adapters. ([#19384](https://github.com/mastra-ai/mastra/pull/19384))
10
+
11
+ Dataset items can now include an `externalId` when calling `addItem` or `addItems`:
12
+
13
+ ```ts
14
+ await dataset.addItem({
15
+ externalId: 'source-item-123',
16
+ input: { prompt: 'Hello' },
17
+ });
18
+ ```
19
+
20
+ Retrying with the same identity and payload returns the existing item. Reusing an identity with different content returns a typed conflict, including during concurrent writes. Updates and deletes preserve the identity, Spanner retries transactions without changing the outcome, and MySQL batch writes now preserve every supported dataset item field.
21
+
22
+ ### Patch Changes
23
+
24
+ - Raised the `@mastra/core` peer dependency floor to `>=1.51.0-0` so the dataset item identity helpers used by the storage adapters are available at runtime. ([#19384](https://github.com/mastra-ai/mastra/pull/19384))
25
+
26
+ - Updated dependencies [[`a99eae8`](https://github.com/mastra-ai/mastra/commit/a99eae8908e500c1b2d12f9d277be616b98617a5), [`fd13f8e`](https://github.com/mastra-ai/mastra/commit/fd13f8e21990f9904c3eedba3a626bb4a929cdb8), [`f703f87`](https://github.com/mastra-ai/mastra/commit/f703f878de072d51fda557f9c50867d8252bef05), [`0ad646f`](https://github.com/mastra-ai/mastra/commit/0ad646f71a530f2454664299e5e01bfd13fa12e5)]:
27
+ - @mastra/core@1.51.0-alpha.13
28
+
3
29
  ## 1.15.1
4
30
 
5
31
  ### Patch Changes
@@ -3,7 +3,7 @@ name: mastra-pg
3
3
  description: Documentation for @mastra/pg. Use when working with @mastra/pg APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/pg"
6
- version: "1.15.1"
6
+ version: "1.16.0-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -17,11 +17,11 @@ Read the individual reference documents for detailed explanations and code examp
17
17
  ### Docs
18
18
 
19
19
  - [Semantic recall](references/docs-memory-semantic-recall.md) - Learn how to use semantic recall in Mastra to retrieve relevant messages from past conversations using vector search and embeddings.
20
- - [Storage](references/docs-memory-storage.md) - Configure storage for Mastra to persist conversations and other runtime state.
21
20
  - [Working memory](references/docs-memory-working-memory.md) - Learn how to configure working memory in Mastra to store persistent user data, preferences.
22
21
  - [RAG (Retrieval-Augmented Generation) in Mastra](references/docs-rag-overview.md) - Overview of Retrieval-Augmented Generation (RAG) in Mastra, detailing its capabilities for enhancing LLM outputs with relevant context.
23
22
  - [Retrieval, semantic search, reranking](references/docs-rag-retrieval.md) - Guide on retrieval processes in Mastra's RAG systems, including semantic search, filtering, and re-ranking.
24
23
  - [Storing embeddings in a vector database](references/docs-rag-vector-databases.md) - Guide on vector storage options in Mastra, including embedded and dedicated vector databases for similarity search.
24
+ - [Storage overview](references/docs-storage-overview.md) - Configure storage for Mastra to persist runtime state across agents, workflows, observability, evals, schedules, and memory.
25
25
 
26
26
  ### Reference
27
27
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.15.1",
2
+ "version": "1.16.0-alpha.0",
3
3
  "package": "@mastra/pg",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -4,7 +4,7 @@
4
4
 
5
5
  If you ask your friend what they did last weekend, they will search in their memory for events associated with "last weekend" and then tell you what they did. That's sort of like how semantic recall works in Mastra.
6
6
 
7
- > **Watch 📹:** What semantic recall is, how it works, and how to configure it in Mastra [YouTube (5 minutes)](https://youtu.be/UVZtK8cK8xQ)
7
+ > **📹 Watch:** Watch [Mastra semantic recall](https://www.youtube.com/watch?v=UVZtK8cK8xQ\&pp=ygUVbWFzdHJhIHdvcmtpbmcgbWVtb3J5) to see how agents retrieve relevant messages from past conversations.
8
8
 
9
9
  ## How semantic recall works
10
10
 
@@ -22,6 +22,8 @@ After getting a response from the LLM, all new messages (user, assistant, and to
22
22
 
23
23
  Semantic recall is disabled by default. To enable it, set `semanticRecall: true` in `options` and provide a `vector` store and `embedder`:
24
24
 
25
+ **LibSQL**:
26
+
25
27
  ```typescript
26
28
  import { Agent } from '@mastra/core/agent'
27
29
  import { Memory } from '@mastra/memory'
@@ -50,6 +52,38 @@ const agent = new Agent({
50
52
  })
51
53
  ```
52
54
 
55
+ **MongoDB**:
56
+
57
+ ```typescript
58
+ import { Agent } from '@mastra/core/agent'
59
+ import { Memory } from '@mastra/memory'
60
+ import { MongoDBStore, MongoDBVector } from '@mastra/mongodb'
61
+ import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
62
+
63
+ const agent = new Agent({
64
+ id: 'support-agent',
65
+ name: 'SupportAgent',
66
+ instructions: 'You are a helpful support agent.',
67
+ model: 'openai/gpt-5.5',
68
+ memory: new Memory({
69
+ storage: new MongoDBStore({
70
+ id: 'agent-storage',
71
+ uri: process.env.MONGODB_URI,
72
+ dbName: process.env.MONGODB_DB_NAME,
73
+ }),
74
+ vector: new MongoDBVector({
75
+ id: 'agent-vector',
76
+ uri: process.env.MONGODB_URI,
77
+ dbName: process.env.MONGODB_DB_NAME,
78
+ }),
79
+ embedder: new ModelRouterEmbeddingModel('openai/text-embedding-3-small'),
80
+ options: {
81
+ semanticRecall: true,
82
+ },
83
+ }),
84
+ })
85
+ ```
86
+
53
87
  ## Using the `recall()` method
54
88
 
55
89
  While `listMessages` retrieves messages by thread ID with basic pagination, [`recall()`](https://mastra.ai/reference/memory/recall) adds support for **semantic search**. When you need to find messages by meaning rather than recency, use `recall()` with a `vectorSearchString`:
@@ -146,7 +180,7 @@ const agent = new Agent({
146
180
  })
147
181
  ```
148
182
 
149
- > **Note:** `scope: 'resource'` is supported by the LibSQL, PostgreSQL, and Upstash storage adapters.
183
+ > **Note:** `scope: 'resource'` is supported by the LibSQL, PostgreSQL, MongoDB, and Upstash storage adapters.
150
184
 
151
185
  ### Metadata filtering
152
186
 
@@ -10,6 +10,8 @@ This is useful for maintaining ongoing state that's always relevant and should a
10
10
 
11
11
  If you use [Observational Memory](https://mastra.ai/docs/memory/observational-memory), `observationalMemory.observation.manageWorkingMemory` lets OM update working memory for the agent.
12
12
 
13
+ > **📹 Watch:** Watch [Mastra working memory](https://www.youtube.com/watch?v=UMy_JHLf1n8\&pp=ygUVbWFzdHJhIHdvcmtpbmcgbWVtb3J5) to see how agents keep persistent user context available across interactions.
14
+
13
15
  Working memory can persist at two different scopes:
14
16
 
15
17
  - **Resource-scoped** (default): Memory persists across all conversation threads for the same user
@@ -43,9 +45,7 @@ const agent = new Agent({
43
45
 
44
46
  ## How it works
45
47
 
46
- Working memory is a block of Markdown text that the agent is able to update over time to store continuously relevant information:
47
-
48
- [YouTube video player](https://www.youtube-nocookie.com/embed/UMy_JHLf1n8)
48
+ Working memory is a block of Markdown text that the agent is able to update over time to store continuously relevant information.
49
49
 
50
50
  ## Memory persistence scopes
51
51
 
@@ -14,7 +14,7 @@ import { MongoDBVector } from '@mastra/mongodb'
14
14
  const store = new MongoDBVector({
15
15
  id: 'mongodb-vector',
16
16
  uri: process.env.MONGODB_URI,
17
- dbName: process.env.MONGODB_DATABASE,
17
+ dbName: process.env.MONGODB_DB_NAME,
18
18
  })
19
19
  await store.createIndex({
20
20
  indexName: 'myCollection',
@@ -27,10 +27,14 @@ await store.upsert({
27
27
  })
28
28
  ```
29
29
 
30
- ### Using MongoDB Atlas Vector search
30
+ ### Using MongoDB Atlas Vector Search
31
31
 
32
32
  For detailed setup instructions and best practices, see the [official MongoDB Atlas Vector Search documentation](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/?utm_campaign=devrel\&utm_source=third-party-content\&utm_medium=cta\&utm_content=mastra-docs).
33
33
 
34
+ ### Using VoyageAI with MongoDB
35
+
36
+ MongoDB works seamlessly with VoyageAI's embedding models, which are optimized for retrieval tasks. For complete examples and specialized models, see the [VoyageAI embeddings documentation](https://mastra.ai/models/embeddings) and [MongoDB vector reference](https://mastra.ai/reference/vectors/mongodb).
37
+
34
38
  **PgVector**:
35
39
 
36
40
  ```ts
@@ -359,6 +363,7 @@ The dimension size must match the output dimension of your chosen embedding mode
359
363
 
360
364
  - `OpenAI text-embedding-3-small`: 1536 dimensions (or custom, e.g., 256)
361
365
  - `Cohere embed-multilingual-v3`: 1024 dimensions
366
+ - `VoyageAI voyage-3.5`: 1024 dimensions (or custom: 256, 512, 1024, 2048)
362
367
  - `Google gemini-embedding-001`: 768 dimensions (or custom)
363
368
 
364
369
  > **Warning:** Index dimensions can't be changed after creation. To use a different model, delete and recreate the index with the new dimension size.
@@ -0,0 +1,214 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Storage overview
4
+
5
+ Storage is the persistence layer for the Mastra runtime. It keeps memory, workflow state, observability data, eval results, schedules, and long-running agent state available after a process restarts.
6
+
7
+ Storage powers:
8
+
9
+ - [Memory](https://mastra.ai/docs/memory/overview): Message history, threads, resources, and working memory.
10
+ - [Workflows](https://mastra.ai/docs/workflows/overview): Durable snapshots for suspended and resumed workflow runs.
11
+ - [Observability](https://mastra.ai/docs/observability/overview): Traces, spans, metrics, logs, and feedback.
12
+ - [Evals](https://mastra.ai/docs/evals/overview): Scores, datasets, experiments, and evaluation results.
13
+ - [Long-running agents](https://mastra.ai/docs/long-running-agents/durable-agents): Background tasks, schedules, goals, and thread state.
14
+
15
+ ## When to configure storage
16
+
17
+ Configure a persistent storage adapter when state must survive restarts, be shared across processes, or be visible in Studio across sessions. The default in-memory store is useful for tests and short local experiments, but it loses data when the process exits.
18
+
19
+ Use storage when your application needs any of these behaviors:
20
+
21
+ - Agents remember past messages or user facts.
22
+ - Workflows suspend and resume after a restart.
23
+ - Traces, metrics, logs, scores, or feedback stay available for analysis.
24
+ - Schedules and background tasks continue across deployments.
25
+ - Multiple runtime processes read and write the same state.
26
+
27
+ ## How storage works
28
+
29
+ Mastra storage is organized into **domains**. A domain owns one type of runtime data, and a storage adapter implements one or more domains.
30
+
31
+ | Domain | What it stores |
32
+ | ----------------- | --------------------------------------------------------------------------- |
33
+ | `memory` | Threads, messages, resources, working memory, and other agent memory state. |
34
+ | `workflows` | Workflow snapshots used to suspend and resume runs. |
35
+ | `observability` | Traces, spans, metrics, logs, and feedback. |
36
+ | `scores` | Eval score records. |
37
+ | `datasets` | Dataset records and dataset items used by evals and experiments. |
38
+ | `experiments` | Experiment runs and per-item experiment results. |
39
+ | `backgroundTasks` | Background task records and execution state. |
40
+ | `schedules` | Schedule definitions and trigger history. |
41
+ | `threadState` | Durable task, goal, and thread state. |
42
+
43
+ Adapter support varies by domain. For the full domain list and built-in schemas, see the [storage overview reference](https://mastra.ai/reference/storage/overview).
44
+
45
+ ## Choose a backend by data shape
46
+
47
+ Different domains write and query different kinds of data. Pick a backend based on the domain's access pattern:
48
+
49
+ - `memory`: Reads and writes rows during every remembered agent call. Use a transactional database such as libSQL, PostgreSQL, or MongoDB.
50
+ - `observability`: Writes high-volume telemetry and often queries aggregations. Use a dedicated observability store or an online analytical processing (OLAP) backend such as ClickHouse or DuckDB.
51
+ - `workflows`: Stores durable snapshots that must be available when a run resumes. Use a reliable persistent database.
52
+ - `scores`, `datasets`, and `experiments`: Store lower-frequency evaluation data that's often read later for analysis.
53
+ - `schedules`: Stores schedule definitions and fire history. Use an adapter that implements the schedules domain.
54
+
55
+ When domains have different operational needs, use [composite storage](#composite-storage) to route each domain to the right backend.
56
+
57
+ ## Get started locally
58
+
59
+ For local development, use libSQL with a file-backed database. It doesn't require a separate database server and persists state between restarts.
60
+
61
+ ```typescript
62
+ import { Mastra } from '@mastra/core'
63
+ import { LibSQLStore } from '@mastra/libsql'
64
+
65
+ export const mastra = new Mastra({
66
+ storage: new LibSQLStore({
67
+ id: 'mastra-storage',
68
+ url: 'file:./mastra.db',
69
+ }),
70
+ })
71
+ ```
72
+
73
+ > **Sharing the database with Studio:** When running `mastra dev` alongside your application, use an absolute path so both processes access the same database:
74
+ >
75
+ > ```typescript
76
+ > url: 'file:/absolute/path/to/your/project/mastra.db'
77
+ > ```
78
+ >
79
+ > Relative paths like `file:./mastra.db` resolve based on each process's working directory, which may differ.
80
+
81
+ Mastra initializes the required storage structures on first use.
82
+
83
+ ## Configure for production
84
+
85
+ For production, use a persistent managed database. PostgreSQL is a good default for most teams because it works well for transactional runtime state and is widely available as a managed service.
86
+
87
+ Production guidance:
88
+
89
+ - Use a managed database with backups, monitoring, and connection pooling.
90
+ - Keep local file databases such as `file:./mastra.db` out of multi-process production deployments.
91
+ - Route high-volume domains, especially `observability`, to a dedicated backend with [composite storage](#composite-storage).
92
+ - Configure [retention](https://mastra.ai/reference/storage/retention) policies on the storage adapter or composite store, then call `storage.prune()` from a scheduler or maintenance job.
93
+ - Choose providers based on the domains your application uses. For example, schedules require an adapter that implements the `schedules` domain.
94
+
95
+ ## Configuration scope
96
+
97
+ Storage can be configured at the Mastra instance level or at the agent level.
98
+
99
+ ### Instance-level storage
100
+
101
+ Instance-level storage is shared by agents, workflows, observability, evals, schedules, and other runtime features registered on the same Mastra instance.
102
+
103
+ **PostgreSQL**:
104
+
105
+ ```typescript
106
+ import { Mastra } from '@mastra/core'
107
+ import { PostgresStore } from '@mastra/pg'
108
+
109
+ export const mastra = new Mastra({
110
+ storage: new PostgresStore({
111
+ id: 'mastra-storage',
112
+ connectionString: process.env.DATABASE_URL,
113
+ }),
114
+ })
115
+ ```
116
+
117
+ **MongoDB**:
118
+
119
+ ```typescript
120
+ import { Mastra } from '@mastra/core'
121
+ import { MongoDBStore } from '@mastra/mongodb'
122
+
123
+ export const mastra = new Mastra({
124
+ storage: new MongoDBStore({
125
+ id: 'mastra-storage',
126
+ uri: process.env.MONGODB_URI,
127
+ dbName: process.env.MONGODB_DB_NAME,
128
+ }),
129
+ })
130
+ ```
131
+
132
+ Use instance-level storage when most runtime domains can share the same database.
133
+
134
+ ### Agent-level storage
135
+
136
+ Agent-level storage is configured on a `Memory` instance. It overrides instance-level storage for that agent's memory data only.
137
+
138
+ ```typescript
139
+ import { Agent } from '@mastra/core/agent'
140
+ import { Memory } from '@mastra/memory'
141
+ import { PostgresStore } from '@mastra/pg'
142
+
143
+ export const supportAgent = new Agent({
144
+ id: 'support-agent',
145
+ name: 'Support agent',
146
+ instructions: 'Answer customer support questions.',
147
+ model: 'openai/gpt-5.5',
148
+ memory: new Memory({
149
+ storage: new PostgresStore({
150
+ id: 'support-agent-storage',
151
+ connectionString: process.env.SUPPORT_AGENT_DATABASE_URL,
152
+ }),
153
+ }),
154
+ })
155
+ ```
156
+
157
+ Use agent-level storage when an agent needs an isolated memory boundary or a different memory backend.
158
+
159
+ ## Composite storage
160
+
161
+ [`MastraCompositeStore`](https://mastra.ai/reference/storage/composite) routes domains to different backends. Use it when one database isn't the right fit for every domain.
162
+
163
+ The following example uses libSQL as the default store and routes workflow state to PostgreSQL:
164
+
165
+ ```typescript
166
+ import { Mastra } from '@mastra/core'
167
+ import { MastraCompositeStore } from '@mastra/core/storage'
168
+ import { LibSQLStore } from '@mastra/libsql'
169
+ import { WorkflowsPG } from '@mastra/pg'
170
+
171
+ export const mastra = new Mastra({
172
+ storage: new MastraCompositeStore({
173
+ id: 'composite-storage',
174
+ default: new LibSQLStore({
175
+ id: 'default-storage',
176
+ url: 'file:./mastra.db',
177
+ }),
178
+ domains: {
179
+ workflows: new WorkflowsPG({
180
+ connectionString: process.env.DATABASE_URL,
181
+ }),
182
+ },
183
+ }),
184
+ })
185
+ ```
186
+
187
+ You can also route `observability` to a dedicated analytics backend. See [observability storage](https://mastra.ai/docs/observability/storage) for an observability-specific example.
188
+
189
+ ## Supported providers
190
+
191
+ Each provider page includes installation instructions, configuration parameters, and usage examples:
192
+
193
+ - [libSQL](https://mastra.ai/reference/storage/libsql)
194
+ - [PostgreSQL](https://mastra.ai/reference/storage/postgresql)
195
+ - [MongoDB](https://mastra.ai/reference/storage/mongodb)
196
+ - [Upstash](https://mastra.ai/reference/storage/upstash)
197
+ - [Redis](https://mastra.ai/reference/storage/redis)
198
+ - [Cloudflare D1](https://mastra.ai/reference/storage/cloudflare-d1)
199
+ - [Cloudflare KV & Durable Objects](https://mastra.ai/reference/storage/cloudflare)
200
+ - [Convex](https://mastra.ai/reference/storage/convex)
201
+ - [DynamoDB](https://mastra.ai/reference/storage/dynamodb)
202
+ - [LanceDB](https://mastra.ai/reference/storage/lance)
203
+ - [Microsoft SQL Server](https://mastra.ai/reference/storage/mssql)
204
+ - [Google Cloud Spanner](https://mastra.ai/reference/storage/spanner)
205
+
206
+ > **Tip:** libSQL is the fastest path for local development because it doesn't require running a separate database server.
207
+
208
+ ## Next steps
209
+
210
+ - [Composite storage](https://mastra.ai/reference/storage/composite)
211
+ - [Storage retention](https://mastra.ai/reference/storage/retention)
212
+ - [Storage schemas](https://mastra.ai/reference/storage/overview)
213
+ - [Memory](https://mastra.ai/docs/memory/overview)
214
+ - [Observability storage](https://mastra.ai/docs/observability/storage)
@@ -37,7 +37,7 @@ export const agent = new Agent({
37
37
 
38
38
  **options** (`MemoryConfig`): Memory configuration options.
39
39
 
40
- **options.lastMessages** (`number | false`): Number of most recent messages to include in context. Set to false to disable loading conversation history into context. Use Number.MAX\_SAFE\_INTEGER to retrieve all messages with no limit. To prevent saving new messages, use the readOnly option instead.
40
+ **options.lastMessages** (`number | false`): Number of most recent messages to include in context. Set to false to disable the message history feature entirely (messages are not loaded into context or saved). Use Number.MAX\_SAFE\_INTEGER to retrieve all messages with no limit. To load messages without saving new ones, use the readOnly option.
41
41
 
42
42
  **options.readOnly** (`boolean`): When true, prevents memory from saving new messages and provides working memory as read-only context (without the updateWorkingMemory tool). Useful for read-only operations like previews, internal routing agents, or sub agents that should reference but not modify memory.
43
43
 
@@ -37,25 +37,25 @@ You'll also need to install the storage providers you want to compose:
37
37
  **npm**:
38
38
 
39
39
  ```bash
40
- npm install @mastra/pg@latest @mastra/libsql@latest
40
+ npm install @mastra/pg@latest @mastra/libsql@latest @mastra/mongodb@latest
41
41
  ```
42
42
 
43
43
  **pnpm**:
44
44
 
45
45
  ```bash
46
- pnpm add @mastra/pg@latest @mastra/libsql@latest
46
+ pnpm add @mastra/pg@latest @mastra/libsql@latest @mastra/mongodb@latest
47
47
  ```
48
48
 
49
49
  **Yarn**:
50
50
 
51
51
  ```bash
52
- yarn add @mastra/pg@latest @mastra/libsql@latest
52
+ yarn add @mastra/pg@latest @mastra/libsql@latest @mastra/mongodb@latest
53
53
  ```
54
54
 
55
55
  **Bun**:
56
56
 
57
57
  ```bash
58
- bun add @mastra/pg@latest @mastra/libsql@latest
58
+ bun add @mastra/pg@latest @mastra/libsql@latest @mastra/mongodb@latest
59
59
  ```
60
60
 
61
61
  ## Storage domains
@@ -124,6 +124,64 @@ export const mastra = new Mastra({
124
124
  })
125
125
  ```
126
126
 
127
+ ### Mixed backends
128
+
129
+ Use domain classes from each storage package to route different domains to different backends. The following example stores memory and workflow state in MongoDB, then routes observability to ClickHouse:
130
+
131
+ ```typescript
132
+ import { Mastra } from '@mastra/core'
133
+ import { MastraCompositeStore } from '@mastra/core/storage'
134
+ import { ObservabilityStorageClickhouse } from '@mastra/clickhouse'
135
+ import { MemoryStorageMongoDB, WorkflowsStorageMongoDB } from '@mastra/mongodb'
136
+
137
+ export const mastra = new Mastra({
138
+ storage: new MastraCompositeStore({
139
+ id: 'composite',
140
+ domains: {
141
+ memory: new MemoryStorageMongoDB({
142
+ uri: process.env.MONGODB_URI,
143
+ dbName: 'mastra_memory',
144
+ }),
145
+ workflows: new WorkflowsStorageMongoDB({
146
+ uri: process.env.MONGODB_URI,
147
+ dbName: 'mastra_workflows',
148
+ }),
149
+ observability: new ObservabilityStorageClickhouse({
150
+ url: process.env.CLICKHOUSE_URL,
151
+ username: process.env.CLICKHOUSE_USERNAME,
152
+ password: process.env.CLICKHOUSE_PASSWORD,
153
+ }),
154
+ },
155
+ }),
156
+ })
157
+ ```
158
+
159
+ ### Disabling a domain
160
+
161
+ Set a domain to `false` to disable it. A disabled domain doesn't fall back to `default`, so data for that domain isn't persisted:
162
+
163
+ ```typescript
164
+ import { MastraCompositeStore } from '@mastra/core/storage'
165
+ import { PostgresStore } from '@mastra/pg'
166
+ import { Mastra } from '@mastra/core'
167
+
168
+ const pgStore = new PostgresStore({
169
+ id: 'pg',
170
+ connectionString: process.env.DATABASE_URL,
171
+ })
172
+
173
+ export const mastra = new Mastra({
174
+ storage: new MastraCompositeStore({
175
+ id: 'composite',
176
+ default: pgStore,
177
+ domains: {
178
+ // don't persist traces and spans
179
+ observability: false,
180
+ },
181
+ }),
182
+ })
183
+ ```
184
+
127
185
  ## Options
128
186
 
129
187
  **id** (`string`): Unique identifier for this storage instance.
@@ -132,7 +190,7 @@ export const mastra = new Mastra({
132
190
 
133
191
  **disableInit** (`boolean`): When true, automatic initialization is disabled. You must call init() explicitly.
134
192
 
135
- **domains** (`object`): Individual domain overrides. Each domain can come from a different storage adapter. These take precedence over both editor and default storage.
193
+ **domains** (`object`): Individual domain overrides. Each domain can come from a different storage adapter. These take precedence over both editor and default storage. Set a domain to false to disable it entirely; a disabled domain does not fall back to editor or default.
136
194
 
137
195
  **domains.memory** (`MemoryStorage`): Storage for threads, messages, and resources.
138
196
 
@@ -274,6 +332,6 @@ const storage = new MastraCompositeStore({
274
332
  })
275
333
  ```
276
334
 
277
- Do not set `replication` on ClickHouse Cloud. Cloud rewrites `MergeTree` to `SharedMergeTree` server-side. See the [ClickHouse storage reference](https://mastra.ai/reference/storage/clickhouse) for the full config shape and operator notes.
335
+ Don't set `replication` on ClickHouse Cloud. Cloud rewrites `MergeTree` to `SharedMergeTree` server-side. See the [ClickHouse storage reference](https://mastra.ai/reference/storage/clickhouse) for the full config shape and operator notes.
278
336
 
279
337
  > **Info:** This approach is also required when using storage providers that don't support observability (like Convex, DynamoDB, or Cloudflare). See the [MastraStorageExporter documentation](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage) for the full list of supported providers.
@@ -6,7 +6,7 @@ The DynamoDB storage implementation provides a scalable and performant NoSQL dat
6
6
 
7
7
  > **Observability Not Supported:** DynamoDB storage **doesn't support the observability domain**. Traces from the `MastraStorageExporter` can't be persisted to DynamoDB, and [Studio's](https://mastra.ai/docs/studio/overview) observability features won't work with DynamoDB as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider like ClickHouse.
8
8
 
9
- > **Item Size Limit:** DynamoDB enforces a **400 KB maximum item size**. This limit can be exceeded when storing messages with base64-encoded attachments such as images. See [Handling large attachments](https://mastra.ai/docs/memory/storage) for workarounds including uploading attachments to external storage.
9
+ > **Item Size Limit:** DynamoDB enforces a **400 KB maximum item size**. This limit can be exceeded when storing messages with base64-encoded attachments such as images. See [Handling large attachments](https://mastra.ai/docs/memory/memory-processors) for workarounds including uploading attachments to external storage.
10
10
 
11
11
  ## Features
12
12