@mastra/mcp-docs-server 1.3.13-alpha.0 → 1.3.13-alpha.11

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 (166) hide show
  1. package/.docs/docs/agents/resumable-streams.md +140 -0
  2. package/.docs/docs/agents/tools.md +3 -2
  3. package/.docs/docs/auth/overview.md +1 -0
  4. package/.docs/docs/channels.md +34 -1
  5. package/.docs/docs/connections/mcp.md +34 -67
  6. package/.docs/docs/deployment/mastra-server.md +10 -2
  7. package/.docs/docs/deployment/workers.md +3 -1
  8. package/.docs/docs/harness/background-tasks.md +2 -1
  9. package/.docs/docs/harness/durable-agents.md +106 -8
  10. package/.docs/docs/harness/schedules.md +2 -0
  11. package/.docs/docs/mastra-platform/connect.md +231 -0
  12. package/.docs/docs/mastra-platform/overview.md +1 -1
  13. package/.docs/docs/memory/semantic-recall.md +26 -1
  14. package/.docs/docs/observability/feedback.md +5 -7
  15. package/.docs/docs/observability/integrations/exporters/mastra-storage.md +41 -0
  16. package/.docs/docs/observability/tracing/overview.md +0 -2
  17. package/.docs/docs/sandbox/skills.md +32 -3
  18. package/.docs/docs/server/custom-adapters.md +40 -11
  19. package/.docs/docs/server/middleware.md +1 -1
  20. package/.docs/docs/signals/sending-signals.md +3 -1
  21. package/.docs/docs/workflows/overview.md +12 -0
  22. package/.docs/docs/workflows/suspend-and-resume.md +1 -1
  23. package/.docs/integrations/agentic-ui/ai-sdk-ui.md +46 -0
  24. package/.docs/integrations/auth/clerk.md +46 -7
  25. package/.docs/integrations/auth/neon.md +217 -0
  26. package/.docs/integrations/auth/supabase.md +46 -7
  27. package/.docs/integrations/auth/workos.md +54 -15
  28. package/.docs/integrations/channels/discord.md +84 -6
  29. package/.docs/integrations/channels/github.md +63 -24
  30. package/.docs/integrations/channels/slack.md +89 -8
  31. package/.docs/integrations/channels/teams.md +79 -5
  32. package/.docs/integrations/channels/telegram.md +47 -6
  33. package/.docs/integrations/crm/attio.md +42 -0
  34. package/.docs/integrations/crm/clay.md +42 -0
  35. package/.docs/integrations/crm/hubspot.md +41 -0
  36. package/.docs/integrations/databases/neon.md +37 -1
  37. package/.docs/integrations/databases/postgresql.md +46 -0
  38. package/.docs/integrations/deploy/render.md +59 -18
  39. package/.docs/integrations/deploy/temporal.md +74 -0
  40. package/.docs/integrations/documents/google-docs.md +41 -0
  41. package/.docs/integrations/documents/google-sheet.md +41 -0
  42. package/.docs/integrations/documents/microsoft-excel.md +43 -0
  43. package/.docs/integrations/documents/microsoft-powerpoint.md +41 -0
  44. package/.docs/integrations/documents/microsoft-word.md +41 -0
  45. package/.docs/integrations/documents/notion.md +41 -0
  46. package/.docs/integrations/documents/one-drive.md +41 -0
  47. package/.docs/integrations/documents/sharepoint-online.md +41 -0
  48. package/.docs/integrations/email-calendar/google-calendar.md +41 -0
  49. package/.docs/integrations/email-calendar/google-mail.md +41 -0
  50. package/.docs/integrations/email-calendar/outlook.md +41 -0
  51. package/.docs/integrations/file-storage/amazon-s3.md +1 -1
  52. package/.docs/integrations/file-storage/google-drive.md +54 -15
  53. package/.docs/integrations/observability/arize.md +1 -1
  54. package/.docs/integrations/observability/posthog.md +50 -11
  55. package/.docs/integrations/other/canva.md +42 -0
  56. package/.docs/integrations/other/fireflies.md +41 -0
  57. package/.docs/integrations/other/incident-io.md +41 -0
  58. package/.docs/integrations/other/resend.md +43 -0
  59. package/.docs/integrations/other/robinhood.md +44 -0
  60. package/.docs/integrations/other/sanity.md +42 -0
  61. package/.docs/integrations/other/snowflake.md +41 -0
  62. package/.docs/integrations/project-management/jira.md +41 -0
  63. package/.docs/integrations/project-management/linear.md +41 -0
  64. package/.docs/integrations/sandboxes/docker.md +39 -0
  65. package/.docs/integrations/sandboxes/e2b.md +1 -1
  66. package/.docs/integrations/voice/openai.md +40 -0
  67. package/.docs/integrations.md +40 -1
  68. package/.docs/models/environment-variables.md +1 -1
  69. package/.docs/models/gateways/azure-openai.md +61 -2
  70. package/.docs/models/gateways/custom-gateways.md +2 -0
  71. package/.docs/models/gateways/merge-gateway.md +3 -1
  72. package/.docs/models/gateways/netlify.md +11 -7
  73. package/.docs/models/gateways/openrouter.md +13 -12
  74. package/.docs/models/gateways/requesty.md +221 -0
  75. package/.docs/models/gateways/vercel.md +423 -420
  76. package/.docs/models/gateways.md +7 -1
  77. package/.docs/models/index.md +46 -3
  78. package/.docs/models/providers/aiand.md +1 -1
  79. package/.docs/models/providers/aihubmix.md +2 -0
  80. package/.docs/models/providers/amazon-bedrock.md +4 -0
  81. package/.docs/models/providers/anthropic.md +2 -1
  82. package/.docs/models/providers/azure.md +4 -0
  83. package/.docs/models/providers/chutes.md +6 -4
  84. package/.docs/models/providers/cloudflare-ai-gateway.md +2 -0
  85. package/.docs/models/providers/cloudflare-workers-ai.md +0 -13
  86. package/.docs/models/providers/cohere.md +2 -0
  87. package/.docs/models/providers/crossmodel.md +5 -1
  88. package/.docs/models/providers/deepinfra.md +2 -1
  89. package/.docs/models/providers/edenai.md +12 -13
  90. package/.docs/models/providers/empiriolabs.md +3 -3
  91. package/.docs/models/providers/fireworks-ai.md +30 -28
  92. package/.docs/models/providers/google-vertex.md +2 -0
  93. package/.docs/models/providers/google.md +4 -3
  94. package/.docs/models/providers/hyper.md +8 -14
  95. package/.docs/models/providers/inceptron.md +2 -2
  96. package/.docs/models/providers/kilo.md +34 -33
  97. package/.docs/models/providers/llmgateway-providers.md +448 -427
  98. package/.docs/models/providers/llmgateway.md +9 -5
  99. package/.docs/models/providers/meta.md +5 -4
  100. package/.docs/models/providers/morph.md +2 -1
  101. package/.docs/models/providers/nano-gpt.md +51 -57
  102. package/.docs/models/providers/novita-ai.md +4 -2
  103. package/.docs/models/providers/ollama-cloud.md +2 -1
  104. package/.docs/models/providers/ollama.md +2 -0
  105. package/.docs/models/providers/opencode-go.md +3 -1
  106. package/.docs/models/providers/opencode.md +11 -6
  107. package/.docs/models/providers/prime.md +4 -4
  108. package/.docs/models/providers/qvac.md +2 -0
  109. package/.docs/models/providers/tencent-token-plan.md +2 -1
  110. package/.docs/models/providers/tencent-tokenhub.md +2 -1
  111. package/.docs/models/providers/tinfoil.md +2 -1
  112. package/.docs/models/providers/wandb.md +4 -4
  113. package/.docs/models/providers.md +0 -1
  114. package/.docs/reference/agent-controller/agent-controller-class.md +4 -2
  115. package/.docs/reference/agent-controller/session.md +1 -1
  116. package/.docs/reference/agents/agent.md +2 -0
  117. package/.docs/reference/agents/channels.md +117 -1
  118. package/.docs/reference/agents/durable-agent.md +42 -29
  119. package/.docs/reference/ai-sdk/chat-route.md +33 -2
  120. package/.docs/reference/auth/neon.md +24 -15
  121. package/.docs/reference/build-with-ai.md +12 -2
  122. package/.docs/reference/cli/mastra.md +10 -1
  123. package/.docs/reference/client-js/agents.md +4 -4
  124. package/.docs/reference/client-js/observability.md +36 -6
  125. package/.docs/reference/code-sdk/mount-agent-controller.md +5 -1
  126. package/.docs/reference/connect/channels.md +55 -1
  127. package/.docs/reference/connect/credential.md +2 -1
  128. package/.docs/reference/connect/providers.md +5 -3
  129. package/.docs/reference/connect/tools.md +29 -2
  130. package/.docs/reference/core/getGatewayById.md +14 -1
  131. package/.docs/reference/core/mastra-class.md +1 -1
  132. package/.docs/reference/evals/create-scorer.md +3 -1
  133. package/.docs/reference/file-based-agents/tools.md +3 -3
  134. package/.docs/reference/index.md +1 -0
  135. package/.docs/reference/memory/memory-class.md +1 -1
  136. package/.docs/reference/observability/feedback.md +43 -14
  137. package/.docs/reference/observability/tracing/advanced-queries.md +47 -58
  138. package/.docs/reference/observability/tracing/configuration.md +3 -0
  139. package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +51 -15
  140. package/.docs/reference/observability/tracing/exporters/mastra-storage-exporter.md +30 -0
  141. package/.docs/reference/observability/tracing/interfaces.md +2 -0
  142. package/.docs/reference/processors/processor-interface.md +24 -1
  143. package/.docs/reference/processors/semantic-recall-processor.md +7 -3
  144. package/.docs/reference/processors/skill-search-processor.md +3 -0
  145. package/.docs/reference/processors/skills-processor.md +84 -0
  146. package/.docs/reference/pubsub/lease-provider.md +4 -2
  147. package/.docs/reference/pubsub/redis-streams.md +3 -1
  148. package/.docs/reference/rag/graph-rag.md +2 -2
  149. package/.docs/reference/rag/rerank.md +1 -1
  150. package/.docs/reference/rag/rerankWithScorer.md +1 -1
  151. package/.docs/reference/streaming/agents/MastraModelOutput.md +13 -12
  152. package/.docs/reference/tools/mcp-client.md +26 -7
  153. package/.docs/reference/tools/mcp-server.md +6 -2
  154. package/.docs/reference/workers/overview.md +2 -2
  155. package/.docs/reference/workflows/run-methods/resume.md +1 -1
  156. package/.docs/reference/workflows/run.md +1 -1
  157. package/.docs/reference/workflows/workflow.md +1 -1
  158. package/.docs/reference/workspace/factory-sandbox.md +24 -8
  159. package/.docs/reference/workspace/platform-sandbox.md +22 -7
  160. package/.docs/reference/workspace/workspace-class.md +5 -5
  161. package/package.json +4 -5
  162. package/.docs/docs/mastra-platform/connect/channels.md +0 -165
  163. package/.docs/docs/mastra-platform/connect/overview.md +0 -102
  164. package/.docs/docs/mastra-platform/connect/providers.md +0 -66
  165. package/.docs/docs/mastra-platform/connect/tools.md +0 -151
  166. package/.docs/models/providers/requesty.md +0 -261
@@ -33,7 +33,7 @@ await mastra.observability.addFeedback({
33
33
 
34
34
  ### `addFeedback(args)`
35
35
 
36
- Adds feedback to a persisted trace or span through the observability entrypoint.
36
+ Sends feedback about a trace or span to configured exporters.
37
37
 
38
38
  ```typescript
39
39
  await mastra.observability.addFeedback?.({
@@ -56,7 +56,9 @@ await mastra.observability.addFeedback?.({
56
56
 
57
57
  **feedback** (`FeedbackInput`): Feedback payload to add.
58
58
 
59
- Without `correlationContext`, the method looks up `traceId` in configured observability storage. If the trace or requested span isn't found, Mastra logs a warning and drops the feedback event. Configure `MastraStorageExporter` when adding feedback by ID after execution, including when `MastraPlatformExporter` handles remote export.
59
+ Without `correlationContext`, each exporter handles the target trace or span at its own destination. `MastraStorageExporter` resolves it from local storage. A failed local lookup doesn't block other exporters. `MastraPlatformExporter` doesn't require local storage. Use `flush()` or `shutdown()` to drain pending deliveries.
60
+
61
+ Local lookup requires the target span's parent chain through its root so feedback inherits the correct root tags. If any ancestor remains missing after retries, the storage exporter logs a warning and skips the local write. Other exporters still receive the feedback.
60
62
 
61
63
  ### `createFeedback(args)`
62
64
 
@@ -138,7 +140,7 @@ await mastraClient.deleteFeedback({
138
140
 
139
141
  **resourceId** (`string`): Restricts the delete to records with this resource id.
140
142
 
141
- Returns `Promise<{ success: boolean }>` from `mastraClient.deleteFeedback()` and the HTTP route. The storage domain method returns `Promise<void>`. Requests with more than 1,000 ids return `400`, and a server running `@mastra/core` older than `1.66.0` returns `501`. ClickHouse vNext, PostgreSQL vNext, DuckDB, and the in-memory store implement deletion. Every other adapter, including LibSQL and MongoDB, throws `OBSERVABILITY_STORAGE_DELETE_FEEDBACK_NOT_IMPLEMENTED`.
143
+ The OSS HTTP route returns `{ success: boolean }`. `mastraClient.deleteFeedback()` returns `Promise<{ success: boolean } | { accepted: true }>` to also support Platform backends with queued batch deletion. An accepted response means cleanup is queued, and records can remain readable until cleanup runs. See [client deletion response handling](https://mastra.ai/reference/client-js/observability). The storage domain method returns `Promise<void>`. Requests with more than 1,000 ids return `400`, and a server running `@mastra/core` older than `1.66.0` returns `501`. ClickHouse vNext, PostgreSQL vNext, DuckDB, and the in-memory store implement deletion. Every other adapter, including LibSQL and MongoDB, throws `OBSERVABILITY_STORAGE_DELETE_FEEDBACK_NOT_IMPLEMENTED`.
142
144
 
143
145
  On ClickHouse, deletion uses lightweight deletes on the main feedback events table to remove rows from reads, including OLAP queries, without guaranteeing immediate physical removal, so open-source deployments must configure an [observability retention period](https://mastra.ai/reference/storage/retention) to physically purge them. Each request is marked applied once its delete succeeds; if the delete fails, the request stays unapplied, doesn't block `updateFeedbackReviewStatus()` on the still-visible feedback, and you retry by calling `deleteFeedback()` again. `updateFeedbackReviewStatus()` also retries the delete and throws a not-found error if the retry succeeds, or saves the new status and throws the delete's error if it fails again. Open-source deployments have no background reconciler. ClickHouse applies a TTL to deletion requests only when all five signals have finite retention. See [ClickHouse native TTL](https://mastra.ai/reference/storage/retention). Delete APIs leave the separate delta cursor table untouched. Its rows contain identifiers rather than feedback payloads and expire within two days.
144
146
 
@@ -413,21 +415,48 @@ Use `FeedbackFilter` in `listFeedback()` and OLAP query `filters`.
413
415
 
414
416
  **tags** (`string[]`): Filter by tags. Matching records must have all specified tags.
415
417
 
418
+ ## Replace feedback
419
+
420
+ `PUT /api/observability/feedback/:feedbackId` accepts a full `{ feedback: { ... } }` replacement. Keep the original `feedbackId`, `traceId`, and `timestamp`, and include every field you want to retain. Omitted optional fields are cleared. The URL and body IDs must match. See [the client example](https://mastra.ai/reference/client-js/observability).
421
+
422
+ OSS writes to its configured storage before returning success and notifies supporting exporters independently. `contextMode` has the same meaning as on create. In `"resolve"` mode, the local trace or span must exist. A missing feedback record is created from the full replacement. Changing an existing record's trace or timestamp returns `409`.
423
+
424
+ In-memory, PostgreSQL vNext, DuckDB, and ClickHouse vNext storage support replacement. Check `capabilities.feedbackReplacement` on the server. Unsupported versions return `501`. Sequential retries of the original HTTP create don't undo a replacement. Direct storage `createFeedback()` calls retain upsert behavior. Pass `onConflict: 'ignore'` to keep an existing record.
425
+
426
+ ClickHouse support uses the existing schema without a migration. Concurrent writes from separate processes can race, so it doesn't guarantee ordering between overlapping creates and replacements. Serialize edits to the same feedback record when using this adapter.
427
+
428
+ To send a replacement to configured exporters without depending on local storage, use the observability entrypoint:
429
+
430
+ ```typescript
431
+ await mastra.observability.replaceFeedback?.({
432
+ traceId: 'trace-123',
433
+ feedback: {
434
+ feedbackId: 'feedback-1',
435
+ timestamp: new Date('2026-11-11T12:00:00.123Z'),
436
+ feedbackType: 'thumbs',
437
+ value: -1,
438
+ },
439
+ })
440
+ ```
441
+
442
+ Each exporter handles its destination independently. `MastraStorageExporter` resolves local span context when needed, and `MastraPlatformExporter` sends a PUT to Platform. Exporters without a replacement handler skip the event. `flush()` and `shutdown()` wait for pending deliveries.
443
+
416
444
  ## HTTP routes
417
445
 
418
446
  These routes belong to a Mastra runtime and use its configured observability storage. They're separate from the [unversioned Mastra Platform Feedback API](https://mastra.ai/docs/mastra-platform/api), which doesn't provide a feedback creation route.
419
447
 
420
- | Method | Path | Purpose | Permission |
421
- | -------- | ------------------------------------------------------- | ----------------------------- | ---------------------- |
422
- | `GET` | `/api/observability/feedback` | List feedback records | `observability:read` |
423
- | `POST` | `/api/observability/feedback` | Create a feedback record | `observability:write` |
424
- | `DELETE` | `/api/observability/feedback` | Delete feedback records by id | `observability:delete` |
425
- | `DELETE` | `/api/observability/scores` | Delete score records by id | `observability:delete` |
426
- | `PATCH` | `/api/observability/feedback/:feedbackId/review-status` | Update review status | `observability:write` |
427
- | `POST` | `/api/observability/feedback/aggregate` | Return one aggregate value | `observability:read` |
428
- | `POST` | `/api/observability/feedback/breakdown` | Group feedback by dimensions | `observability:read` |
429
- | `POST` | `/api/observability/feedback/timeseries` | Bucket feedback by interval | `observability:read` |
430
- | `POST` | `/api/observability/feedback/percentiles` | Return percentile series | `observability:read` |
448
+ | Method | Path | Purpose | Permission |
449
+ | -------- | ------------------------------------------------------- | ---------------------------------- | ---------------------- |
450
+ | `GET` | `/api/observability/feedback` | List feedback records | `observability:read` |
451
+ | `POST` | `/api/observability/feedback` | Create a feedback record | `observability:write` |
452
+ | `PUT` | `/api/observability/feedback/:feedbackId` | Replace a complete feedback record | `observability:write` |
453
+ | `DELETE` | `/api/observability/feedback` | Delete feedback records by id | `observability:delete` |
454
+ | `DELETE` | `/api/observability/scores` | Delete score records by id | `observability:delete` |
455
+ | `PATCH` | `/api/observability/feedback/:feedbackId/review-status` | Update review status | `observability:write` |
456
+ | `POST` | `/api/observability/feedback/aggregate` | Return one aggregate value | `observability:read` |
457
+ | `POST` | `/api/observability/feedback/breakdown` | Group feedback by dimensions | `observability:read` |
458
+ | `POST` | `/api/observability/feedback/timeseries` | Bucket feedback by interval | `observability:read` |
459
+ | `POST` | `/api/observability/feedback/percentiles` | Return percentile series | `observability:read` |
431
460
 
432
461
  ### List query parameters
433
462
 
@@ -128,39 +128,9 @@ This top-level predicate doesn't inspect child spans. In contrast, `spans.some`
128
128
 
129
129
  Trace queries exclude incomplete roots before evaluating predicates. As a result, `{ op: 'notExists', path: 'durationMs' }` doesn't find running traces or malformed roots without a usable `endedAt`.
130
130
 
131
- #### Filter by time to first chunk
131
+ #### Filter and sort by time to first chunk or token
132
132
 
133
- `timeToFirstChunkMs` is the time in milliseconds from a span's start to the first chunk of its model response. Agent run and model spans record it when the model streams a response. At trace scope, the field reads the current root span's value. Inside `spans.some` or `spans.none`, it reads each related span.
134
-
135
- This predicate finds traces with a model call that took more than 2 seconds to stream its first chunk:
136
-
137
- ```typescript
138
- const slowFirstChunk = {
139
- spans: {
140
- some: {
141
- op: 'and',
142
- args: [
143
- { op: 'eq', left: { path: 'spanType' }, right: { literal: 'model_generation' } },
144
- { op: 'gt', left: { path: 'timeToFirstChunkMs' }, right: { literal: 2000 } },
145
- ],
146
- },
147
- },
148
- }
149
- ```
150
-
151
- The value is `null` when the span didn't stream a chunk, for example a tool call or a workflow run. A `null` value counts as missing, so it matches `notExists` and never matches ordered predicates. A value of `0` isn't missing. It means the first chunk arrived in the same millisecond the span started.
152
-
153
- Trace query results include the root span's `timeToFirstChunkMs`, and `querySpans()` results include each span's value. Stores advertise support through the `trace-query-time-to-first-chunk` feature, and the server reports it as the `traceQueryTimeToFirstChunk` capability. Against an older store, results omit the field, a predicate on it returns `501` before storage runs, and field discovery omits it.
154
-
155
- #### Sort by time to first chunk
156
-
157
- Pass `orderBy: [{ field: 'timeToFirstChunkMs', direction: 'desc' }]` to list the slowest first chunks first. Traces sort by the root span's value. Missing values sort last in both directions, and `0` sorts as a value. Ties break by `traceId` for traces and by span identity for `querySpans()`.
158
-
159
- Stores advertise the sort through the `trace-query-time-to-first-chunk-sort` feature, and the server reports it as the `traceQueryTimeToFirstChunkSort` capability. Against an older store, the sort returns `501` before storage runs.
160
-
161
- #### Filter and sort by time to first token
162
-
163
- `timeToFirstTokenMs` is the time in milliseconds from the start of a model call, the provider request itself, to the first chunk that call streams. It leaves out the work Mastra does before calling the model, such as input processors. The value is measured once, on the model inference span that streamed the chunk. Model step, model generation, and agent run spans carry the value of the nearest such inference below them: each step takes its own, and the generation and agent run take the first step's. A step can run more than one inference, for example a fallback model or a retry that opens a new inference span. The value then comes from the first inference that streamed a chunk. A fallback attempt that failed ends its inference span with its error. That span has a value only if it streamed a chunk first. Mastra storage keeps the value in its own column and leaves it out of the stored `attributes`. Read it from the span's `timeToFirstTokenMs` field. When an in-process agent retries a failed model call, the AI SDK retries inside a single inference span. The value then includes the failed attempt and the retry wait. Durable agents open one inference span per attempt and don't. At trace scope, the field reads the current root span's value. Inside `spans.some` or `spans.none`, it reads each related span.
133
+ `timeToFirstChunkMs` holds a span's [time to first chunk (TTFC)](#time-to-first-chunk-ttfc), and `timeToFirstTokenMs` holds its [time to first token (TTFT)](#time-to-first-token-ttft). At trace scope, the fields read the root span's value. Inside `spans.some` or `spans.none`, they read each related span. Both fields also work in `orderBy`.
164
134
 
165
135
  This predicate finds traces whose root agent waited more than 2 seconds for the model's first token:
166
136
 
@@ -168,9 +138,7 @@ This predicate finds traces whose root agent waited more than 2 seconds for the
168
138
  const slowFirstToken = { op: 'gt', left: { path: 'timeToFirstTokenMs' }, right: { literal: 2000 } }
169
139
  ```
170
140
 
171
- `null`, `0`, and missing values follow the same rules as `timeToFirstChunkMs`. Pass `orderBy: [{ field: 'timeToFirstTokenMs', direction: 'desc' }]` to list the slowest first tokens first, with the same ordering and tie-breaks.
172
-
173
- Stores advertise support through the `trace-query-time-to-first-token` feature and the sort through the `trace-query-time-to-first-token-sort` feature. The server reports them as the `traceQueryTimeToFirstToken` and `traceQueryTimeToFirstTokenSort` capabilities. Against an older store, results omit the field, and a predicate or sort on it returns `501` before storage runs.
141
+ See [Missing first chunk and token values](#missing-first-chunk-and-token-values) for `null`, `0`, and the capabilities each use needs.
174
142
 
175
143
  #### Filter by outcome
176
144
 
@@ -570,7 +538,7 @@ A query using keyset pagination returns lightweight completed traces and a curso
570
538
 
571
539
  The response includes `name`, `createdAt`, identity fields, `metadata`, and input/output/error previews. Supported nullable fields remain present with `null` when no value was recorded. Fields that require an optional store feature are omitted when the store lacks that feature. Previews summarize payloads; retrieve the full trace for complete input, output, and error details.
572
540
 
573
- `timeToFirstChunkMs` and `timeToFirstTokenMs` are present only when the configured store supports them. See [Filter by time to first chunk](#filter-by-time-to-first-chunk) and [Filter and sort by time to first token](#filter-and-sort-by-time-to-first-token). `outcome`, `stopReason`, and `stopReasonContext` read the root span and are present only when the store supports the `traceQueryOutcomeFields` capability. They're `null` when the root span didn't record them. See [Filter by outcome](#filter-by-outcome).
541
+ `timeToFirstChunkMs` and `timeToFirstTokenMs` are present only when the configured store supports them. See [Filter and sort by time to first chunk or token](#filter-and-sort-by-time-to-first-chunk-or-token). `outcome`, `stopReason`, and `stopReasonContext` read the root span and are present only when the store supports the `traceQueryOutcomeFields` capability. They're `null` when the root span didn't record them. See [Filter by outcome](#filter-by-outcome).
574
542
 
575
543
  The response doesn't include the related spans that matched the predicate. Use [`getTrace()`](https://mastra.ai/reference/client-js/observability) to load the full trace after selecting a result.
576
544
 
@@ -838,6 +806,12 @@ Every dimension except `executionSource` is also a trace-scope `where` field, so
838
806
  | `countDistinct.<field>` | Number of distinct non-null values of a dimension or `traceId`, such as `countDistinct.userId`. |
839
807
  | `duration.avg`, `duration.min`, `duration.max` | Root span duration in milliseconds. |
840
808
  | `duration.p50`, `duration.p90`, `duration.p95`, `duration.p99` | Root span duration percentile in milliseconds. Percentiles can be approximate, depending on the store. |
809
+ | `timeToFirstChunk.avg`, `timeToFirstChunk.min`, `timeToFirstChunk.max` | Root span time to first chunk in milliseconds. Requires the `aggregateTimeToFirstMeasures` capability. |
810
+ | `timeToFirstChunk.p50`, `timeToFirstChunk.p90`, `timeToFirstChunk.p95`, `timeToFirstChunk.p99` | Root span time to first chunk percentile in milliseconds. Requires the `aggregateTimeToFirstMeasures` capability. |
811
+ | `timeToFirstChunk.count` | Number of traces whose root span recorded a time to first chunk. Requires the `aggregateTimeToFirstMeasures` capability. |
812
+ | `timeToFirstToken.avg`, `timeToFirstToken.min`, `timeToFirstToken.max` | Root span time to first token in milliseconds. Requires the `aggregateTimeToFirstMeasures` capability. |
813
+ | `timeToFirstToken.p50`, `timeToFirstToken.p90`, `timeToFirstToken.p95`, `timeToFirstToken.p99` | Root span time to first token percentile in milliseconds. Requires the `aggregateTimeToFirstMeasures` capability. |
814
+ | `timeToFirstToken.count` | Number of traces whose root span recorded a time to first token. Requires the `aggregateTimeToFirstMeasures` capability. |
841
815
  | `errorCount` | Number of traces whose root span recorded an error. |
842
816
  | `errorRate` | `errorCount` divided by `count`, from 0 to 1. |
843
817
  | `tokens.input.sum`, `tokens.input.avg` | Input tokens. |
@@ -846,12 +820,6 @@ Every dimension except `executionSource` is also a trace-scope `where` field, so
846
820
  | `tokens.reasoning.sum`, `tokens.reasoning.avg` | Reasoning output tokens. |
847
821
  | `tokens.cached.sum`, `tokens.cached.avg` | Input tokens read from the provider's cache. |
848
822
  | `cost.sum`, `cost.avg` | Estimated model cost. |
849
- | `timeToFirstToken.avg`, `timeToFirstToken.min`, `timeToFirstToken.max` | Root span time to first token in milliseconds. Requires the `aggregateTimeToFirstMeasures` capability. |
850
- | `timeToFirstToken.p50`, `timeToFirstToken.p90`, `timeToFirstToken.p95`, `timeToFirstToken.p99` | Root span time to first token percentile in milliseconds. Requires the `aggregateTimeToFirstMeasures` capability. |
851
- | `timeToFirstToken.count` | Number of traces whose root span recorded a time to first token. Requires the `aggregateTimeToFirstMeasures` capability. |
852
- | `timeToFirstChunk.avg`, `timeToFirstChunk.min`, `timeToFirstChunk.max` | Root span time to first chunk in milliseconds. Requires the `aggregateTimeToFirstMeasures` capability. |
853
- | `timeToFirstChunk.p50`, `timeToFirstChunk.p90`, `timeToFirstChunk.p95`, `timeToFirstChunk.p99` | Root span time to first chunk percentile in milliseconds. Requires the `aggregateTimeToFirstMeasures` capability. |
854
- | `timeToFirstChunk.count` | Number of traces whose root span recorded a time to first chunk. Requires the `aggregateTimeToFirstMeasures` capability. |
855
823
 
856
824
  Numeric measures over metadata aren't supported.
857
825
 
@@ -872,16 +840,11 @@ When you request any `cost.*` measure, every row also includes a `cost` object:
872
840
 
873
841
  `cost.sum` and `cost.avg` are `null` when the group has no priced traces or `unit` is `'mixed'`. A coverage below 1 means the cost understates the group's spend. The `cost` object isn't a measure, so `having` and `orderBy` can't reference it.
874
842
 
875
- #### Time to first token and chunk measures
876
-
877
- `timeToFirstToken.*` and `timeToFirstChunk.*` read the root span's `timeToFirstTokenMs` and `timeToFirstChunkMs`, the same values [`queryTraces()`](#query-traces) returns. An agent run copies them from the first model generation of its own loop:
878
-
879
- - `timeToFirstChunk.*` is measured from the agent run's start, so it includes work done before the first model call, such as input processors and memory recall.
880
- - `timeToFirstToken.*` is the time to first token of the model call that streamed that first chunk.
843
+ ### Time to first chunk (TTFC)
881
844
 
882
- Traces without a value are skipped, never counted as 0. This includes traces whose agent run didn't stream, and traces rooted in a workflow, since a workflow run records neither value. `avg`, `min`, `max`, and the percentiles are `null` for a group where no trace has a value, and `.count` is the number of traces that do have one. Percentiles can be approximate, depending on the store.
845
+ Time to first chunk (TTFC) is how long a caller waits for the first streamed chunk. `timeToFirstChunkMs` is the time from a span's start to the first chunk of its model response. Agent run and model spans record it when the model streams a response. On an agent run, it's measured from the run's start and includes work done before the first model call, such as input processors and memory recall.
883
846
 
884
- Stores advertise support through the `aggregate-time-to-first-measures` feature, and the server reports it as the `aggregateTimeToFirstMeasures` capability. Against an older store, a request for any of these measures returns `501` before storage runs, and [field discovery](#discover-fields-and-values) omits them.
847
+ The `timeToFirstChunk.*` measures aggregate the root span's `timeToFirstChunkMs`, the same value [`queryTraces()`](#query-traces) returns. To filter or sort by it, see [Filter and sort by time to first chunk or token](#filter-and-sort-by-time-to-first-chunk-or-token).
885
848
 
886
849
  ```typescript
887
850
  const { capabilities } = await mastraClient.getObservabilityCapabilities()
@@ -900,6 +863,39 @@ if (capabilities.traceAggregate && capabilities.aggregateTimeToFirstMeasures) {
900
863
  }
901
864
  ```
902
865
 
866
+ ### Time to first token (TTFT)
867
+
868
+ Time to first token (TTFT) is the time in milliseconds from the start of a model call, the provider request itself, to the first chunk that call streams. Unlike TTFC, it leaves out the work Mastra does before calling the model, such as input processors.
869
+
870
+ The `timeToFirstToken.*` measures aggregate the root span's `timeToFirstTokenMs`. To filter or sort by it, see [Filter and sort by time to first chunk or token](#filter-and-sort-by-time-to-first-chunk-or-token). Compare TTFC with TTFT to see how much of an agent's wait comes from work before the model call.
871
+
872
+ ### First chunk and token span types
873
+
874
+ These span types record TTFC and TTFT:
875
+
876
+ - `model_inference`: each provider call.
877
+ - `model_step`: each step of a generation, with the values of the inference that streamed the step's first chunk.
878
+ - `model_generation`: the whole generation, with the values of its first streamed inference only. A multi-step generation, such as a tool loop, reports only its first call.
879
+ - `agent_run`: the agent run, with the values of the first model generation of its own loop. Its TTFC is measured from the run's start.
880
+
881
+ Other spans, such as tool calls and workflow runs, record neither value. A trace rooted in a workflow has no TTFC or TTFT at trace scope.
882
+
883
+ TTFT is measured once, on the `model_inference` span that streamed the chunk. A step with a fallback model or a retry takes the value of its first inference that streamed a chunk. A failed fallback attempt has a value only if it streamed a chunk before failing. An in-process agent retries a failed model call inside a single inference span. Its TTFT then includes the failed attempt and the retry wait. Durable agents open one inference span per attempt.
884
+
885
+ Mastra storage keeps TTFT in its own column, not in the stored `attributes`. Read it from the span's `timeToFirstTokenMs` field.
886
+
887
+ ### Missing first chunk and token values
888
+
889
+ The value is `null` when the span didn't stream a chunk. A value of `0` isn't missing. It means the first chunk arrived in the same millisecond the span started.
890
+
891
+ - In predicates, `null` counts as missing. It matches `notExists` and never matches ordered predicates.
892
+ - In `orderBy`, missing values sort last in both directions, and `0` sorts as a value.
893
+ - In aggregates, spans and traces without a value are skipped, never counted as 0.
894
+
895
+ Filtering, sorting, and aggregating each require a store feature. See [Check capabilities](#check-capabilities) for the `traceQueryTimeToFirstChunk`, `traceQueryTimeToFirstChunkSort`, `traceQueryTimeToFirstToken`, `traceQueryTimeToFirstTokenSort`, and `aggregateTimeToFirstMeasures` flags. Against an older store, results omit the unsupported fields, a request that uses them returns `501` before storage runs, and [field discovery](#discover-fields-and-values) omits them.
896
+
897
+ For `timeToFirstChunk.*` and `timeToFirstToken.*`, `avg`, `min`, `max`, and the percentiles are `null` for a group where no trace has a value, and `.count` is the number of traces that do have one. Percentiles can be approximate, depending on the store. The measures require the `aggregateTimeToFirstMeasures` capability.
898
+
903
899
  ### Filter and order groups
904
900
 
905
901
  A group is one distinct combination of `groupBy` values. `having`, `orderBy`, and `limit` operate on groups and use each group's measures over the whole time range, even when `interval` is set. The server applies `having` first, then orders the remaining groups and keeps the first `limit`. `truncated` is `true` when more groups remained than `limit`.
@@ -1031,14 +1027,7 @@ Aggregation uses the same span predicates as [`querySpans()`](#query-spans), wit
1031
1027
 
1032
1028
  `count` counts selected spans in each group or time bucket. Buckets use each span's `startedAt`. `duration.*` measures read the span's own duration, and `errorCount` and `errorRate` read whether the span itself recorded an error.
1033
1029
 
1034
- `timeToFirstToken.*` and `timeToFirstChunk.*` read the span's own `timeToFirstTokenMs` and `timeToFirstChunkMs`, and skip spans without a value. Several span types record them:
1035
-
1036
- - `model_inference`: each provider call. Filter to this type for per-call time to first token.
1037
- - `model_step`: each step of a generation, with the values of the inference that streamed the step's first chunk.
1038
- - `model_generation`: the whole generation, with the values of its first streamed inference only. A multi-step generation, such as a tool loop, reports only its first call.
1039
- - `agent_run`: the agent run, with time to first chunk measured from the run's start. Filter to this type for latency as the caller of each agent sees it.
1040
-
1041
- Without a `spanType` filter, one agent call contributes its agent run, its model generation, and every model step and model inference.
1030
+ `timeToFirstToken.*` and `timeToFirstChunk.*` read the span's own `timeToFirstTokenMs` and `timeToFirstChunkMs`. See [First chunk and token span types](#first-chunk-and-token-span-types) for which spans record them. Filter to `model_inference` for per-call TTFT, or to `agent_run` for latency as the caller of each agent sees it. Without a `spanType` filter, one agent call contributes its agent run, its model generation, and every model step and model inference.
1042
1031
 
1043
1032
  On ClickHouse, a direct `spanType` `eq` or `in` predicate, or one immediately inside an `and`, can select the smaller branch table. All selected types must be branch types: `agent_run`, `workflow_run`, `processor_run`, `scorer_run`, `rag_ingestion`, `tool_call`, or `mcp_tool_call`. Every requested field must be available in that table. An equivalent `or` predicate doesn't select this optimization. The branch path can differ from `querySpans()`:
1044
1033
 
@@ -31,6 +31,7 @@ interface ObservabilityInstanceConfig {
31
31
  serviceName: string
32
32
  sampling?: SamplingStrategy
33
33
  exporters?: ObservabilityExporter[]
34
+ retainStorageExporterOnPlatform?: boolean
34
35
  spanOutputProcessors?: SpanOutputProcessor[]
35
36
  includeInternalSpans?: boolean
36
37
  excludeSpanTypes?: SpanType[]
@@ -49,6 +50,8 @@ interface ObservabilityInstanceConfig {
49
50
 
50
51
  **exporters** (`ObservabilityExporter[]`): Trace data exporters
51
52
 
53
+ **retainStorageExporterOnPlatform** (`boolean`): Defaults to false. Retains configured MastraStorageExporter instances on Platform, including later registration. Known local storage remains blocked, and deprecated DefaultExporter remains disabled. See storage export on Platform for configuration, adapter requirements, and restrictions.
54
+
52
55
  **spanOutputProcessors** (`SpanOutputProcessor[]`): Span output processors
53
56
 
54
57
  **includeInternalSpans** (`boolean`): Include spans internal to Mastra operations
@@ -30,7 +30,14 @@ interface MastraPlatformExporterConfig extends BaseExporterConfig {
30
30
  /** Maximum wait time before flushing in milliseconds. Default: 5000 */
31
31
  maxBatchWaitMs?: number
32
32
 
33
- /** Maximum retry attempts. Default: 3 */
33
+ /** Opt into byte-triggered batches and upload concurrency control */
34
+ byteBatching?: {
35
+ maxBatchBytes?: number // Default: 8 MiB
36
+ maxConcurrentUploads?: number // Default: 2
37
+ uploadTimeoutMs?: number // Default: 30000
38
+ }
39
+
40
+ /** Maximum retry attempts for collector batches. Default: 3 */
34
41
  maxRetries?: number
35
42
 
36
43
  /** Mastra Observability access token (from env or config) */
@@ -135,11 +142,9 @@ Every `MetricEvent` passed to this handler is buffered and exported to the metri
135
142
  async onScoreEvent(event: ScoreEvent): Promise<void>
136
143
  ```
137
144
 
138
- Processes score signals for export.
145
+ Schedules a score for export using the [feedback and score delivery](#feedback-and-score-delivery) behavior. Events are ignored when the exporter is disabled or shutdown has started. If Platform needs to look up the trace, a missing trace ID causes the record to be dropped.
139
146
 
140
- Every `ScoreEvent` passed to this handler is buffered and exported to the scores endpoint derived from the configured base endpoint. No extra filtering at the exporter layer beyond the disabled-exporter check is performed, so all score events received by this method are forwarded.
141
-
142
- **Returns:** `Promise<void>` after the score event has been accepted for buffering.
147
+ **Returns:** `Promise<void>` when the event has been scheduled or ignored. Call `flush()` to wait for pending deliveries, because this return value doesn't confirm delivery.
143
148
 
144
149
  ### `onFeedbackEvent`
145
150
 
@@ -147,11 +152,9 @@ Every `ScoreEvent` passed to this handler is buffered and exported to the scores
147
152
  async onFeedbackEvent(event: FeedbackEvent): Promise<void>
148
153
  ```
149
154
 
150
- Processes feedback signals for export.
151
-
152
- Every `FeedbackEvent` passed to this handler is buffered and exported to the feedback endpoint derived from the configured base endpoint. No feedback-type filtering inside `MastraPlatformExporter` is performed. All feedback events received here are forwarded unless the exporter is disabled.
155
+ Schedules feedback for export using the [feedback and score delivery](#feedback-and-score-delivery) behavior. Events are ignored when the exporter is disabled or shutdown has started. If Platform needs to look up the trace, a missing trace ID causes the record to be dropped.
153
156
 
154
- **Returns:** `Promise<void>` after the feedback event has been accepted for buffering.
157
+ **Returns:** `Promise<void>` when the event has been scheduled or ignored. Call `flush()` to wait for pending deliveries, because this return value doesn't confirm delivery.
155
158
 
156
159
  ### flush
157
160
 
@@ -180,15 +183,47 @@ If no access token is provided via config or environment variable, the exporter:
180
183
 
181
184
  ### Batching
182
185
 
183
- The exporter batches tracing spans, logs, metrics, scores, and feedback for efficient network usage:
186
+ The exporter batches traces, logs, and metrics, along with feedback and scores that already include their trace details:
184
187
 
185
188
  - Flushes when total buffered event count reaches `maxBatchSize`
186
189
  - Flushes when `maxBatchWaitMs` elapsed since the first buffered signal in the batch
187
190
  - Flushes on `shutdown()`
188
191
 
192
+ ### Feedback and score delivery
193
+
194
+ Feedback and scores received by the exporter can reference a trace stored in Platform using its trace ID and an optional span ID. If the record needs details from that trace, the exporter sends it immediately instead of waiting for a batch.
195
+
196
+ Call `flush()` before ending a short-lived process, or `shutdown()` when stopping the exporter, to wait for pending deliveries and retries. These methods finish when records have been accepted or dropped after a failure. Accepted feedback and scores may take time to appear in Platform.
197
+
198
+ ### Byte batching
199
+
200
+ Set `byteBatching` to flush by serialized byte size and control concurrent uploads:
201
+
202
+ ```typescript
203
+ import { MastraPlatformExporter } from '@mastra/observability'
204
+
205
+ const exporter = new MastraPlatformExporter({
206
+ byteBatching: {
207
+ maxBatchBytes: 8 * 1024 * 1024,
208
+ maxConcurrentUploads: 2,
209
+ uploadTimeoutMs: 30_000,
210
+ },
211
+ })
212
+ ```
213
+
214
+ Without `byteBatching`, the exporter keeps its existing count-based batching behavior.
215
+
216
+ - `maxBatchBytes` triggers an upload when a batch reaches 8 MiB by default. Larger records are sent intact, without truncation or size-based drops.
217
+ - `maxConcurrentUploads` controls concurrent collector batch uploads. The default is two.
218
+ - `uploadTimeoutMs` sets the upload deadline, including retries. The default is 30 seconds.
219
+
220
+ Record-count and timer-based flush triggers still apply. Queued records are retained when uploads fall behind, so queue memory can grow.
221
+
222
+ Inspect the current queue with `exporter.getByteBatchingStats()`.
223
+
189
224
  ### Error handling
190
225
 
191
- - Uses exponential backoff retry with `maxRetries` attempts
226
+ - Uses exponential backoff retry for collector batches with `maxRetries` attempts
192
227
  - Drops batches after all retries fail
193
228
  - Logs errors but continues processing new events
194
229
 
@@ -199,14 +234,14 @@ Errors raised by `MastraPlatformExporter` use the `MASTRA_PLATFORM_EXPORTER_*` `
199
234
  When an organization has exhausted its observability quota, the Mastra platform rejects publish requests with `402 Payment Required` plus the `x-mastra-observability: disabled` header. When the exporter sees a `402` (or the header) on any publish route, it:
200
235
 
201
236
  - Drops the rejected batch without retrying it
202
- - Pauses all five signal types (traces, logs, metrics, scores, feedback) and drops buffered and new events instead of sending them
237
+ - Pauses collector batches for traces, logs, metrics, scores, and feedback, dropping buffered and incoming batch records
203
238
  - Logs a warning that telemetry is paused
204
239
  - Probes the platform periodically with an empty batch, using the interval from the `x-mastra-observability-retry-after` header (seconds), or every 5 minutes if the header is absent
205
240
  - Resumes exporting automatically and logs a warning once the platform stops rejecting with `402`
206
241
 
207
242
  The probe timer doesn't keep the Node.js process alive, so short-lived and serverless processes exit normally while paused.
208
243
 
209
- Every request the exporter sends (batch uploads for all five signal types, plus the traces recovery probe) includes the `x-mastra-observability-capabilities: quota-pause-v1` header. This tells the platform that the client understands the quota-pause contract, so it can safely respond with `402` instead of silently dropping telemetry for older clients that would retry it.
244
+ Every collector request (batch uploads and the traces recovery probe) includes the `x-mastra-observability-capabilities: quota-pause-v1` header. This tells the platform that the client understands the quota-pause contract, so it can safely respond with `402` instead of silently dropping telemetry for older clients that would retry it.
210
245
 
211
246
  ### Endpoint routing
212
247
 
@@ -215,10 +250,11 @@ Every request the exporter sends (batch uploads for all five signal types, plus
215
250
  - With `projectId` or `MASTRA_PROJECT_ID`, derived routes use `/projects/:projectId/ai/{signal}/publish`
216
251
  - Explicit full publish URLs are used as-is, even when `projectId` is configured
217
252
 
218
- ### Signal Processing
253
+ ### Event processing
219
254
 
220
255
  - `exportTracingEvent()` only exports `SPAN_ENDED` tracing events
221
- - `onLogEvent()`, `onMetricEvent()`, `onScoreEvent()`, and `onFeedbackEvent()` buffer every event they receive for that signal type
256
+ - `onLogEvent()` and `onMetricEvent()` buffer events
257
+ - `onScoreEvent()` and `onFeedbackEvent()` deliver records as described in [Feedback and score delivery](#feedback-and-score-delivery)
222
258
  - All supported signal batches are uploaded to their matching publish endpoints during `flush()` and `shutdown()`
223
259
 
224
260
  ## Span wire format
@@ -8,6 +8,10 @@ Persists traces to Mastra's configured storage with automatic batching and retry
8
8
 
9
9
  > **Note:** `MastraStorageExporter` was previously called `DefaultExporter`. The original `DefaultExporter` class is still exported from `@mastra/observability` so existing imports keep working, but it's deprecated and will be removed in a future major version. New code should use `MastraStorageExporter`.
10
10
 
11
+ > **Platform storage restrictions:** When `MASTRA_DEPLOYMENT_ID` is set, this exporter is disabled by default. Set `retainStorageExporterOnPlatform: true` on the **observability config**, not the exporter constructor, to allow remote storage export. `InMemoryStore` (including the fallback when no storage is configured), local libSQL, embedded replicas, and DuckDB remain blocked when the adapter reports local persistence, even with the opt-in. No observability events are written to that local database, even if the initialization warning is hidden by your logging setup.
12
+ >
13
+ > See [storage export on Platform](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage) for the supported-provider table, adapter upgrade requirements, and a configuration example.
14
+
11
15
  ## Span previews
12
16
 
13
17
  `MastraStorageExporter` automatically generates short, readable `inputPreview`, `outputPreview`, and `errorPreview` summaries based on the span type. Each preview contains up to 100 characters plus an ellipsis when truncated. Full payloads remain available separately.
@@ -22,6 +26,12 @@ new MastraStorageExporter(config?: MastraStorageExporterConfig)
22
26
 
23
27
  ```typescript
24
28
  interface MastraStorageExporterConfig extends BaseExporterConfig {
29
+ /** Opt-in byte flush thresholds. Omit to keep count-based batching. */
30
+ byteBatching?: {
31
+ maxBatchBytes?: number // Default: 8 MiB
32
+ maxConcurrentWrites?: number // Default: 1
33
+ }
34
+
25
35
  /** Maximum number of spans per batch. Default: 1000 */
26
36
  maxBatchSize?: number
27
37
 
@@ -47,6 +57,26 @@ Extends `BaseExporterConfig`, which includes:
47
57
  - `logger?: IMastraLogger` - Logger instance
48
58
  - `logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error'` - Log level (default: INFO)
49
59
 
60
+ ## Byte batching
61
+
62
+ Enable byte batching with `byteBatching: {}` or supply custom thresholds. The exporter ignores byte batching when the resolved strategy is `realtime`, which keeps its immediate, awaited writes:
63
+
64
+ ```typescript
65
+ new MastraStorageExporter({
66
+ byteBatching: {
67
+ maxBatchBytes: 8 * 1024 * 1024,
68
+ maxConcurrentWrites: 1,
69
+ },
70
+ })
71
+ ```
72
+
73
+ - `maxBatchBytes` triggers a write when buffered events reach 8 MiB by default. Larger records are sent intact, without truncation or size-based drops.
74
+ - `maxConcurrentWrites` controls concurrent storage writes. The default is one. Update-based tracing strategies always use one write at a time to preserve span ordering.
75
+
76
+ Record-count and timer-based flush triggers still apply. Queued records are retained when storage falls behind, so queue memory can grow. Without `byteBatching`, the exporter keeps its existing count-based batching behavior.
77
+
78
+ Inspect the current queue with `exporter.getByteBatchingStats()`.
79
+
50
80
  ## `TracingStorageStrategy`
51
81
 
52
82
  ```typescript
@@ -1261,6 +1261,8 @@ interface ObservabilityInstanceConfig {
1261
1261
  }
1262
1262
  ```
1263
1263
 
1264
+ The `@mastra/observability` implementation also supports `retainStorageExporterOnPlatform`. See the [configuration reference](https://mastra.ai/reference/observability/tracing/configuration) for this implementation-specific option.
1265
+
1264
1266
  ### `ObservabilityRegistryConfig`
1265
1267
 
1266
1268
  Complete observability registry configuration.
@@ -652,6 +652,29 @@ processOutputStream?(args: ProcessOutputStreamArgs): Promise<ChunkType | null |
652
652
 
653
653
  Dropping a chunk only affects that single chunk. The stream continues and the next chunk is still processed. To stop the stream entirely, call `abort()`.
654
654
 
655
+ #### Emitting a second chunk
656
+
657
+ `processOutputStream` returns one chunk, but a processor sometimes needs to emit two for one input, such as text it held back followed by the chunk that released it. Return the first chunk and set the second on `state` under `REPROCESS_PART_KEY`. Mastra emits the stashed chunk right after the returned one.
658
+
659
+ The stashed chunk goes through the output processors again, including the one that stashed it, so that processor must pass it through unchanged on the second pass:
660
+
661
+ ```typescript
662
+ import { REPROCESS_PART_KEY } from '@mastra/core/processors'
663
+ import type { ChunkType } from '@mastra/core/stream'
664
+ import type { ProcessOutputStreamArgs, Processor } from '@mastra/core/processors'
665
+
666
+ export class SignOff implements Processor<'sign-off'> {
667
+ readonly id = 'sign-off'
668
+
669
+ async processOutputStream({ part, state }: ProcessOutputStreamArgs): Promise<ChunkType> {
670
+ if (part.type !== 'text-end' || state.signed) return part
671
+ state.signed = true
672
+ state[REPROCESS_PART_KEY] = part
673
+ return { ...part, type: 'text-delta', payload: { id: part.payload.id, text: '\n\nCheers!' } }
674
+ }
675
+ }
676
+ ```
677
+
655
678
  ***
656
679
 
657
680
  ### `processOutputResult`
@@ -670,7 +693,7 @@ processOutputResult?(args: ProcessOutputResultArgs): ProcessorMessageResult;
670
693
 
671
694
  **state** (`Record<string, unknown>`): Per-processor state that persists across all method calls within this request. Shared with processOutputStream and other methods.
672
695
 
673
- **result** (`OutputResult`): Resolved generation result containing text (accumulated text), usage (token usage with inputTokens, outputTokens, totalTokens), finishReason (why generation ended), steps (all LLM step results, each with toolCalls, toolResults, reasoning, sources, files, etc.), and an optional inputAccepted. inputAccepted is set only when finishReason is 'error', and is true when the run accepted the turn's input before it failed. A history processor can use it to keep the input of a failed turn that produced no output.
696
+ **result** (`OutputResult`): Resolved generation result containing text (accumulated text), usage (token usage with inputTokens, outputTokens, totalTokens), finishReason (why generation ended), steps (all LLM step results, each with toolCalls, toolResults, reasoning, sources, files, etc.). inputAccepted is deprecated and no longer set; check finishReason === 'error' to detect failed runs.
674
697
 
675
698
  **abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing. Throws a TripWire error that stops execution and emits a tripwire chunk.
676
699
 
@@ -40,10 +40,14 @@ const processor = new SemanticRecall({
40
40
 
41
41
  **options.threshold** (`number`): Minimum similarity score threshold (0-1). Messages below this threshold are filtered out
42
42
 
43
+ **options.filter** (`VectorFilter`): Metadata filter for the vector query, combined with the scope filter using $and. Messages are stored with their thread's metadata, so the filter can match thread metadata. For example, { projectId: { $eq: 'project-a' } }
44
+
43
45
  **options.indexName** (`string`): Index name for the vector store. If not provided, auto-generated based on embedder model
44
46
 
45
47
  **options.logger** (`IMastraLogger`): Optional logger instance for structured logging
46
48
 
49
+ **options.maxChunkChars** (`number`): Largest number of characters of message text sent to the embedder in one input. Longer messages are split into chunks, each stored as its own vector row. When unset, the limit comes from the embedder's maxInputTokens if it declares one (FastEmbed models do), otherwise 16,384 characters (about 4,096 English tokens).
50
+
47
51
  ## Returns
48
52
 
49
53
  **id** (`string`): Processor identifier set to 'semantic-recall'
@@ -105,9 +109,9 @@ export const agent = new Agent({
105
109
 
106
110
  ### Output processing
107
111
 
108
- 1. Extracts text content from new user and assistant messages
109
- 2. Generates embeddings for each message
110
- 3. Stores embeddings in the vector store with metadata (message ID, thread ID, resource ID, role, content, timestamp)
112
+ 1. Extracts text content from new user and assistant messages, skipping messages already embedded earlier in the same run
113
+ 2. Splits long messages into chunks of at most `maxChunkChars` characters and generates an embedding for each chunk
114
+ 3. Stores one vector row per chunk with metadata (thread metadata, message ID, thread ID, resource ID, role, content, timestamp). Row IDs are derived from the message ID (the first chunk uses a UUID message ID as is), so saving the same message again replaces its rows instead of adding new ones
111
115
  4. Uses LRU caching for embeddings to avoid redundant API calls
112
116
 
113
117
  ### Cross-thread recall
@@ -6,6 +6,8 @@
6
6
 
7
7
  The `SkillSearchProcessor` is an **input processor** that enables on-demand skill discovery and loading. Instead of injecting all skill metadata into the system prompt upfront (like `SkillsProcessor`), it gives the agent two meta-tools (`search_skills` and `load_skill`) that let it find and load skills on demand. This reduces context token usage when workspaces have many skills.
8
8
 
9
+ To hide the skills list but keep the standard `skill`, `skill_read`, and `skill_search` tools, use `SkillsProcessor` with `injectCatalog: false` instead. See [Turn off the skills list](https://mastra.ai/docs/sandbox/skills).
10
+
9
11
  By default, when you attach only `SkillSearchProcessor` to an agent with a skill-enabled `Workspace`, the agent treats skills as on-demand:
10
12
 
11
13
  - The default eager `SkillsProcessor` isn't auto-added.
@@ -114,6 +116,7 @@ Reserve workspace file tools such as `mastra_workspace_read_file` for explicit f
114
116
 
115
117
  ## Related
116
118
 
119
+ - [SkillsProcessor](https://mastra.ai/reference/processors/skills-processor)
117
120
  - [ToolSearchProcessor](https://mastra.ai/reference/processors/tool-search-processor)
118
121
  - [Processors](https://mastra.ai/docs/agents/processors)
119
122
  - [Workspace Skills](https://mastra.ai/docs/sandbox/skills)