@mastra/mcp-docs-server 1.1.35-alpha.2 → 1.1.35-alpha.26

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 (121) hide show
  1. package/.docs/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +48 -4
  2. package/.docs/docs/agents/background-tasks.md +62 -2
  3. package/.docs/docs/agents/processors.md +35 -3
  4. package/.docs/docs/agents/response-caching.md +148 -0
  5. package/.docs/docs/agents/signals.md +151 -0
  6. package/.docs/docs/agents/using-tools.md +8 -0
  7. package/.docs/docs/browser/agent-browser.md +15 -0
  8. package/.docs/docs/browser/stagehand.md +25 -1
  9. package/.docs/docs/editor/tools.md +1 -1
  10. package/.docs/docs/index.md +2 -2
  11. package/.docs/docs/mastra-platform/configuration.md +1 -1
  12. package/.docs/docs/mastra-platform/overview.md +1 -1
  13. package/.docs/docs/memory/observational-memory.md +63 -14
  14. package/.docs/docs/memory/overview.md +2 -1
  15. package/.docs/docs/memory/semantic-recall.md +68 -6
  16. package/.docs/docs/observability/logging.md +2 -2
  17. package/.docs/docs/observability/metrics/overview.md +4 -4
  18. package/.docs/docs/observability/overview.md +6 -6
  19. package/.docs/docs/observability/tracing/bridges/otel.md +25 -0
  20. package/.docs/docs/observability/tracing/exporters/arize.md +5 -5
  21. package/.docs/docs/observability/tracing/exporters/braintrust.md +37 -0
  22. package/.docs/docs/observability/tracing/exporters/langfuse.md +21 -0
  23. package/.docs/docs/observability/tracing/exporters/{cloud.md → mastra-platform.md} +28 -26
  24. package/.docs/docs/observability/tracing/exporters/{default.md → mastra-storage.md} +56 -19
  25. package/.docs/docs/observability/tracing/exporters/otel.md +79 -2
  26. package/.docs/docs/observability/tracing/overview.md +30 -29
  27. package/.docs/docs/observability/tracing/processors/sensitive-data-filter.md +6 -6
  28. package/.docs/docs/server/mastra-server.md +30 -19
  29. package/.docs/docs/studio/observability.md +4 -4
  30. package/.docs/docs/studio/overview.md +4 -0
  31. package/.docs/docs/voice/overview.md +84 -0
  32. package/.docs/docs/workflows/suspend-and-resume.md +28 -1
  33. package/.docs/guides/deployment/inngest.md +29 -8
  34. package/.docs/guides/guide/web-search.md +7 -7
  35. package/.docs/guides/migrations/mastra-cloud.md +6 -6
  36. package/.docs/guides/migrations/upgrade-to-v1/tracing.md +19 -17
  37. package/.docs/models/gateways/azure-openai.md +94 -23
  38. package/.docs/models/gateways/netlify.md +3 -1
  39. package/.docs/models/gateways/openrouter.md +5 -1
  40. package/.docs/models/gateways/vercel.md +2 -1
  41. package/.docs/models/index.md +1 -1
  42. package/.docs/models/providers/chutes.md +23 -54
  43. package/.docs/models/providers/databricks.md +96 -0
  44. package/.docs/models/providers/deepinfra.md +2 -1
  45. package/.docs/models/providers/deepseek.md +3 -1
  46. package/.docs/models/providers/digitalocean.md +10 -2
  47. package/.docs/models/providers/firepass.md +71 -0
  48. package/.docs/models/providers/google.md +3 -2
  49. package/.docs/models/providers/kilo.md +5 -3
  50. package/.docs/models/providers/kiro.md +110 -0
  51. package/.docs/models/providers/llmgateway.md +8 -2
  52. package/.docs/models/providers/nebius.md +37 -55
  53. package/.docs/models/providers/novita-ai.md +5 -5
  54. package/.docs/models/providers/nvidia.md +59 -49
  55. package/.docs/models/providers/ollama-cloud.md +1 -1
  56. package/.docs/models/providers/openai.md +2 -0
  57. package/.docs/models/providers/opencode-go.md +2 -4
  58. package/.docs/models/providers/opencode.md +44 -43
  59. package/.docs/models/providers/poe.md +4 -1
  60. package/.docs/models/providers/qiniu-ai.md +2 -2
  61. package/.docs/models/providers/sarvam.md +72 -0
  62. package/.docs/models/providers/wafer.ai.md +2 -1
  63. package/.docs/models/providers/xiaomi-token-plan-ams.md +6 -5
  64. package/.docs/models/providers/xiaomi-token-plan-cn.md +6 -5
  65. package/.docs/models/providers/xiaomi-token-plan-sgp.md +6 -5
  66. package/.docs/models/providers/xiaomi.md +2 -2
  67. package/.docs/models/providers/zenmux.md +1 -1
  68. package/.docs/models/providers.md +3 -0
  69. package/.docs/reference/agents/agent.md +85 -0
  70. package/.docs/reference/browser/agent-browser.md +37 -11
  71. package/.docs/reference/browser/stagehand-browser.md +35 -9
  72. package/.docs/reference/cli/mastra.md +464 -0
  73. package/.docs/reference/client-js/agents.md +115 -1
  74. package/.docs/reference/client-js/responses.md +4 -0
  75. package/.docs/reference/configuration.md +6 -6
  76. package/.docs/reference/editor/tool-provider.md +3 -3
  77. package/.docs/reference/harness/harness-class.md +23 -8
  78. package/.docs/reference/index.md +6 -0
  79. package/.docs/reference/memory/observational-memory.md +11 -1
  80. package/.docs/reference/observability/metrics/automatic-metrics.md +2 -4
  81. package/.docs/reference/observability/tracing/bridges/datadog.md +2 -2
  82. package/.docs/reference/observability/tracing/bridges/otel.md +26 -4
  83. package/.docs/reference/observability/tracing/configuration.md +6 -3
  84. package/.docs/reference/observability/tracing/exporters/arize.md +1 -1
  85. package/.docs/reference/observability/tracing/exporters/braintrust.md +2 -0
  86. package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +3 -1
  87. package/.docs/reference/observability/tracing/exporters/console-exporter.md +2 -2
  88. package/.docs/reference/observability/tracing/exporters/default-exporter.md +7 -1
  89. package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +263 -0
  90. package/.docs/reference/observability/tracing/exporters/mastra-storage-exporter.md +194 -0
  91. package/.docs/reference/observability/tracing/exporters/otel.md +12 -8
  92. package/.docs/reference/observability/tracing/instances.md +2 -2
  93. package/.docs/reference/observability/tracing/interfaces.md +37 -2
  94. package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +22 -0
  95. package/.docs/reference/observability/tracing/span-filtering.md +2 -2
  96. package/.docs/reference/processors/prefill-error-handler.md +3 -3
  97. package/.docs/reference/processors/processor-interface.md +74 -12
  98. package/.docs/reference/processors/provider-history-compat.md +132 -0
  99. package/.docs/reference/processors/response-cache.md +114 -0
  100. package/.docs/reference/processors/tool-call-filter.md +28 -0
  101. package/.docs/reference/storage/clickhouse.md +8 -8
  102. package/.docs/reference/storage/cloudflare-d1.md +1 -1
  103. package/.docs/reference/storage/cloudflare.md +1 -1
  104. package/.docs/reference/storage/composite.md +1 -1
  105. package/.docs/reference/storage/convex.md +1 -1
  106. package/.docs/reference/storage/dsql.md +428 -0
  107. package/.docs/reference/storage/duckdb.md +3 -3
  108. package/.docs/reference/storage/dynamodb.md +1 -1
  109. package/.docs/reference/storage/lance.md +1 -1
  110. package/.docs/reference/storage/libsql.md +1 -1
  111. package/.docs/reference/storage/postgresql.md +1 -1
  112. package/.docs/reference/storage/upstash.md +1 -1
  113. package/.docs/reference/streaming/ChunkType.md +44 -0
  114. package/.docs/reference/streaming/agents/stream.md +18 -2
  115. package/.docs/reference/tools/brightdata.md +167 -0
  116. package/.docs/reference/tools/create-tool.md +46 -0
  117. package/.docs/reference/tools/mcp-client.md +47 -0
  118. package/.docs/reference/voice/inworld.md +133 -0
  119. package/.docs/reference/workflows/workflow-state-reader.md +113 -0
  120. package/CHANGELOG.md +92 -0
  121. package/package.json +4 -4
@@ -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 six processor methods run at different points in the agent execution lifecycle:
7
+ The seven processor methods run at different points in the agent execution lifecycle:
8
8
 
9
9
  ```text
10
10
  ┌─────────────────────────────────────────────────────────────────┐
@@ -26,6 +26,11 @@ The six processor methods run at different points in the agent execution lifecyc
26
26
  │ │ └──────────┬──────────┘ │ │
27
27
  │ │ │ │ │
28
28
  │ │ ▼ │ │
29
+ │ │ ┌─────────────────────┐ │ │
30
+ │ │ │ processLLMRequest │ ← Runs before provider call │ │
31
+ │ │ └──────────┬──────────┘ │ │
32
+ │ │ │ │ │
33
+ │ │ ▼ │ │
29
34
  │ │ LLM Execution ──── API Error? ──┐ │ │
30
35
  │ │ │ │ │ │
31
36
  │ │ │ ┌───────────────────┐ │ │
@@ -59,14 +64,15 @@ The six processor methods run at different points in the agent execution lifecyc
59
64
  └─────────────────────────────────────────────────────────────────┘
60
65
  ```
61
66
 
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 |
67
+ | Method | When it runs | Use case |
68
+ | --------------------- | ------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
69
+ | `processInput` | Once at the start, before the agentic loop | Validate/transform initial user input, add context |
70
+ | `processInputStep` | At each step of the agentic loop, before each LLM call | Transform messages between steps, handle tool results |
71
+ | `processLLMRequest` | After LLM request conversion, before the provider call | Rewrite the outbound `LanguageModelV2Prompt` for the current call without persisting changes |
72
+ | `processAPIError` | When an LLM API call fails | Inspect API rejections, optionally mutate state/messages, and request a retry |
73
+ | `processOutputStream` | On each streaming chunk during LLM response | Filter/modify streaming content, detect patterns in real-time |
74
+ | `processOutputStep` | After each LLM response, before tool execution | Validate output quality, implement guardrails with retry |
75
+ | `processOutputResult` | Once after generation completes | Post-process final response, log results |
70
76
 
71
77
  ## Interface definition
72
78
 
@@ -97,6 +103,10 @@ interface Processor<TId extends string = string, TTripwireMetadata = unknown> {
97
103
  | void
98
104
  | undefined
99
105
 
106
+ processLLMRequest?(
107
+ args: ProcessLLMRequestArgs<TTripwireMetadata>,
108
+ ): Promise<ProcessLLMRequestResult> | ProcessLLMRequestResult
109
+
100
110
  processAPIError?(
101
111
  args: ProcessAPIErrorArgs<TTripwireMetadata>,
102
112
  ): Promise<ProcessAPIErrorResult | void> | ProcessAPIErrorResult | void
@@ -243,9 +253,10 @@ processInputStep?<TTripwireMetadata = unknown>(
243
253
  1. `processInput` (once at start)
244
254
  2. `processInputStep` from inputProcessors (at each step, before LLM call)
245
255
  3. `prepareStep` callback (runs as part of the processInputStep pipeline, after inputProcessors)
246
- 4. LLM execution
247
- 5. Tool execution (if needed)
248
- 6. Repeat from step 2 if tools were called
256
+ 4. `processLLMRequest` from inputProcessors (after prompt conversion, before the provider call)
257
+ 5. LLM execution
258
+ 6. Tool execution (if needed)
259
+ 7. Repeat from step 2 if tools were called
249
260
 
250
261
  #### `ProcessInputStepArgs`
251
262
 
@@ -339,6 +350,57 @@ System messages are **reset to their original values** at the start of each step
339
350
 
340
351
  ***
341
352
 
353
+ ### `processLLMRequest`
354
+
355
+ Processes the final LLM request after Mastra converts the `MessageList` into `LanguageModelV2Prompt` and before the provider call. Use this method for transient, model-aware rewrites that should affect only the current outbound request.
356
+
357
+ Returned prompt changes are forwarded to the model for the current call only. They are not persisted back to `MessageList`, memory, UI history, or later provider calls.
358
+
359
+ ```typescript
360
+ processLLMRequest?(
361
+ args: ProcessLLMRequestArgs,
362
+ ): Promise<ProcessLLMRequestResult> | ProcessLLMRequestResult;
363
+ ```
364
+
365
+ #### `ProcessLLMRequestArgs`
366
+
367
+ **prompt** (`LanguageModelV2Prompt`): The LLM request prompt that will be sent to the provider for this call.
368
+
369
+ **model** (`MastraLanguageModel`): The resolved model that will receive the prompt. Use this to scope provider-specific rewrites.
370
+
371
+ **stepNumber** (`number`): Current step number (0-indexed). Step 0 is the initial LLM call.
372
+
373
+ **steps** (`StepResult[]`): Results from previous steps, including text, toolCalls, and toolResults.
374
+
375
+ **state** (`Record<string, unknown>`): Per-processor state that persists across all method calls within this request.
376
+
377
+ **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.
378
+
379
+ **retryCount** (`number`): Current retry attempt count from \`ProcessorContext\`. Starts at \`0\`; use to cap processor-triggered retries.
380
+
381
+ **requestContext** (`RequestContext`): Request-scoped context with execution metadata.
382
+
383
+ **tracingContext** (`TracingContext`): Tracing context for observability.
384
+
385
+ **writer** (`ProcessorStreamWriter`): Stream writer for emitting custom data chunks during streaming. Use \`writer.custom()\` to send transient UI signals.
386
+
387
+ **abortSignal** (`AbortSignal`): Signal for cancelling the operation.
388
+
389
+ #### Return value
390
+
391
+ `processLLMRequest` returns `ProcessLLMRequestResult`, which is `{ prompt?: LanguageModelV2Prompt } | undefined | void`.
392
+
393
+ - Return `{ prompt }` to replace the outbound prompt for the current provider call.
394
+ - Return `undefined` or `void` to forward the original prompt unchanged.
395
+
396
+ #### Use cases
397
+
398
+ - Removing or reshaping provider-specific prompt parts before a model call
399
+ - Normalizing roles or content to match a provider's input requirements
400
+ - Adapting tool result formats when switching providers mid-loop
401
+
402
+ ***
403
+
342
404
  ### `processAPIError`
343
405
 
344
406
  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.
@@ -0,0 +1,132 @@
1
+ # ProviderHistoryCompat
2
+
3
+ The `ProviderHistoryCompat` processor handles provider-specific history incompatibilities. It can rewrite the outbound language model prompt before a provider call, or react to API errors and retry with repaired message history.
4
+
5
+ Use it when an agent may switch between model providers, reuse message history across providers, or call a provider that rejects fields emitted by another provider.
6
+
7
+ ## Usage example
8
+
9
+ Add `ProviderHistoryCompat` to `inputProcessors` when you want all built-in compatibility rules available for an agent:
10
+
11
+ ```typescript
12
+ import { Agent } from '@mastra/core/agent'
13
+ import { ProviderHistoryCompat } from '@mastra/core/processors'
14
+
15
+ export const agent = new Agent({
16
+ name: 'my-agent',
17
+ instructions: 'You are a helpful assistant.',
18
+ model: 'anthropic/claude-sonnet-4-5',
19
+ inputProcessors: [new ProviderHistoryCompat()],
20
+ })
21
+ ```
22
+
23
+ Mastra agents don't add this processor automatically. Add it explicitly when you need provider history compatibility rules, reactive API error recovery, custom rules, or predictable processor ordering.
24
+
25
+ ## Constructor parameters
26
+
27
+ **opts** (`{ additionalRules?: CompatRule[] }`): Configuration options for provider history compatibility rules.
28
+
29
+ **opts.additionalRules** (`CompatRule[]`): Custom compatibility rules to run after the built-in rules. Rules can rewrite the outbound prompt or repair persisted messages after matching an API error.
30
+
31
+ ## Properties
32
+
33
+ **id** (`'provider-history-compat'`): Processor identifier.
34
+
35
+ **name** (`'Provider History Compat'`): Processor display name.
36
+
37
+ **processLLMRequest** (`(args: ProcessLLMRequestArgs) => ProcessLLMRequestResult`): Runs preemptive compatibility rules against the converted LanguageModelV2Prompt immediately before the provider call. Returned prompt changes are transient and are not persisted to memory or message history.
38
+
39
+ **processAPIError** (`(args: ProcessAPIErrorArgs) => Promise<ProcessAPIErrorResult | void>`): Runs reactive compatibility rules when a provider rejects the request. Matching rules can mutate the message list and return retry: true on the first retry attempt.
40
+
41
+ ## Built-in rules
42
+
43
+ `ProviderHistoryCompat` includes these built-in compatibility rules:
44
+
45
+ | Rule | Provider | Timing | Behavior |
46
+ | ------------------------------------------- | --------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
47
+ | `anthropic-tool-id-format` | Anthropic | Reactive API error recovery | Rewrites tool call IDs that contain characters outside `[a-zA-Z0-9_-]` and retries the request. |
48
+ | `cerebras-strip-reasoning-content` | Cerebras | Preemptive prompt rewrite | Removes assistant `reasoning` parts from the outbound prompt so they're not serialized as unsupported `reasoning_content` fields. |
49
+ | `anthropic-strip-foreign-reasoning-content` | Anthropic | Preemptive prompt rewrite | Removes non-Anthropic assistant `reasoning` parts from the outbound prompt. Anthropic-native thinking history is preserved. |
50
+
51
+ Preemptive rules run through `processLLMRequest` after Mastra converts messages to the model prompt format and before the prompt is sent to the provider. These rewrites affect only the current provider call.
52
+
53
+ Reactive rules run through `processAPIError` after a provider rejection. They can update the persisted `messageList` and request a retry.
54
+
55
+ ## `CompatRule`
56
+
57
+ A `CompatRule` defines one provider history compatibility fix:
58
+
59
+ ```typescript
60
+ import type { CompatRule } from '@mastra/core/processors'
61
+
62
+ const removeUnsupportedPromptParts: CompatRule = {
63
+ name: 'remove-unsupported-prompt-parts',
64
+ applyToPrompt({ prompt, model }) {
65
+ // Return a modified LanguageModelV2Prompt, or undefined to leave it unchanged.
66
+ return undefined
67
+ },
68
+ }
69
+ ```
70
+
71
+ **name** (`string`): Human-readable rule identifier for logs and debugging.
72
+
73
+ **errorPatterns** (`RegExp[]`): Patterns matched against provider API error messages and response bodies. Required for reactive rules that implement fix.
74
+
75
+ **fix** (`(messages: MastraDBMessage[]) => boolean`): Reactive fix that mutates persisted database messages after a matching API error. Return true when the rule changed messages and the request should retry.
76
+
77
+ **applyToPrompt** (`(args: { prompt: LanguageModelV2Prompt; model: unknown }) => LanguageModelV2Prompt | undefined`): Preemptive fix that rewrites the outbound prompt for the current provider call. Return undefined when no prompt change is needed.
78
+
79
+ ## Custom rules
80
+
81
+ Pass custom rules through `additionalRules`. Custom rules run after the built-in rules:
82
+
83
+ ```typescript
84
+ import { Agent } from '@mastra/core/agent'
85
+ import { ProviderHistoryCompat, type CompatRule } from '@mastra/core/processors'
86
+
87
+ const stripUnsupportedAssistantMetadata: CompatRule = {
88
+ name: 'strip-unsupported-assistant-metadata',
89
+ applyToPrompt({ prompt, model }) {
90
+ if (typeof model !== 'string' || !model.startsWith('example-provider/')) {
91
+ return undefined
92
+ }
93
+
94
+ let changed = false
95
+ const nextPrompt = prompt.map(message => {
96
+ if (message.role !== 'assistant' || typeof message.content === 'string') {
97
+ return message
98
+ }
99
+
100
+ const nextContent = message.content.map(part => {
101
+ if (!('providerOptions' in part)) return part
102
+ changed = true
103
+ const { providerOptions: _providerOptions, ...rest } = part
104
+ return rest
105
+ })
106
+
107
+ return { ...message, content: nextContent }
108
+ })
109
+
110
+ return changed ? nextPrompt : undefined
111
+ },
112
+ }
113
+
114
+ export const agent = new Agent({
115
+ name: 'custom-provider-agent',
116
+ instructions: 'You are a helpful assistant.',
117
+ model: 'example-provider/model',
118
+ inputProcessors: [
119
+ new ProviderHistoryCompat({
120
+ additionalRules: [stripUnsupportedAssistantMetadata],
121
+ }),
122
+ ],
123
+ })
124
+ ```
125
+
126
+ Use `applyToPrompt` for provider-specific rewrites that shouldn't be saved to memory. Use `fix` with `errorPatterns` when the provider rejects persisted message history and the repaired history should be reused on future turns.
127
+
128
+ ## Related
129
+
130
+ - [Processor interface](https://mastra.ai/reference/processors/processor-interface)
131
+ - [Processors](https://mastra.ai/docs/agents/processors)
132
+ - [PrefillErrorHandler](https://mastra.ai/reference/processors/prefill-error-handler)
@@ -0,0 +1,114 @@
1
+ # ResponseCache
2
+
3
+ `ResponseCache` is an input processor that caches LLM responses on the request/response boundary inside the agentic loop. It hooks into `processLLMRequest` (cache lookup; short-circuits on hit) and `processLLMResponse` (cache write on completion).
4
+
5
+ The cache key is derived from the resolved `LanguageModelV2Prompt` Mastra is about to send to the model — i.e. _after_ memory has loaded and earlier input processors have transformed the prompt — so two users with different memory contexts produce different cache keys. Each step in an agentic tool loop is independently cached.
6
+
7
+ There is no agent-level option for response caching; register `ResponseCache` explicitly on `inputProcessors`. Per-call overrides flow through `RequestContext` via [`ResponseCache.context()`](#static-helpers) and [`ResponseCache.applyContext()`](#static-helpers).
8
+
9
+ ## Usage example
10
+
11
+ ```typescript
12
+ import { Agent } from '@mastra/core/agent'
13
+ import { InMemoryServerCache } from '@mastra/core/cache'
14
+ import { ResponseCache } from '@mastra/core/processors'
15
+
16
+ const cache = new InMemoryServerCache()
17
+
18
+ const agent = new Agent({
19
+ name: 'Search Agent',
20
+ instructions: 'You answer questions concisely.',
21
+ model: 'openai/gpt-5',
22
+ inputProcessors: [new ResponseCache({ cache, ttl: 600 })],
23
+ })
24
+
25
+ // First call hits the LLM and writes to the cache.
26
+ await agent.generate('What is the capital of France?')
27
+
28
+ // Second identical call replays the cached response.
29
+ await agent.generate('What is the capital of France?')
30
+
31
+ // Force a fresh call but still update the cache.
32
+ await agent.generate('What is the capital of France?', {
33
+ requestContext: ResponseCache.context({ bust: true }),
34
+ })
35
+ ```
36
+
37
+ See [Response caching](https://mastra.ai/docs/agents/response-caching) for the conceptual overview, scoping rules, and recommended deployment patterns.
38
+
39
+ ## Constructor parameters
40
+
41
+ **cache** (`MastraServerCache`): The cache backend. Required. Pass any \`MastraServerCache\` implementation — \`InMemoryServerCache\` for local development, \`RedisCache\` from \`@mastra/redis\` for production, or your own subclass for a custom backend.
42
+
43
+ **ttl** (`number`): Time-to-live (seconds) for entries written by this processor. Defaults to 300 seconds (5 minutes), matching OpenRouter's reference implementation. (Default: `300`)
44
+
45
+ **scope** (`string | null`): Tenant scope appended to the cache key. \`null\` opts out of scoping. When omitted, the processor falls back to the resource id resolved from the request context (\`MASTRA\_RESOURCE\_ID\_KEY\`) for automatic per-user isolation.
46
+
47
+ **key** (`string | (inputs: ResponseCacheKeyInputs) => string | Promise<string>`): Override the auto-derived cache key. Pass a string to pin a key, or a function that receives \`{ agentId, scope, model, prompt, stepNumber }\` and returns a key. If the function throws, the processor falls back to the deterministic hash so the call still benefits from caching.
48
+
49
+ **bust** (`boolean`): Force a cache miss on every call: skip the read but still write on completion. Useful for explicit refresh paths. (Default: `false`)
50
+
51
+ **agentId** (`string`): Logical id used in the cache key namespace. Defaults to \`'mastra-response-cache'\`. Set this to the owning agent's id when you want cache entries scoped per-agent. (Default: `'mastra-response-cache'`)
52
+
53
+ ## Static helpers
54
+
55
+ `ResponseCache` exposes two static helpers for setting per-call overrides on a `RequestContext`. The helpers keep the underlying context key a private implementation detail — prefer them over reading/writing the raw key.
56
+
57
+ ### `ResponseCache.context(options)`
58
+
59
+ Build a fresh `RequestContext` preloaded with per-call response cache overrides.
60
+
61
+ ```typescript
62
+ await agent.stream('hello', {
63
+ requestContext: ResponseCache.context({ key: 'custom', bust: true }),
64
+ })
65
+ ```
66
+
67
+ ### `ResponseCache.applyContext(requestContext, options)`
68
+
69
+ Merge per-call response cache overrides into an existing `RequestContext`. Returns the same context for chaining.
70
+
71
+ ```typescript
72
+ const ctx = new RequestContext()
73
+ ctx.set('caller-meta', { userId: 'u-123' })
74
+ ResponseCache.applyContext(ctx, { bust: true })
75
+ await agent.stream('hello', { requestContext: ctx })
76
+ ```
77
+
78
+ ## ResponseCacheContextOptions
79
+
80
+ The shape passed to `ResponseCache.context()` / `ResponseCache.applyContext()`.
81
+
82
+ **key** (`string | (inputs: ResponseCacheKeyInputs) => string | Promise<string>`): Overrides the auto-derived cache key for this request only.
83
+
84
+ **scope** (`string | null`): Overrides the tenant scope for this request only. \`null\` opts out of scoping.
85
+
86
+ **bust** (`boolean`): Skip the cache read but still write on completion.
87
+
88
+ `cache`, `ttl`, and `agentId` are intentionally not overridable per call — they are instance-level concerns that should not vary per request.
89
+
90
+ ## ResponseCacheKeyInputs
91
+
92
+ The argument passed to a `key` function (constructor or per-call). All fields contribute to the deterministic hash by default.
93
+
94
+ **agentId** (`string`): Logical processor id used to namespace the cache key.
95
+
96
+ **scope** (`string | null | undefined`): Resolved scope for this request, or \`null\` when scoping is disabled.
97
+
98
+ **model** (`{ provider?: string; modelId?: string; specVersion?: string }`): Provider/model identity. Different models produce different responses.
99
+
100
+ **prompt** (`LanguageModelV2Prompt`): The exact prompt the provider would receive, post memory load and post any prompt-modifying input processors.
101
+
102
+ **stepNumber** (`number`): 0-indexed step number within the agentic loop. Greater than zero for tool steps.
103
+
104
+ ## Helper exports
105
+
106
+ - `buildResponseCacheKey(inputs)` — the deterministic hash used by default. Re-export it to override individual fields while preserving the rest of the standard key shape.
107
+ - `DEFAULT_RESPONSE_CACHE_TTL_SECONDS` — the default `ttl` (`300`).
108
+ - `RESPONSE_CACHE_CONTEXT_KEY` — the `RequestContext` key the static helpers write to. Exposed for advanced cases (e.g. clearing the override mid-pipeline); prefer the helpers.
109
+
110
+ ## Related
111
+
112
+ - [Response caching](https://mastra.ai/docs/agents/response-caching)
113
+ - [Processors](https://mastra.ai/docs/agents/processors)
114
+ - [Processor interface](https://mastra.ai/reference/processors/processor-interface)
@@ -19,6 +19,11 @@ const filterSpecific = new ToolCallFilter({
19
19
  const filterAfterRecentTools = new ToolCallFilter({
20
20
  filterAfterToolSteps: 2,
21
21
  })
22
+
23
+ // Preserve compact model-facing output for filtered completed tool results
24
+ const filterWithCompactToolHistory = new ToolCallFilter({
25
+ preserveModelOutput: true,
26
+ })
22
27
  ```
23
28
 
24
29
  ## Constructor parameters
@@ -29,6 +34,8 @@ const filterAfterRecentTools = new ToolCallFilter({
29
34
 
30
35
  **options.filterAfterToolSteps** (`number`): Enables filtering during agent loops and preserves tool calls and results from this many recent tool-producing steps. If undefined, step filtering is disabled
31
36
 
37
+ **options.preserveModelOutput** (`boolean`): Preserves compact model-facing output from completed filtered tool results with providerMetadata.mastra.modelOutput. Raw tool args and raw results are removed
38
+
32
39
  ## Returns
33
40
 
34
41
  **id** (`string`): Processor identifier set to 'tool-call-filter'
@@ -53,6 +60,27 @@ const filter = new ToolCallFilter({
53
60
  })
54
61
  ```
55
62
 
63
+ ## Preserve compact model output
64
+
65
+ Set `preserveModelOutput: true` to retain compact `toModelOutput` history for completed tool results that the filter removes. This keeps the model-facing output as text in the prompt while removing the raw `toolInvocation.args` and raw `toolInvocation.result` payloads.
66
+
67
+ Only completed tool results with `providerMetadata.mastra.modelOutput` are preserved. Tool calls, incomplete results, and results without stored model output are still filtered.
68
+
69
+ ```typescript
70
+ const filter = new ToolCallFilter({
71
+ preserveModelOutput: true,
72
+ })
73
+ ```
74
+
75
+ Combine `preserveModelOutput` with `exclude` to preserve compact output only for filtered tools:
76
+
77
+ ```typescript
78
+ const filter = new ToolCallFilter({
79
+ exclude: ['searchDatabase'],
80
+ preserveModelOutput: true,
81
+ })
82
+ ```
83
+
56
84
  ## Extended usage example
57
85
 
58
86
  ```typescript
@@ -51,7 +51,7 @@ import { Mastra } from '@mastra/core'
51
51
  import { MastraCompositeStore } from '@mastra/core/storage'
52
52
  import { PostgresStore } from '@mastra/pg'
53
53
  import { ObservabilityStorageClickhouseVNext } from '@mastra/clickhouse'
54
- import { Observability, DefaultExporter } from '@mastra/observability'
54
+ import { Observability, MastraStorageExporter } from '@mastra/observability'
55
55
 
56
56
  const observabilityStore = new ObservabilityStorageClickhouseVNext({
57
57
  url: process.env.CLICKHOUSE_URL!,
@@ -74,14 +74,14 @@ export const mastra = new Mastra({
74
74
  configs: {
75
75
  default: {
76
76
  serviceName: 'mastra',
77
- exporters: [new DefaultExporter()],
77
+ exporters: [new MastraStorageExporter()],
78
78
  },
79
79
  },
80
80
  }),
81
81
  })
82
82
  ```
83
83
 
84
- `DefaultExporter` automatically selects the `insert-only` strategy when ClickHouse is the observability backend, which gives the highest write throughput. See [tracing strategies](https://mastra.ai/docs/observability/tracing/exporters/default) for details.
84
+ `MastraStorageExporter` automatically selects the `insert-only` strategy when ClickHouse is the observability backend, which gives the highest write throughput. See [tracing strategies](https://mastra.ai/docs/observability/tracing/exporters/mastra-storage) for details.
85
85
 
86
86
  ### Observability with the legacy domain
87
87
 
@@ -226,7 +226,7 @@ import { Mastra } from '@mastra/core'
226
226
  import { MastraCompositeStore } from '@mastra/core/storage'
227
227
  import { PostgresStore } from '@mastra/pg'
228
228
  import { ObservabilityStorageClickhouseVNext } from '@mastra/clickhouse'
229
- import { Observability, DefaultExporter } from '@mastra/observability'
229
+ import { Observability, MastraStorageExporter } from '@mastra/observability'
230
230
 
231
231
  export const mastra = new Mastra({
232
232
  storage: new MastraCompositeStore({
@@ -247,7 +247,7 @@ export const mastra = new Mastra({
247
247
  configs: {
248
248
  default: {
249
249
  serviceName: 'mastra',
250
- exporters: [new DefaultExporter()],
250
+ exporters: [new MastraStorageExporter()],
251
251
  },
252
252
  },
253
253
  }),
@@ -287,14 +287,14 @@ In CI/CD pipelines, set `disableInit: true` on `ClickhouseStore` and run `init()
287
287
 
288
288
  ClickHouse is the recommended backend for production observability:
289
289
 
290
- - **Insert-only strategy**: `DefaultExporter` writes completed spans in batches without per-span updates, which is the highest-throughput strategy available.
290
+ - **Insert-only strategy**: `MastraStorageExporter` writes completed spans in batches without per-span updates, which is the highest-throughput strategy available.
291
291
  - **Columnar compression**: Span attributes and log payloads compress well compared to the same data in row-oriented databases.
292
292
 
293
- For the full strategy matrix and production guidance, see the [`DefaultExporter` reference](https://mastra.ai/docs/observability/tracing/exporters/default).
293
+ For the full strategy matrix and production guidance, see the [`MastraStorageExporter` reference](https://mastra.ai/docs/observability/tracing/exporters/mastra-storage).
294
294
 
295
295
  ## Related
296
296
 
297
297
  - [Storage overview](https://mastra.ai/reference/storage/overview)
298
298
  - [Composite storage](https://mastra.ai/reference/storage/composite)
299
- - [`DefaultExporter`](https://mastra.ai/docs/observability/tracing/exporters/default)
299
+ - [`MastraStorageExporter`](https://mastra.ai/docs/observability/tracing/exporters/mastra-storage)
300
300
  - [Observability overview](https://mastra.ai/docs/observability/overview)
@@ -2,7 +2,7 @@
2
2
 
3
3
  The Cloudflare D1 storage implementation provides a serverless SQL database solution using Cloudflare D1, supporting relational operations and transactional consistency.
4
4
 
5
- > **Observability Not Supported:** Cloudflare D1 storage **doesn't support the observability domain**. Traces from the `DefaultExporter` can't be persisted to D1, and [Studio's](https://mastra.ai/docs/studio/overview) observability features won't work with D1 as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider like ClickHouse or PostgreSQL.
5
+ > **Observability Not Supported:** Cloudflare D1 storage **doesn't support the observability domain**. Traces from the `MastraStorageExporter` can't be persisted to D1, and [Studio's](https://mastra.ai/docs/studio/overview) observability features won't work with D1 as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider like ClickHouse.
6
6
 
7
7
  > **Row Size Limit:** Cloudflare D1 enforces a **1 MiB maximum row size**. This limit can be exceeded when storing messages with base64-encoded attachments such as images. See [Handling large attachments](https://mastra.ai/docs/memory/storage) for workarounds including uploading attachments to external storage.
8
8
 
@@ -5,7 +5,7 @@ Mastra provides two Cloudflare storage implementations:
5
5
  - **Cloudflare KV** (`CloudflareKVStorage`): A globally distributed, eventually consistent key-value store
6
6
  - **Cloudflare Durable Objects** (`CloudflareDOStorage`): A strongly consistent, SQLite-based storage using Durable Objects
7
7
 
8
- > **Observability Not Supported:** Cloudflare storage **doesn't support the observability domain**. Traces from the `DefaultExporter` can't be persisted, and [Studio's](https://mastra.ai/docs/studio/overview) observability features won't work with Cloudflare as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider like ClickHouse or PostgreSQL.
8
+ > **Observability Not Supported:** Cloudflare storage **doesn't support the observability domain**. Traces from the `MastraStorageExporter` can't be persisted, and [Studio's](https://mastra.ai/docs/studio/overview) observability features won't work with Cloudflare as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider like ClickHouse.
9
9
 
10
10
  ## Installation
11
11
 
@@ -242,4 +242,4 @@ const storage = new MastraCompositeStore({
242
242
 
243
243
  > **Note:** `ObservabilityStorageClickhouseVNext` is the current observability domain implementation. The legacy `ObservabilityStorageClickhouse` class is also exported and remains supported for projects that have not migrated. See the [ClickHouse storage reference](https://mastra.ai/reference/storage/clickhouse) for details.
244
244
 
245
- > **Info:** This approach is also required when using storage providers that don't support observability (like Convex, DynamoDB, or Cloudflare). See the [DefaultExporter documentation](https://mastra.ai/docs/observability/tracing/exporters/default) for the full list of supported providers.
245
+ > **Info:** This approach is also required when using storage providers that don't support observability (like Convex, DynamoDB, or Cloudflare). See the [MastraStorageExporter documentation](https://mastra.ai/docs/observability/tracing/exporters/mastra-storage) for the full list of supported providers.
@@ -2,7 +2,7 @@
2
2
 
3
3
  The Convex storage implementation provides a serverless storage solution using [Convex](https://convex.dev), a full-stack TypeScript development platform with real-time sync and automatic caching.
4
4
 
5
- > **Observability Not Supported:** Convex storage **doesn't support the observability domain**. Traces from the `DefaultExporter` can't be persisted to Convex, and [Studio's](https://mastra.ai/docs/studio/overview) observability features won't work with Convex as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider like ClickHouse or PostgreSQL.
5
+ > **Observability Not Supported:** Convex storage **doesn't support the observability domain**. Traces from the `MastraStorageExporter` can't be persisted to Convex, and [Studio's](https://mastra.ai/docs/studio/overview) observability features won't work with Convex as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider like ClickHouse.
6
6
 
7
7
  > **Record Size Limit:** Convex enforces a **1 MiB maximum record size**. This limit can be exceeded when storing messages with base64-encoded attachments such as images. See [Handling large attachments](https://mastra.ai/docs/memory/storage) for workarounds including uploading attachments to external storage like S3, Cloudflare R2, or [Convex file storage](https://docs.convex.dev/file-storage).
8
8