@mastra/mcp-docs-server 0.0.0-studio-deploy-20260404182525 → 0.0.0-studio-cli-20260504022012

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 (285) hide show
  1. package/.docs/docs/agents/adding-voice.md +18 -17
  2. package/.docs/docs/agents/background-tasks.md +242 -0
  3. package/.docs/docs/agents/channels.md +2 -1
  4. package/.docs/docs/agents/overview.md +4 -0
  5. package/.docs/docs/agents/processors.md +177 -5
  6. package/.docs/docs/agents/structured-output.md +66 -1
  7. package/.docs/docs/agents/supervisor-agents.md +65 -0
  8. package/.docs/docs/agents/using-tools.md +73 -0
  9. package/.docs/docs/browser/agent-browser.md +78 -0
  10. package/.docs/docs/browser/browser-viewer.md +144 -0
  11. package/.docs/docs/browser/overview.md +168 -0
  12. package/.docs/docs/browser/stagehand.md +129 -0
  13. package/.docs/docs/deployment/cloud-providers.md +5 -1
  14. package/.docs/docs/deployment/mastra-server.md +4 -4
  15. package/.docs/docs/deployment/monorepo.md +3 -3
  16. package/.docs/docs/deployment/overview.md +11 -8
  17. package/.docs/docs/editor/overview.md +290 -0
  18. package/.docs/docs/editor/prompts.md +134 -0
  19. package/.docs/docs/editor/tools.md +152 -0
  20. package/.docs/docs/evals/custom-scorers.md +63 -3
  21. package/.docs/docs/evals/datasets/overview.md +1 -1
  22. package/.docs/docs/index.md +2 -2
  23. package/.docs/docs/mastra-platform/configuration.md +36 -0
  24. package/.docs/docs/mastra-platform/overview.md +78 -0
  25. package/.docs/docs/mcp/overview.md +17 -0
  26. package/.docs/docs/memory/memory-processors.md +3 -3
  27. package/.docs/docs/memory/message-history.md +8 -2
  28. package/.docs/docs/memory/observational-memory.md +65 -8
  29. package/.docs/docs/memory/storage.md +1 -2
  30. package/.docs/docs/memory/working-memory.md +2 -2
  31. package/.docs/docs/observability/logging.md +1 -1
  32. package/.docs/docs/observability/metrics/overview.md +2 -2
  33. package/.docs/docs/observability/overview.md +1 -1
  34. package/.docs/docs/observability/tracing/bridges/datadog.md +217 -0
  35. package/.docs/docs/observability/tracing/bridges/otel.md +2 -2
  36. package/.docs/docs/observability/tracing/exporters/arthur.md +163 -0
  37. package/.docs/docs/observability/tracing/exporters/cloud.md +135 -63
  38. package/.docs/docs/observability/tracing/exporters/datadog.md +3 -1
  39. package/.docs/docs/observability/tracing/exporters/default.md +5 -5
  40. package/.docs/docs/observability/tracing/exporters/laminar.md +22 -14
  41. package/.docs/docs/observability/tracing/exporters/langfuse.md +50 -33
  42. package/.docs/docs/observability/tracing/overview.md +87 -20
  43. package/.docs/docs/server/custom-adapters.md +5 -5
  44. package/.docs/docs/server/custom-api-routes.md +3 -3
  45. package/.docs/docs/server/mastra-client.md +2 -2
  46. package/.docs/docs/server/mastra-server.md +1 -1
  47. package/.docs/docs/server/middleware.md +46 -42
  48. package/.docs/docs/server/request-context.md +13 -2
  49. package/.docs/docs/server/server-adapters.md +91 -8
  50. package/.docs/docs/streaming/background-task-streaming.md +80 -0
  51. package/.docs/docs/streaming/overview.md +3 -0
  52. package/.docs/docs/studio/deployment.md +24 -6
  53. package/.docs/docs/studio/observability.md +1 -1
  54. package/.docs/docs/studio/overview.md +4 -4
  55. package/.docs/docs/voice/overview.md +74 -5
  56. package/.docs/docs/voice/speech-to-speech.md +45 -1
  57. package/.docs/docs/voice/speech-to-text.md +7 -7
  58. package/.docs/docs/voice/text-to-speech.md +10 -10
  59. package/.docs/docs/workflows/agents-and-tools.md +1 -1
  60. package/.docs/docs/workflows/overview.md +105 -4
  61. package/.docs/docs/workflows/scheduled-workflows.md +181 -0
  62. package/.docs/docs/workspace/filesystem.md +64 -6
  63. package/.docs/docs/workspace/lsp.md +76 -4
  64. package/.docs/docs/workspace/overview.md +62 -15
  65. package/.docs/docs/workspace/sandbox.md +3 -1
  66. package/.docs/docs/workspace/search.md +41 -2
  67. package/.docs/docs/workspace/skills.md +19 -19
  68. package/.docs/guides/agent-frameworks/ai-sdk.md +4 -4
  69. package/.docs/guides/build-your-ui/ai-sdk-ui.md +56 -9
  70. package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
  71. package/.docs/guides/deployment/mastra-platform.md +191 -0
  72. package/.docs/guides/deployment/netlify.md +16 -1
  73. package/.docs/guides/getting-started/nestjs.md +238 -0
  74. package/.docs/guides/getting-started/next-js.md +0 -4
  75. package/.docs/guides/guide/code-review-bot.md +2 -2
  76. package/.docs/guides/guide/dev-assistant.md +4 -4
  77. package/.docs/{docs/mcp → guides/guide}/publishing-mcp-server.md +21 -1
  78. package/.docs/guides/guide/slack-assistant.md +191 -0
  79. package/.docs/guides/migrations/mastra-cloud.md +368 -0
  80. package/.docs/guides/migrations/upgrade-to-v1/tracing.md +1 -1
  81. package/.docs/models/embeddings.md +3 -3
  82. package/.docs/models/gateways/azure-openai.md +74 -35
  83. package/.docs/models/gateways/mastra.md +64 -0
  84. package/.docs/models/gateways/netlify.md +7 -3
  85. package/.docs/models/gateways/openrouter.md +28 -12
  86. package/.docs/models/gateways/vercel.md +22 -2
  87. package/.docs/models/gateways.md +1 -0
  88. package/.docs/models/index.md +43 -8
  89. package/.docs/models/providers/302ai.md +37 -4
  90. package/.docs/models/providers/abliteration-ai.md +71 -0
  91. package/.docs/models/providers/alibaba-cn.md +8 -2
  92. package/.docs/models/providers/alibaba-coding-plan-cn.md +3 -2
  93. package/.docs/models/providers/alibaba-coding-plan.md +3 -2
  94. package/.docs/models/providers/alibaba.md +8 -1
  95. package/.docs/models/providers/anthropic.md +18 -5
  96. package/.docs/models/providers/baseten.md +3 -1
  97. package/.docs/models/providers/berget.md +10 -12
  98. package/.docs/models/providers/chutes.md +4 -2
  99. package/.docs/models/providers/cloudflare-workers-ai.md +14 -48
  100. package/.docs/models/providers/cortecs.md +22 -2
  101. package/.docs/models/providers/deepinfra.md +8 -2
  102. package/.docs/models/providers/deepseek.md +6 -4
  103. package/.docs/models/providers/digitalocean.md +133 -0
  104. package/.docs/models/providers/fireworks-ai.md +6 -1
  105. package/.docs/models/providers/firmware.md +12 -10
  106. package/.docs/models/providers/friendli.md +6 -7
  107. package/.docs/models/providers/google.md +9 -3
  108. package/.docs/models/providers/helicone.md +1 -2
  109. package/.docs/models/providers/hpc-ai.md +73 -0
  110. package/.docs/models/providers/huggingface.md +6 -2
  111. package/.docs/models/providers/inception.md +9 -11
  112. package/.docs/models/providers/kilo.md +359 -339
  113. package/.docs/models/providers/kimi-for-coding.md +2 -1
  114. package/.docs/models/providers/llmgateway.md +67 -77
  115. package/.docs/models/providers/mistral.md +3 -2
  116. package/.docs/models/providers/mixlayer.md +75 -0
  117. package/.docs/models/providers/moonshotai-cn.md +3 -2
  118. package/.docs/models/providers/moonshotai.md +3 -2
  119. package/.docs/models/providers/nano-gpt.md +8 -2
  120. package/.docs/models/providers/neuralwatt.md +84 -0
  121. package/.docs/models/providers/novita-ai.md +19 -4
  122. package/.docs/models/providers/nvidia.md +8 -1
  123. package/.docs/models/providers/ollama-cloud.md +7 -2
  124. package/.docs/models/providers/openai.md +7 -2
  125. package/.docs/models/providers/opencode-go.md +21 -13
  126. package/.docs/models/providers/opencode.md +11 -4
  127. package/.docs/models/providers/ovhcloud.md +6 -8
  128. package/.docs/models/providers/poe.md +10 -15
  129. package/.docs/models/providers/regolo-ai.md +83 -0
  130. package/.docs/models/providers/siliconflow-cn.md +5 -2
  131. package/.docs/models/providers/siliconflow.md +6 -3
  132. package/.docs/models/providers/stepfun.md +8 -7
  133. package/.docs/models/providers/synthetic.md +5 -2
  134. package/.docs/models/providers/tencent-token-plan.md +71 -0
  135. package/.docs/models/providers/tencent-tokenhub.md +71 -0
  136. package/.docs/models/providers/togetherai.md +8 -7
  137. package/.docs/models/providers/vivgrid.md +7 -3
  138. package/.docs/models/providers/vultr.md +7 -6
  139. package/.docs/models/providers/wafer.ai.md +73 -0
  140. package/.docs/models/providers/wandb.md +3 -2
  141. package/.docs/models/providers/xai.md +6 -1
  142. package/.docs/models/providers/xiaomi-token-plan-ams.md +75 -0
  143. package/.docs/models/providers/xiaomi-token-plan-cn.md +75 -0
  144. package/.docs/models/providers/xiaomi-token-plan-sgp.md +75 -0
  145. package/.docs/models/providers/xiaomi.md +4 -2
  146. package/.docs/models/providers/zai-coding-plan.md +11 -19
  147. package/.docs/models/providers/zai.md +2 -1
  148. package/.docs/models/providers/zenmux.md +17 -6
  149. package/.docs/models/providers/zhipuai-coding-plan.md +11 -21
  150. package/.docs/models/providers/zhipuai.md +2 -1
  151. package/.docs/models/providers.md +11 -0
  152. package/.docs/reference/agents/agent.md +1 -1
  153. package/.docs/reference/agents/channels.md +3 -3
  154. package/.docs/reference/agents/generate.md +88 -6
  155. package/.docs/reference/agents/generateLegacy.md +1 -1
  156. package/.docs/reference/ai-sdk/chat-route.md +2 -0
  157. package/.docs/reference/ai-sdk/handle-chat-stream.md +19 -0
  158. package/.docs/reference/ai-sdk/handle-network-stream.md +2 -0
  159. package/.docs/reference/ai-sdk/network-route.md +2 -0
  160. package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +95 -0
  161. package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +15 -0
  162. package/.docs/reference/browser/agent-browser.md +375 -0
  163. package/.docs/reference/browser/browser-viewer.md +228 -0
  164. package/.docs/reference/browser/mastra-browser.md +286 -0
  165. package/.docs/reference/browser/stagehand-browser.md +286 -0
  166. package/.docs/reference/cli/mastra.md +703 -0
  167. package/.docs/reference/client-js/agents.md +166 -0
  168. package/.docs/reference/client-js/conversations.md +1 -1
  169. package/.docs/reference/client-js/mastra-client.md +23 -0
  170. package/.docs/reference/client-js/observability.md +2 -2
  171. package/.docs/reference/client-js/responses.md +1 -1
  172. package/.docs/reference/client-js/workflows.md +62 -1
  173. package/.docs/reference/configuration.md +67 -1
  174. package/.docs/reference/core/addGateway.md +5 -5
  175. package/.docs/reference/core/getEditor.md +35 -0
  176. package/.docs/reference/core/getGateway.md +5 -5
  177. package/.docs/reference/core/getGatewayById.md +5 -5
  178. package/.docs/reference/core/getMCPServer.md +2 -2
  179. package/.docs/reference/core/getMCPServerById.md +2 -2
  180. package/.docs/reference/core/getScorer.md +3 -3
  181. package/.docs/reference/core/getScorerById.md +3 -3
  182. package/.docs/reference/core/listGateways.md +5 -5
  183. package/.docs/reference/core/listMCPServers.md +2 -2
  184. package/.docs/reference/core/listScorers.md +3 -3
  185. package/.docs/reference/core/mastra-class.md +11 -1
  186. package/.docs/reference/core/mastra-model-gateway.md +5 -5
  187. package/.docs/reference/datasets/create.md +4 -4
  188. package/.docs/reference/datasets/startExperiment.md +28 -2
  189. package/.docs/reference/datasets/update.md +4 -4
  190. package/.docs/reference/deployer/cloudflare.md +14 -1
  191. package/.docs/reference/deployer/netlify.md +50 -2
  192. package/.docs/reference/editor/mastra-editor.md +168 -0
  193. package/.docs/reference/editor/tool-provider.md +85 -0
  194. package/.docs/reference/evals/context-precision.md +3 -3
  195. package/.docs/reference/evals/context-relevance.md +3 -3
  196. package/.docs/reference/evals/create-scorer.md +5 -3
  197. package/.docs/reference/evals/filter-run.md +117 -0
  198. package/.docs/reference/evals/mastra-scorer.md +4 -4
  199. package/.docs/reference/evals/noise-sensitivity.md +6 -6
  200. package/.docs/reference/evals/prompt-alignment.md +12 -12
  201. package/.docs/reference/evals/run-evals.md +6 -6
  202. package/.docs/reference/evals/scorer-utils.md +3 -3
  203. package/.docs/reference/evals/trajectory-accuracy.md +3 -3
  204. package/.docs/reference/harness/harness-class.md +152 -53
  205. package/.docs/reference/index.md +25 -0
  206. package/.docs/reference/logging/pino-logger.md +0 -2
  207. package/.docs/reference/mastra-platform/api.md +108 -0
  208. package/.docs/reference/memory/clone-utilities.md +4 -2
  209. package/.docs/reference/memory/cloneThread.md +4 -2
  210. package/.docs/reference/memory/observational-memory.md +4 -0
  211. package/.docs/reference/observability/metrics/automatic-metrics.md +3 -3
  212. package/.docs/reference/observability/tracing/bridges/datadog.md +211 -0
  213. package/.docs/reference/observability/tracing/bridges/otel.md +3 -3
  214. package/.docs/reference/observability/tracing/configuration.md +18 -11
  215. package/.docs/reference/observability/tracing/exporters/arthur.md +122 -0
  216. package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +102 -21
  217. package/.docs/reference/observability/tracing/exporters/console-exporter.md +8 -8
  218. package/.docs/reference/observability/tracing/exporters/datadog.md +3 -1
  219. package/.docs/reference/observability/tracing/exporters/default-exporter.md +8 -8
  220. package/.docs/reference/observability/tracing/exporters/langfuse.md +25 -32
  221. package/.docs/reference/observability/tracing/exporters/otel.md +3 -3
  222. package/.docs/reference/observability/tracing/instances.md +7 -7
  223. package/.docs/reference/observability/tracing/interfaces.md +23 -6
  224. package/.docs/reference/observability/tracing/span-filtering.md +95 -0
  225. package/.docs/reference/observability/tracing/spans.md +6 -6
  226. package/.docs/reference/processors/prefill-error-handler.md +70 -0
  227. package/.docs/reference/processors/processor-interface.md +400 -40
  228. package/.docs/reference/processors/skill-search-processor.md +20 -1
  229. package/.docs/reference/processors/stream-error-retry-processor.md +54 -0
  230. package/.docs/reference/processors/tool-call-filter.md +23 -0
  231. package/.docs/reference/server/create-route.md +3 -3
  232. package/.docs/reference/server/express-adapter.md +4 -4
  233. package/.docs/reference/server/fastify-adapter.md +4 -4
  234. package/.docs/reference/server/hono-adapter.md +4 -4
  235. package/.docs/reference/server/koa-adapter.md +4 -4
  236. package/.docs/reference/server/mastra-server.md +3 -3
  237. package/.docs/reference/server/nestjs-adapter.md +169 -0
  238. package/.docs/reference/server/register-api-route.md +4 -4
  239. package/.docs/reference/server/routes.md +11 -10
  240. package/.docs/reference/storage/clickhouse.md +300 -0
  241. package/.docs/reference/storage/cloudflare-d1.md +42 -42
  242. package/.docs/reference/storage/composite.md +5 -3
  243. package/.docs/reference/storage/duckdb.md +150 -0
  244. package/.docs/reference/storage/overview.md +1 -1
  245. package/.docs/reference/storage/redis.md +266 -0
  246. package/.docs/reference/streaming/ChunkType.md +143 -3
  247. package/.docs/reference/streaming/agents/MastraModelOutput.md +2 -2
  248. package/.docs/reference/streaming/agents/stream.md +10 -2
  249. package/.docs/reference/streaming/agents/streamUntilIdle.md +94 -0
  250. package/.docs/reference/streaming/workflows/resumeStream.md +2 -0
  251. package/.docs/reference/templates/overview.md +88 -14
  252. package/.docs/reference/tools/create-tool.md +107 -5
  253. package/.docs/reference/tools/mcp-client.md +45 -0
  254. package/.docs/reference/tools/mcp-server.md +1 -3
  255. package/.docs/reference/tools/perplexity.md +155 -0
  256. package/.docs/reference/tools/tavily.md +307 -0
  257. package/.docs/reference/vectors/mongodb.md +0 -2
  258. package/.docs/reference/voice/aws-nova-sonic.md +247 -0
  259. package/.docs/reference/voice/cloudflare.md +3 -3
  260. package/.docs/reference/voice/sarvam.md +29 -23
  261. package/.docs/reference/voice/voice.connect.md +4 -4
  262. package/.docs/reference/voice/voice.listen.md +3 -3
  263. package/.docs/reference/workflows/run-methods/resume.md +24 -0
  264. package/.docs/reference/workflows/run-methods/startAsync.md +1 -1
  265. package/.docs/reference/workflows/step.md +88 -7
  266. package/.docs/reference/workflows/workflow-methods/foreach.md +14 -1
  267. package/.docs/reference/workflows/workflow.md +88 -4
  268. package/.docs/reference/workspace/azure-blob-filesystem.md +219 -0
  269. package/.docs/reference/workspace/docker-sandbox.md +196 -0
  270. package/.docs/reference/workspace/gcs-filesystem.md +1 -0
  271. package/.docs/reference/workspace/google-drive-filesystem.md +185 -0
  272. package/.docs/reference/workspace/modal-sandbox.md +168 -0
  273. package/.docs/reference/workspace/process-manager.md +1 -1
  274. package/.docs/reference/workspace/s3-filesystem.md +80 -5
  275. package/.docs/reference/workspace/vercel.md +1 -1
  276. package/.docs/reference/workspace/workspace-class.md +37 -6
  277. package/CHANGELOG.md +500 -4
  278. package/dist/stdio.js.map +1 -1
  279. package/dist/utils.d.ts +1 -4
  280. package/dist/utils.d.ts.map +1 -1
  281. package/package.json +11 -11
  282. package/.docs/docs/mastra-cloud/deployment.md +0 -77
  283. package/.docs/docs/mastra-cloud/observability.md +0 -38
  284. package/.docs/docs/mastra-cloud/overview.md +0 -23
  285. package/.docs/docs/mastra-cloud/setup.md +0 -42
@@ -4,7 +4,7 @@ The `Processor` interface defines the contract for all processors in Mastra. Pro
4
4
 
5
5
  ## When processor methods run
6
6
 
7
- The five processor methods run at different points in the agent execution lifecycle:
7
+ The six processor methods run at different points in the agent execution lifecycle:
8
8
 
9
9
  ```text
10
10
  ┌─────────────────────────────────────────────────────────────────┐
@@ -26,10 +26,14 @@ The five processor methods run at different points in the agent execution lifecy
26
26
  │ │ └──────────┬──────────┘ │ │
27
27
  │ │ │ │ │
28
28
  │ │ ▼ │ │
29
- │ │ LLM Execution │ │
30
- │ │ │ │ │
31
- │ │ ▼ │ │
32
- │ │ ┌──────────────────────┐ │ │
29
+ │ │ LLM Execution ──── API Error? ──┐ │ │
30
+ │ │ │ │ │ │
31
+ │ │ │ ┌───────────────────┐ │ │
32
+ │ │ │ │ processAPIError │ │ │
33
+ │ │ │ └─────────┬─────────┘ │ │
34
+ │ │ │ retry? └── Loop back ──┐ │ │
35
+ │ │ ▼ │ │ │
36
+ │ │ ┌──────────────────────┐ │ │ │
33
37
  │ │ │ processOutputStream │ ← Runs on EACH stream chunk │ │
34
38
  │ │ └──────────┬───────────┘ │ │
35
39
  │ │ │ │ │
@@ -55,26 +59,52 @@ The five processor methods run at different points in the agent execution lifecy
55
59
  └─────────────────────────────────────────────────────────────────┘
56
60
  ```
57
61
 
58
- | Method | When it runs | Use case |
59
- | --------------------- | ------------------------------------------------------ | ------------------------------------------------------------- |
60
- | `processInput` | Once at the start, before the agentic loop | Validate/transform initial user input, add context |
61
- | `processInputStep` | At each step of the agentic loop, before each LLM call | Transform messages between steps, handle tool results |
62
- | `processOutputStream` | On each streaming chunk during LLM response | Filter/modify streaming content, detect patterns in real-time |
63
- | `processOutputStep` | After each LLM response, before tool execution | Validate output quality, implement guardrails with retry |
64
- | `processOutputResult` | Once after generation completes | Post-process final response, log results |
62
+ | Method | When it runs | Use case |
63
+ | --------------------- | ------------------------------------------------------ | ----------------------------------------------------------------------------- |
64
+ | `processInput` | Once at the start, before the agentic loop | Validate/transform initial user input, add context |
65
+ | `processInputStep` | At each step of the agentic loop, before each LLM call | Transform messages between steps, handle tool results |
66
+ | `processAPIError` | When an LLM API call fails | Inspect API rejections, optionally mutate state/messages, and request a retry |
67
+ | `processOutputStream` | On each streaming chunk during LLM response | Filter/modify streaming content, detect patterns in real-time |
68
+ | `processOutputStep` | After each LLM response, before tool execution | Validate output quality, implement guardrails with retry |
69
+ | `processOutputResult` | Once after generation completes | Post-process final response, log results |
65
70
 
66
71
  ## Interface definition
67
72
 
68
73
  ```typescript
69
- interface Processor<TId extends string = string> {
74
+ interface Processor<TId extends string = string, TTripwireMetadata = unknown> {
70
75
  readonly id: TId
71
76
  readonly name?: string
72
-
73
- processInput?(args: ProcessInputArgs): Promise<ProcessInputResult> | ProcessInputResult
74
- processInputStep?(args: ProcessInputStepArgs): ProcessorMessageResult
75
- processOutputStream?(args: ProcessOutputStreamArgs): Promise<ChunkType | null | undefined>
76
- processOutputStep?(args: ProcessOutputStepArgs): ProcessorMessageResult
77
- processOutputResult?(args: ProcessOutputResultArgs): ProcessorMessageResult
77
+ readonly description?: string
78
+ /** Index of this processor in the workflow (set at runtime when combining processors). */
79
+ processorIndex?: number
80
+ /** When true, processOutputStream also receives `data-*` chunks. Default: false. */
81
+ processDataParts?: boolean
82
+
83
+ processInput?(
84
+ args: ProcessInputArgs<TTripwireMetadata>,
85
+ ): Promise<ProcessInputResult> | ProcessInputResult
86
+
87
+ processInputStep?(
88
+ args: ProcessInputStepArgs<TTripwireMetadata>,
89
+ ):
90
+ | Promise<ProcessInputStepResult | MessageList | MastraDBMessage[] | undefined | void>
91
+ | ProcessInputStepResult
92
+ | MessageList
93
+ | MastraDBMessage[]
94
+ | void
95
+ | undefined
96
+
97
+ processAPIError?(
98
+ args: ProcessAPIErrorArgs<TTripwireMetadata>,
99
+ ): Promise<ProcessAPIErrorResult | void> | ProcessAPIErrorResult | void
100
+
101
+ processOutputStream?(
102
+ args: ProcessOutputStreamArgs<TTripwireMetadata>,
103
+ ): Promise<ChunkType | null | undefined>
104
+
105
+ processOutputStep?(args: ProcessOutputStepArgs<TTripwireMetadata>): ProcessorMessageResult
106
+
107
+ processOutputResult?(args: ProcessOutputResultArgs<TTripwireMetadata>): ProcessorMessageResult
78
108
  }
79
109
  ```
80
110
 
@@ -84,8 +114,71 @@ interface Processor<TId extends string = string> {
84
114
 
85
115
  **name** (`string`): Optional display name for the processor. Falls back to id if not provided.
86
116
 
117
+ **description** (`string`): Optional human-readable description shown in tracing and Studio.
118
+
119
+ **processorIndex** (`number`): Position of the processor in the combined processor list. Set at runtime by Mastra when processors are merged with memory, workspace, and per-call overrides. You do not set this yourself.
120
+
87
121
  **processDataParts** (`boolean`): When true, the processOutputStream method also receives \`data-\*\` chunks emitted by tools via writer.custom(). Defaults to false.
88
122
 
123
+ ## Message arguments
124
+
125
+ Most processor methods receive both `messages` and `messageList`. They point to the same underlying conversation but expose it differently.
126
+
127
+ ### `messages` vs `messageList`
128
+
129
+ - `messages`: A plain array of `MastraDBMessage` objects, scoped to the current stage. For `processInput` and `processInputStep` this excludes system messages. For `processOutputResult` and `processOutputStep` this includes the latest LLM response. The array is backed by `messageList`, so editing a message's `content.parts` in place is visible to downstream processors and to persistence.
130
+ - `messageList`: The live `MessageList` instance backing the run. It exposes filtered views (input, response, remembered, all), multiple output formats (db, ui, core), and methods for mutating the conversation.
131
+
132
+ Use `messages` when you only need to read, map over, or lightly edit fields on the current stage's messages. Use `messageList` when you need to:
133
+
134
+ - Read messages from another stage, for example input messages while processing output.
135
+ - Add, remove, or replace whole messages.
136
+ - Convert to another format such as UI or core messages for a third-party API.
137
+
138
+ `messages` is always derived from `messageList`, so mutating `messageList` is the canonical way to add, remove, or reorder messages. For in-place edits to a message's content (for example, rewriting `content.parts`), mutating `messages` directly is equivalent. If you return a new array from `messages`, Mastra reconciles it against `messageList` for the current stage.
139
+
140
+ ### Persistence
141
+
142
+ When memory is enabled, only what ends up in `messageList` after all processors finish is persisted to storage. The two return styles are equivalent for persistence:
143
+
144
+ - Mutating `messageList` directly (or returning the same `MessageList` instance) — recorded mutations are applied in place, so the saved conversation reflects your changes.
145
+ - Returning a `MastraDBMessage[]` or `{ messages, systemMessages }` — Mastra reconciles the returned array against `messageList` for the current stage, removing missing messages and replacing system messages.
146
+
147
+ Returning a different `MessageList` instance is an error; always mutate the one passed to your processor.
148
+
149
+ ### Reading text from a message
150
+
151
+ `MastraDBMessage.content` is a structured object, not a string. The canonical way to read user or assistant text is `content.parts`:
152
+
153
+ ```typescript
154
+ import type { MastraDBMessage } from '@mastra/core/memory'
155
+
156
+ function getText(message: MastraDBMessage): string {
157
+ let text = ''
158
+
159
+ if (message.content.parts) {
160
+ for (const part of message.content.parts) {
161
+ if (part.type === 'text' && typeof part.text === 'string') {
162
+ text += part.text
163
+ }
164
+ }
165
+ }
166
+
167
+ // Fallback for legacy messages that only have the flattened `content` string
168
+ if (!text && typeof message.content.content === 'string') {
169
+ text = message.content.content
170
+ }
171
+
172
+ return text
173
+ }
174
+ ```
175
+
176
+ Key points:
177
+
178
+ - `message.content.parts` is the primary source. A single message can contain multiple parts, including non-text parts such as tool calls, tool results, and file parts. Filter by `part.type === 'text'` before reading `part.text`.
179
+ - `message.content.content` is a flattened string kept for backward compatibility. Use it only as a fallback when `parts` is empty or missing.
180
+ - `message.content` itself is never a plain string on `MastraDBMessage`. Legacy `CoreMessage` shapes may be strings, but processors always receive `MastraDBMessage`.
181
+
89
182
  ## Methods
90
183
 
91
184
  ### `processInput`
@@ -106,7 +199,7 @@ processInput?(args: ProcessInputArgs): Promise<ProcessInputResult> | ProcessInpu
106
199
 
107
200
  **abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing. Throws a TripWire error that stops execution. Pass \`retry: true\` to request the LLM retry the step with feedback.
108
201
 
109
- **retryCount** (`number`): Number of times processors have triggered retry for this generation. Use this to limit retry attempts.
202
+ **retryCount** (`number`): Number of times processors have triggered retry for this generation. Use this to limit retry attempts. Always passed by Mastra; starts at 0.
110
203
 
111
204
  **tracingContext** (`TracingContext`): Tracing context for observability.
112
205
 
@@ -129,7 +222,15 @@ The method can return one of three types:
129
222
  Processes input messages at each step of the agentic loop, before they're sent to the LLM. Unlike `processInput` which runs once at the start, this runs at every step including tool call continuations.
130
223
 
131
224
  ```typescript
132
- processInputStep?(args: ProcessInputStepArgs): ProcessorMessageResult;
225
+ processInputStep?<TTripwireMetadata = unknown>(
226
+ args: ProcessInputStepArgs<TTripwireMetadata>,
227
+ ):
228
+ | Promise<ProcessInputStepResult | MessageList | MastraDBMessage[] | void | undefined>
229
+ | ProcessInputStepResult
230
+ | MessageList
231
+ | MastraDBMessage[]
232
+ | void
233
+ | undefined;
133
234
  ```
134
235
 
135
236
  #### Execution order in the agentic loop
@@ -167,7 +268,9 @@ processInputStep?(args: ProcessInputStepArgs): ProcessorMessageResult;
167
268
 
168
269
  **structuredOutput** (`StructuredOutputOptions`): Structured output configuration (schema, output mode). Return in result to modify.
169
270
 
170
- **abort** (`(reason?: string) => never`): Function to abort processing.
271
+ **abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing. Throws a TripWire error that stops execution. Pass \`retry: true\` to request the LLM retry the step with feedback.
272
+
273
+ **retryCount** (`number`): Current retry attempt count from \`ProcessorContext\`. Starts at \`0\`; use to cap processor-triggered retries.
171
274
 
172
275
  **tracingContext** (`TracingContext`): Tracing context for observability.
173
276
 
@@ -175,7 +278,14 @@ processInputStep?(args: ProcessInputStepArgs): ProcessorMessageResult;
175
278
 
176
279
  #### `ProcessInputStepResult`
177
280
 
178
- The method can return any combination of these properties:
281
+ `processInputStep` can return several shapes:
282
+
283
+ - **`ProcessInputStepResult` object** — override any combination of the properties below for this step (described next).
284
+ - **`MessageList`** — return the same `messageList` instance to signal you mutated messages in place.
285
+ - **`MastraDBMessage[]`** — return a transformed messages array; replaces the step's messages.
286
+ - **`void` or `undefined`** — return nothing to leave the step unchanged.
287
+
288
+ The object form can return any combination of these properties:
179
289
 
180
290
  **model** (`LanguageModelV2 | string`): Change the model for this step. Can be a model instance or router ID like 'openai/gpt-5.4'.
181
291
 
@@ -224,6 +334,84 @@ System messages are **reset to their original values** at the start of each step
224
334
 
225
335
  ***
226
336
 
337
+ ### `processAPIError`
338
+
339
+ Handles LLM API rejection errors before they surface as final errors. This runs when the API call fails with a non-retryable error (such as a 400 or 422 status code). Unlike `processOutputStep` which runs after successful responses, this runs when the API rejects the request.
340
+
341
+ Add processors that implement `processAPIError` to an agent's `errorProcessors` array.
342
+
343
+ Processors can inspect the error, modify the request (for example, by appending messages to the `messageList`), and return `{ retry: true }` to signal a retry with the modified state.
344
+
345
+ ```typescript
346
+ processAPIError?(args: ProcessAPIErrorArgs): Promise<ProcessAPIErrorResult | void> | ProcessAPIErrorResult | void;
347
+ ```
348
+
349
+ #### `ProcessAPIErrorArgs`
350
+
351
+ **error** (`unknown`): The error that occurred during the LLM API call.
352
+
353
+ **messages** (`MastraDBMessage[]`): All messages at the time of the error.
354
+
355
+ **messageList** (`MessageList`): MessageList instance for managing messages. Modify this to change the request before retry.
356
+
357
+ **stepNumber** (`number`): Current step number (0-indexed).
358
+
359
+ **steps** (`StepResult[]`): All completed steps so far.
360
+
361
+ **state** (`Record<string, unknown>`): Per-processor state that persists across all method calls within this request.
362
+
363
+ **retryCount** (`number`): The current retry count for error handlers. Use this to limit retry attempts.
364
+
365
+ **abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing.
366
+
367
+ **writer** (`ProcessorStreamWriter`): Stream writer for emitting custom data chunks during streaming. Use \`writer.custom()\` to send transient UI signals.
368
+
369
+ **requestContext** (`RequestContext`): Request context passed through from the agent call.
370
+
371
+ **abortSignal** (`AbortSignal`): Signal for cancelling the operation.
372
+
373
+ #### `ProcessAPIErrorResult`
374
+
375
+ **retry** (`boolean`): Whether to retry the LLM call after applying modifications.
376
+
377
+ #### Use cases
378
+
379
+ - Handling API-specific rejections by modifying the request and retrying
380
+ - Converting non-retryable errors into retryable ones with request modifications
381
+ - Implementing model-specific error recovery strategies
382
+
383
+ #### Example: Custom error recovery
384
+
385
+ ```typescript
386
+ import { APICallError } from '@ai-sdk/provider'
387
+ import type { Processor, ProcessAPIErrorArgs, ProcessAPIErrorResult } from '@mastra/core/processors'
388
+
389
+ export class ErrorRecoveryProcessor implements Processor {
390
+ id = 'error-recovery'
391
+
392
+ processAPIError({
393
+ error,
394
+ messageList,
395
+ retryCount,
396
+ }: ProcessAPIErrorArgs): ProcessAPIErrorResult | void {
397
+ // Only retry once
398
+ if (retryCount > 0) return
399
+
400
+ // Check for a specific API error
401
+ if (APICallError.isInstance(error) && error.message.includes('context length exceeded')) {
402
+ // Trim older messages to fit within context
403
+ const messages = messageList.get.all.db()
404
+ if (messages.length > 4) {
405
+ messageList.removeByIds([messages[1]!.id, messages[2]!.id])
406
+ return { retry: true }
407
+ }
408
+ }
409
+ }
410
+ }
411
+ ```
412
+
413
+ ***
414
+
227
415
  ### `processOutputStream`
228
416
 
229
417
  Processes streaming output chunks with built-in state management. Allows processors to accumulate chunks and make decisions based on larger context.
@@ -238,9 +426,11 @@ processOutputStream?(args: ProcessOutputStreamArgs): Promise<ChunkType | null |
238
426
 
239
427
  **streamParts** (`ChunkType[]`): All chunks seen so far in the stream.
240
428
 
241
- **state** (`Record<string, unknown>`): Mutable state object that persists across chunks within a single stream.
429
+ **state** (`Record<string, unknown>`): Mutable per-processor state that persists across every chunk and every method call within a single request. A fresh state object is created for each new generate or stream call.
242
430
 
243
- **abort** (`(reason?: string) => never`): Function to abort the stream.
431
+ **abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort the stream. Throws a TripWire error that ends the stream and emits a \`tripwire\` chunk. Pass \`retry: true\` to request another LLM attempt instead of ending.
432
+
433
+ **retryCount** (`number`): Current retry attempt count from \`ProcessorContext\`. Starts at \`0\`; use to cap processor-triggered retries.
244
434
 
245
435
  **messageList** (`MessageList`): MessageList instance for accessing conversation history.
246
436
 
@@ -252,8 +442,13 @@ processOutputStream?(args: ProcessOutputStreamArgs): Promise<ChunkType | null |
252
442
 
253
443
  #### Return value
254
444
 
255
- - Return the `ChunkType` to emit it (possibly modified)
256
- - Return `null` or `undefined` to skip emitting the chunk
445
+ `processOutputStream` returns `Promise<ChunkType | null | undefined>`.
446
+
447
+ - Return the `ChunkType` to emit the chunk. Return the original `part` to emit it unchanged, or a new `ChunkType` to emit a modified chunk.
448
+ - Return `null` to drop the chunk. Nothing is sent to the next processor or the client.
449
+ - Return `undefined` (including implicit `undefined` from a `return;` statement or a method that falls off the end) to drop the chunk. `null` and `undefined` behave the same way.
450
+
451
+ 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()`.
257
452
 
258
453
  ***
259
454
 
@@ -275,7 +470,9 @@ processOutputResult?(args: ProcessOutputResultArgs): ProcessorMessageResult;
275
470
 
276
471
  **result** (`OutputResult`): Resolved generation result containing \`text\` (accumulated text), \`usage\` (token usage with inputTokens, outputTokens, totalTokens), \`finishReason\` (why generation ended), and \`steps\` (all LLM step results, each with toolCalls, toolResults, reasoning, sources, files, etc.).
277
472
 
278
- **abort** (`(reason?: string) => never`): Function to abort processing.
473
+ **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.
474
+
475
+ **retryCount** (`number`): Current retry attempt count from \`ProcessorContext\`. Starts at \`0\`; use to cap processor-triggered retries.
279
476
 
280
477
  **tracingContext** (`TracingContext`): Tracing context for observability.
281
478
 
@@ -307,11 +504,17 @@ processOutputStep?(args: ProcessOutputStepArgs): ProcessorMessageResult;
307
504
 
308
505
  **text** (`string`): Generated text from this step.
309
506
 
507
+ **usage** (`LanguageModelUsage`): Token usage for the current step (\`inputTokens\`, \`outputTokens\`, \`totalTokens\`).
508
+
310
509
  **systemMessages** (`CoreMessage[]`): All system messages for read/modify access.
311
510
 
511
+ **steps** (`StepResult[]`): All completed steps so far, including the current step.
512
+
513
+ **state** (`Record<string, unknown>`): Per-processor state that persists across all method calls within this request. Shared with processOutputStream and processOutputResult.
514
+
312
515
  **abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing. Pass \`retry: true\` to request the LLM retry the step.
313
516
 
314
- **retryCount** (`number`): Number of times processors have triggered retry. Use this to limit retry attempts.
517
+ **retryCount** (`number`): Number of times processors have triggered retry. Use this to limit retry attempts. Always passed by Mastra; starts at 0.
315
518
 
316
519
  **tracingContext** (`TracingContext`): Tracing context for observability.
317
520
 
@@ -327,7 +530,7 @@ processOutputStep?(args: ProcessOutputStepArgs): ProcessorMessageResult;
327
530
  #### Example: Quality guardrail with retry
328
531
 
329
532
  ```typescript
330
- import type { Processor } from '@mastra/core'
533
+ import type { Processor } from '@mastra/core/processors'
331
534
 
332
535
  export class QualityGuardrail implements Processor {
333
536
  id = 'quality-guardrail'
@@ -368,6 +571,18 @@ type OutputProcessor = Processor &
368
571
  | { processOutputStep: required }
369
572
  | { processOutputResult: required }
370
573
  )
574
+
575
+ // Must implement processAPIError
576
+ type ErrorProcessor = Processor & { processAPIError: required }
577
+ ```
578
+
579
+ Configure processors that implement `processAPIError` in `errorProcessors`:
580
+
581
+ ```typescript
582
+ const agent = new Agent({
583
+ // ...
584
+ errorProcessors: [new PrefillErrorHandler()],
585
+ })
371
586
  ```
372
587
 
373
588
  ## Usage examples
@@ -375,7 +590,8 @@ type OutputProcessor = Processor &
375
590
  ### Basic input processor
376
591
 
377
592
  ```typescript
378
- import type { Processor, MastraDBMessage } from '@mastra/core'
593
+ import type { Processor } from '@mastra/core/processors'
594
+ import type { MastraDBMessage } from '@mastra/core/memory'
379
595
 
380
596
  export class LowercaseProcessor implements Processor {
381
597
  id = 'lowercase'
@@ -397,7 +613,11 @@ export class LowercaseProcessor implements Processor {
397
613
  ### Per-step processor with `processInputStep`
398
614
 
399
615
  ```typescript
400
- import type { Processor, ProcessInputStepArgs, ProcessInputStepResult } from '@mastra/core'
616
+ import type {
617
+ Processor,
618
+ ProcessInputStepArgs,
619
+ ProcessInputStepResult,
620
+ } from '@mastra/core/processors'
401
621
 
402
622
  export class DynamicModelProcessor implements Processor {
403
623
  id = 'dynamic-model'
@@ -430,7 +650,8 @@ export class DynamicModelProcessor implements Processor {
430
650
  ### Message transformer with `processInputStep`
431
651
 
432
652
  ```typescript
433
- import type { Processor, MastraDBMessage } from '@mastra/core'
653
+ import type { Processor } from '@mastra/core/processors'
654
+ import type { MastraDBMessage } from '@mastra/core/memory'
434
655
 
435
656
  export class ReasoningTransformer implements Processor {
436
657
  id = 'reasoning-transformer'
@@ -455,7 +676,9 @@ export class ReasoningTransformer implements Processor {
455
676
  ### Hybrid processor (input and output)
456
677
 
457
678
  ```typescript
458
- import type { Processor, MastraDBMessage, ChunkType } from '@mastra/core'
679
+ import type { Processor } from '@mastra/core/processors'
680
+ import type { MastraDBMessage } from '@mastra/core/memory'
681
+ import type { ChunkType } from '@mastra/core/stream'
459
682
 
460
683
  export class ContentFilter implements Processor {
461
684
  id = 'content-filter'
@@ -481,7 +704,7 @@ export class ContentFilter implements Processor {
481
704
 
482
705
  async processOutputStream({ part, abort }): Promise<ChunkType | null> {
483
706
  if (part.type === 'text-delta') {
484
- if (this.blockedWords.some(word => part.textDelta.includes(word))) {
707
+ if (this.blockedWords.some(word => part.payload.text.includes(word))) {
485
708
  abort('Blocked content detected in output')
486
709
  }
487
710
  }
@@ -493,7 +716,8 @@ export class ContentFilter implements Processor {
493
716
  ### Stream accumulator with state
494
717
 
495
718
  ```typescript
496
- import type { Processor, ChunkType } from '@mastra/core'
719
+ import type { Processor } from '@mastra/core/processors'
720
+ import type { ChunkType } from '@mastra/core/stream'
497
721
 
498
722
  export class WordCounter implements Processor {
499
723
  id = 'word-counter'
@@ -506,7 +730,7 @@ export class WordCounter implements Processor {
506
730
 
507
731
  // Count words in text chunks
508
732
  if (part.type === 'text-delta') {
509
- const words = part.textDelta.split(/\s+/).filter(Boolean)
733
+ const words = part.payload.text.split(/\s+/).filter(Boolean)
510
734
  state.wordCount += words.length
511
735
  }
512
736
 
@@ -520,8 +744,144 @@ export class WordCounter implements Processor {
520
744
  }
521
745
  ```
522
746
 
747
+ ## State lifecycle
748
+
749
+ Every processor receives a `state` object in `processOutputStream`, `processOutputStep`, `processOutputResult`, and `processAPIError`. State has three important properties:
750
+
751
+ - **Per-processor**: Each processor gets its own `state` object, keyed by the processor's `id`. Two processors with different ids cannot read or overwrite each other's state.
752
+ - **Per-request**: A fresh state object is created at the start of every `agent.generate()` or `agent.stream()` call. State does not leak between requests or between users.
753
+ - **Shared across methods**: Within one request, the same `state` object is passed to `processOutputStream` (for every chunk), `processOutputStep` (after every LLM step), `processOutputResult` (once at the end), and `processAPIError` (when an LLM call fails). Accumulate data in `processOutputStream` and read it in `processOutputResult` or `processAPIError`.
754
+
755
+ Initialize fields defensively on first access, because `state` starts as an empty object:
756
+
757
+ ```typescript
758
+ import type { Processor } from '@mastra/core/processors'
759
+
760
+ export class WordCounter implements Processor {
761
+ id = 'word-counter'
762
+
763
+ async processOutputStream({ part, state }) {
764
+ state.wordCount ??= 0
765
+ if (part.type === 'text-delta') {
766
+ state.wordCount += part.payload.text.split(/\s+/).filter(Boolean).length
767
+ }
768
+ return part
769
+ }
770
+ }
771
+ ```
772
+
773
+ ## Aborting and tripwire chunks
774
+
775
+ The `abort` function on each method throws a `TripWire` error that stops processing and emits a `tripwire` chunk on the output stream. Clients can detect the chunk to distinguish a blocked response from a normal finish.
776
+
777
+ ```typescript
778
+ abort('Blocked content detected', { retry: false, metadata: { category: 'pii' } })
779
+ ```
780
+
781
+ - `reason`: A human-readable explanation. Appears as `tripwire.payload.reason`.
782
+ - `retry`: When `true`, the agent retries the same step with `reason` fed back as feedback. Retries only run when `maxProcessorRetries` is set on the agent or call; otherwise the request aborts. When `errorProcessors` are configured, `maxProcessorRetries` defaults to `10` for that call.
783
+ - `metadata`: Optional structured data attached to the `tripwire` chunk for downstream consumers.
784
+
785
+ The emitted `tripwire` chunk has the shape:
786
+
787
+ ```typescript
788
+ type TripwireChunk = {
789
+ type: 'tripwire'
790
+ runId: string
791
+ from: 'AGENT'
792
+ payload: {
793
+ reason: string
794
+ retry?: boolean
795
+ metadata?: unknown
796
+ processorId: string
797
+ }
798
+ }
799
+ ```
800
+
801
+ In non-streaming calls (`agent.generate()`), the result exposes the same information as `result.tripwire` and `result.finishReason === 'other'`.
802
+
803
+ ## Emitting custom data chunks
804
+
805
+ Processors with access to `writer` can stream custom `data-*` chunks to the client by calling `writer.custom(chunk)`. Tools can do the same through their own writer. This is the only way for a processor to emit content outside of normal text and tool chunks.
806
+
807
+ ```typescript
808
+ await writer.custom({
809
+ type: 'data-moderation',
810
+ runId,
811
+ from: 'AGENT',
812
+ data: { level: 'warn', reason: 'Possibly unsafe' },
813
+ })
814
+ ```
815
+
816
+ By default, processors do **not** see `data-*` chunks in `processOutputStream` so they don't accidentally process tool telemetry or their own output. Opt in by setting `processDataParts: true` on the processor:
817
+
818
+ ```typescript
819
+ class ModerationCollector implements Processor {
820
+ id = 'moderation-collector'
821
+ processDataParts = true
822
+
823
+ async processOutputStream({ part, state }) {
824
+ if (part.type === 'data-moderation') {
825
+ state.warnings ??= []
826
+ state.warnings.push(part.data)
827
+ }
828
+ return part
829
+ }
830
+ }
831
+ ```
832
+
833
+ The chunk `type` must start with `data-` to be treated as a custom data chunk. Returning `null` or `undefined` from `processOutputStream` still drops the chunk, so a processor can inspect, modify, or filter custom data the same way it filters text chunks.
834
+
835
+ ## Configuring processors on an agent
836
+
837
+ Processors are attached to an agent through three arrays:
838
+
839
+ ```typescript
840
+ import { Agent } from '@mastra/core/agent'
841
+ import { PrefillErrorHandler } from '@mastra/core/processors'
842
+
843
+ const agent = new Agent({
844
+ name: 'support-agent',
845
+ model: 'openai/gpt-5',
846
+ instructions: '...',
847
+ inputProcessors: [new ContentFilter(['secret'])],
848
+ outputProcessors: [new WordCounter()],
849
+ errorProcessors: [new PrefillErrorHandler()],
850
+ maxProcessorRetries: 3,
851
+ })
852
+ ```
853
+
854
+ - `inputProcessors`: Run before the LLM. Receives input messages.
855
+ - `outputProcessors`: Run during or after the LLM response. Receives output chunks or messages.
856
+ - `errorProcessors`: Run when the LLM API call throws. Receives the raw error.
857
+
858
+ Each array also accepts a function so processors can be built per-request from `RequestContext`:
859
+
860
+ ```typescript
861
+ new Agent({
862
+ // ...
863
+ inputProcessors: ({ requestContext }) => {
864
+ const blockedWords = requestContext.get('blockedWords') ?? []
865
+ return [new ContentFilter(blockedWords)]
866
+ },
867
+ })
868
+ ```
869
+
870
+ ### Per-call overrides
871
+
872
+ `agent.generate()` and `agent.stream()` accept `inputProcessors`, `outputProcessors`, `errorProcessors`, and `maxProcessorRetries`. When any processor array is set on the call, it **replaces** the matching array configured on the agent for that request. Memory, workspace, skill, channel, and browser processors that Mastra adds automatically are always preserved and run around your array.
873
+
874
+ ```typescript
875
+ await agent.stream('Summarize this', {
876
+ outputProcessors: [new StreamFilter()],
877
+ maxProcessorRetries: 5,
878
+ })
879
+ ```
880
+
881
+ `maxProcessorRetries` passed on the call overrides the agent default. If neither is set, processor-requested retries are treated as aborts.
882
+
523
883
  ## Related
524
884
 
525
- - [Processors overview](https://mastra.ai/docs/agents/processors) - Conceptual guide to processors
526
- - [Guardrails](https://mastra.ai/docs/agents/guardrails) - Security and validation processors
527
- - [Memory Processors](https://mastra.ai/docs/memory/memory-processors) - Memory-specific processors
885
+ - [Processors overview](https://mastra.ai/docs/agents/processors): Conceptual guide to processors
886
+ - [Guardrails](https://mastra.ai/docs/agents/guardrails): Security and validation processors
887
+ - [Memory Processors](https://mastra.ai/docs/memory/memory-processors): Memory-specific processors
@@ -2,6 +2,15 @@
2
2
 
3
3
  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.
4
4
 
5
+ By default, when you attach only `SkillSearchProcessor` to an agent with a skill-enabled `Workspace`, the agent treats skills as on-demand:
6
+
7
+ - The default eager `SkillsProcessor` is not auto-added.
8
+ - `search_skills` and `load_skill` are exposed for discovery and instruction loading.
9
+ - Overlapping `skill` and `skill_search` tools are hidden.
10
+ - `skill_read` remains available so the agent can read supporting skill files such as references, scripts, and assets.
11
+
12
+ If you explicitly configure `SkillsProcessor` alongside `SkillSearchProcessor`, the agent preserves the eager `skill` and `skill_search` tools as an opt-in path.
13
+
5
14
  ## Usage example
6
15
 
7
16
  ```typescript
@@ -36,6 +45,8 @@ const skillSearch = new SkillSearchProcessor({
36
45
 
37
46
  **name** (`string`): Processor display name set to 'Skill Search Processor'
38
47
 
48
+ **providesSkillDiscovery** (`'on-demand'`): Signals to the agent that this processor owns skill discovery and instruction loading.
49
+
39
50
  **processInputStep** (`(args: ProcessInputStepArgs) => Promise<ProcessInputStepResult>`): Processes each step to inject search/load meta-tools and any previously loaded skill instructions as system messages.
40
51
 
41
52
  ## Extended usage example
@@ -47,7 +58,7 @@ import { Workspace, LocalFilesystem } from '@mastra/core/workspace'
47
58
 
48
59
  const workspace = new Workspace({
49
60
  filesystem: new LocalFilesystem({ basePath: './project' }),
50
- skills: ['/skills'],
61
+ skills: ['skills'],
51
62
  bm25: true,
52
63
  })
53
64
 
@@ -77,6 +88,14 @@ The agent workflow is:
77
88
  4. The skill's instructions appear as system messages on the next turn
78
89
  5. Agent follows the loaded skill's instructions
79
90
 
91
+ ## Workspace file tools
92
+
93
+ `SkillSearchProcessor` loads skill instructions into the conversation. It does not block workspace file tools from reading files.
94
+
95
+ Use `skill_read` for supporting files that belong to a loaded skill, such as files under `references/`, `scripts/`, or `assets/`.
96
+
97
+ Reserve workspace file tools such as `mastra_workspace_read_file` for explicit file inspection or editing workflows. During normal task execution, the agent does not need to read the same `SKILL.md` file after `load_skill` succeeds.
98
+
80
99
  ## Compared to SkillsProcessor
81
100
 
82
101
  | | SkillsProcessor | SkillSearchProcessor |