@mastra/mcp-docs-server 1.1.41-alpha.0 → 1.1.42-alpha.10

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 (180) hide show
  1. package/.docs/docs/agent-builder/access-control.md +97 -0
  2. package/.docs/docs/agent-builder/browser.md +61 -0
  3. package/.docs/docs/agent-builder/channels.md +76 -0
  4. package/.docs/docs/agent-builder/configuration.md +147 -0
  5. package/.docs/docs/agent-builder/deploying.md +121 -0
  6. package/.docs/docs/agent-builder/memory.md +65 -0
  7. package/.docs/docs/agent-builder/model-policy.md +48 -0
  8. package/.docs/docs/agent-builder/overview.md +97 -0
  9. package/.docs/docs/agent-builder/skill-registries.md +31 -0
  10. package/.docs/docs/agent-builder/workspace.md +60 -0
  11. package/.docs/docs/agents/a2a.md +1 -1
  12. package/.docs/docs/agents/acp.md +4 -4
  13. package/.docs/docs/agents/adding-voice.md +37 -6
  14. package/.docs/docs/agents/agent-approval.md +15 -1
  15. package/.docs/docs/agents/background-tasks.md +2 -2
  16. package/.docs/docs/agents/channels.md +3 -1
  17. package/.docs/docs/agents/code-mode.md +163 -0
  18. package/.docs/docs/agents/guardrails.md +2 -2
  19. package/.docs/docs/agents/networks.md +1 -1
  20. package/.docs/docs/agents/overview.md +1 -1
  21. package/.docs/docs/agents/processors.md +3 -3
  22. package/.docs/docs/agents/response-caching.md +1 -1
  23. package/.docs/docs/agents/sdk-agents.md +261 -0
  24. package/.docs/docs/agents/signals.md +150 -73
  25. package/.docs/docs/agents/structured-output.md +5 -5
  26. package/.docs/docs/agents/supervisor-agents.md +2 -2
  27. package/.docs/docs/agents/using-tools.md +5 -5
  28. package/.docs/docs/browser/agent-browser.md +1 -1
  29. package/.docs/docs/browser/browser-viewer.md +1 -1
  30. package/.docs/docs/browser/overview.md +1 -1
  31. package/.docs/docs/browser/stagehand.md +5 -5
  32. package/.docs/docs/editor/overview.md +70 -8
  33. package/.docs/docs/evals/custom-scorers.md +1 -1
  34. package/.docs/docs/evals/datasets/running-experiments.md +1 -1
  35. package/.docs/docs/evals/overview.md +2 -2
  36. package/.docs/docs/getting-started/manual-install.md +1 -1
  37. package/.docs/docs/mcp/mcp-apps.md +3 -3
  38. package/.docs/docs/mcp/overview.md +1 -1
  39. package/.docs/docs/memory/memory-processors.md +6 -6
  40. package/.docs/docs/memory/multi-user-threads.md +1 -1
  41. package/.docs/docs/memory/observational-memory.md +19 -0
  42. package/.docs/docs/memory/semantic-recall.md +2 -2
  43. package/.docs/docs/memory/storage.md +2 -1
  44. package/.docs/docs/memory/working-memory.md +1 -1
  45. package/.docs/docs/observability/metrics/overview.md +1 -0
  46. package/.docs/docs/observability/metrics/querying.md +292 -0
  47. package/.docs/docs/observability/tracing/exporters/langfuse.md +1 -1
  48. package/.docs/docs/observability/tracing/exporters/langsmith.md +2 -2
  49. package/.docs/docs/rag/graph-rag.md +2 -2
  50. package/.docs/docs/rag/retrieval.md +12 -12
  51. package/.docs/docs/server/auth/fga.md +4 -0
  52. package/.docs/docs/server/mastra-client.md +1 -1
  53. package/.docs/docs/server/request-context.md +3 -3
  54. package/.docs/docs/streaming/overview.md +1 -1
  55. package/.docs/docs/streaming/tool-streaming.md +1 -1
  56. package/.docs/docs/voice/overview.md +86 -24
  57. package/.docs/docs/voice/speech-to-speech.md +55 -4
  58. package/.docs/docs/voice/speech-to-text.md +1 -1
  59. package/.docs/docs/voice/text-to-speech.md +1 -1
  60. package/.docs/docs/workspace/filesystem.md +2 -2
  61. package/.docs/docs/workspace/overview.md +1 -1
  62. package/.docs/docs/workspace/sandbox.md +5 -3
  63. package/.docs/guides/build-your-ui/ai-sdk-ui.md +1 -1
  64. package/.docs/guides/deployment/inngest.md +69 -0
  65. package/.docs/guides/guide/ai-recruiter.md +1 -1
  66. package/.docs/guides/guide/chef-michel.md +1 -1
  67. package/.docs/guides/guide/code-review-bot.md +1 -1
  68. package/.docs/guides/guide/dev-assistant.md +1 -1
  69. package/.docs/guides/guide/docs-manager.md +1 -1
  70. package/.docs/guides/guide/firecrawl.md +6 -6
  71. package/.docs/guides/guide/github-actions-pr-description.md +1 -1
  72. package/.docs/guides/guide/research-assistant.md +1 -1
  73. package/.docs/guides/guide/research-coordinator.md +2 -2
  74. package/.docs/guides/guide/slack-assistant.md +1 -1
  75. package/.docs/guides/guide/stock-agent.md +2 -2
  76. package/.docs/guides/guide/whatsapp-chat-bot.md +2 -2
  77. package/.docs/guides/migrations/agentnetwork.md +4 -4
  78. package/.docs/guides/migrations/upgrade-to-v1/agent.md +1 -1
  79. package/.docs/guides/migrations/vnext-to-standard-apis.md +2 -2
  80. package/.docs/models/embeddings.md +2 -2
  81. package/.docs/reference/agents/agent.md +60 -21
  82. package/.docs/reference/agents/channels.md +48 -6
  83. package/.docs/reference/agents/generateLegacy.md +1 -1
  84. package/.docs/reference/agents/getLLM.md +2 -2
  85. package/.docs/reference/agents/getMetadata.md +2 -2
  86. package/.docs/reference/agents/network.md +1 -1
  87. package/.docs/reference/browser/agent-browser.md +1 -1
  88. package/.docs/reference/browser/browser-viewer.md +1 -1
  89. package/.docs/reference/browser/mastra-browser.md +1 -1
  90. package/.docs/reference/browser/stagehand-browser.md +5 -5
  91. package/.docs/reference/client-js/agent-builder.md +161 -0
  92. package/.docs/reference/client-js/agents.md +19 -2
  93. package/.docs/reference/client-js/mastra-client.md +4 -0
  94. package/.docs/reference/configuration.md +1 -1
  95. package/.docs/reference/editor/agent-builder/agent-builder-options.md +74 -0
  96. package/.docs/reference/editor/agent-builder/builder-agent-defaults.md +77 -0
  97. package/.docs/reference/editor/agent-builder/builder-models.md +64 -0
  98. package/.docs/reference/editor/blob-store-provider.md +59 -0
  99. package/.docs/reference/editor/browser-provider.md +75 -0
  100. package/.docs/reference/editor/filesystem-provider.md +62 -0
  101. package/.docs/reference/editor/mastra-editor.md +61 -1
  102. package/.docs/reference/editor/processor-provider.md +64 -0
  103. package/.docs/reference/editor/sandbox-provider.md +61 -0
  104. package/.docs/reference/editor/storage-browser-ref.md +80 -0
  105. package/.docs/reference/editor/storage-workspace-ref.md +93 -0
  106. package/.docs/reference/evals/answer-relevancy.md +1 -1
  107. package/.docs/reference/evals/answer-similarity.md +1 -1
  108. package/.docs/reference/evals/bias.md +1 -1
  109. package/.docs/reference/evals/context-precision.md +3 -3
  110. package/.docs/reference/evals/context-relevance.md +11 -11
  111. package/.docs/reference/evals/create-scorer.md +2 -0
  112. package/.docs/reference/evals/faithfulness.md +1 -1
  113. package/.docs/reference/evals/hallucination.md +5 -5
  114. package/.docs/reference/evals/noise-sensitivity.md +11 -11
  115. package/.docs/reference/evals/prompt-alignment.md +15 -15
  116. package/.docs/reference/evals/tool-call-accuracy.md +3 -3
  117. package/.docs/reference/evals/toxicity.md +1 -1
  118. package/.docs/reference/index.md +15 -0
  119. package/.docs/reference/memory/memory-class.md +3 -3
  120. package/.docs/reference/memory/observational-memory.md +6 -4
  121. package/.docs/reference/memory/serialized-memory-config.md +72 -0
  122. package/.docs/reference/observability/metrics/automatic-metrics.md +7 -1
  123. package/.docs/reference/observability/tracing/exporters/langfuse.md +1 -1
  124. package/.docs/reference/processors/batch-parts-processor.md +1 -1
  125. package/.docs/reference/processors/cost-guard-processor.md +1 -1
  126. package/.docs/reference/processors/language-detector.md +1 -1
  127. package/.docs/reference/processors/message-history-processor.md +1 -1
  128. package/.docs/reference/processors/moderation-processor.md +2 -2
  129. package/.docs/reference/processors/pii-detector.md +2 -2
  130. package/.docs/reference/processors/prefill-error-handler.md +2 -2
  131. package/.docs/reference/processors/processor-interface.md +2 -2
  132. package/.docs/reference/processors/prompt-injection-detector.md +1 -1
  133. package/.docs/reference/processors/regex-filter-processor.md +1 -1
  134. package/.docs/reference/processors/semantic-recall-processor.md +1 -1
  135. package/.docs/reference/processors/skill-search-processor.md +1 -1
  136. package/.docs/reference/processors/system-prompt-scrubber.md +1 -1
  137. package/.docs/reference/processors/token-limiter-processor.md +3 -3
  138. package/.docs/reference/processors/tool-call-filter.md +2 -2
  139. package/.docs/reference/processors/tool-search-processor.md +33 -2
  140. package/.docs/reference/processors/unicode-normalizer.md +1 -1
  141. package/.docs/reference/processors/working-memory-processor.md +1 -1
  142. package/.docs/reference/rag/rerank.md +1 -1
  143. package/.docs/reference/server/nestjs-adapter.md +1 -1
  144. package/.docs/reference/server/routes.md +108 -9
  145. package/.docs/reference/storage/dsql.md +1 -1
  146. package/.docs/reference/storage/mongodb.md +1 -1
  147. package/.docs/reference/storage/postgresql.md +1 -1
  148. package/.docs/reference/storage/redis.md +1 -1
  149. package/.docs/reference/storage/spanner.md +5 -0
  150. package/.docs/reference/storage/upstash.md +1 -1
  151. package/.docs/reference/streaming/agents/stream.md +1 -1
  152. package/.docs/reference/templates/overview.md +3 -3
  153. package/.docs/reference/tools/mcp-client.md +53 -2
  154. package/.docs/reference/tools/mcp-server.md +33 -1
  155. package/.docs/reference/tools/vector-query-tool.md +1 -1
  156. package/.docs/reference/vectors/libsql.md +1 -1
  157. package/.docs/reference/vectors/mongodb.md +1 -1
  158. package/.docs/reference/vectors/pg.md +3 -1
  159. package/.docs/reference/vectors/upstash.md +1 -1
  160. package/.docs/reference/voice/google-gemini-live.md +15 -2
  161. package/.docs/reference/voice/inworld-realtime.md +353 -0
  162. package/.docs/reference/voice/inworld.md +2 -0
  163. package/.docs/reference/voice/voice.addInstructions.md +1 -1
  164. package/.docs/reference/workspace/agentcore-runtime-sandbox.md +202 -0
  165. package/.docs/reference/workspace/agentfs-filesystem.md +1 -1
  166. package/.docs/reference/workspace/azure-blob-filesystem.md +1 -1
  167. package/.docs/reference/workspace/blaxel-sandbox.md +3 -0
  168. package/.docs/reference/workspace/docker-sandbox.md +4 -2
  169. package/.docs/reference/workspace/e2b-sandbox.md +9 -5
  170. package/.docs/reference/workspace/files-sdk-filesystem.md +1 -1
  171. package/.docs/reference/workspace/gcs-filesystem.md +1 -1
  172. package/.docs/reference/workspace/google-drive-filesystem.md +1 -1
  173. package/.docs/reference/workspace/local-filesystem.md +1 -1
  174. package/.docs/reference/workspace/local-sandbox.md +1 -1
  175. package/.docs/reference/workspace/modal-sandbox.md +1 -1
  176. package/.docs/reference/workspace/s3-filesystem.md +1 -1
  177. package/.docs/reference/workspace/vercel-microvm-sandbox.md +199 -0
  178. package/.docs/reference/workspace/vercel.md +2 -0
  179. package/CHANGELOG.md +72 -0
  180. package/package.json +9 -7
@@ -0,0 +1,261 @@
1
+ # SDK agents
2
+
3
+ SDK agents let you use other agent SDK frameworks inside Mastra. Use them to register SDK-backed agents in a Mastra project while the provider SDK keeps its own runtime, tools, permissions, and agent loop.
4
+
5
+ ## When to use SDK agents
6
+
7
+ - A vendor SDK already owns the agent loop, tools, permissions, or local runtime.
8
+ - You want to register that SDK-backed agent in a Mastra project.
9
+ - You need Mastra-compatible `generate()` and `stream()` outputs.
10
+ - You want usage, cost, and tool activity from the SDK run to appear in Mastra observability.
11
+
12
+ ## Supported SDK agents
13
+
14
+ - [Claude Agent SDK](#claude-agent-sdk): Use `@mastra/claude` to register a Claude SDK agent and call it with Mastra `generate()` and `stream()`.
15
+ - [Cursor Agent SDK](#cursor-agent-sdk): Use `@mastra/cursor` to register a Cursor SDK agent and call it with Mastra `generate()` and `stream()`.
16
+
17
+ ## Claude Agent SDK
18
+
19
+ Use `@mastra/claude` for Claude Code runtime configuration, permissions, tools, and agent-loop behavior.
20
+
21
+ ### Install Claude packages
22
+
23
+ Install the Mastra package and the Claude Agent SDK peer dependency:
24
+
25
+ **npm**:
26
+
27
+ ```bash
28
+ npm install @mastra/claude @anthropic-ai/claude-agent-sdk
29
+ ```
30
+
31
+ **pnpm**:
32
+
33
+ ```bash
34
+ pnpm add @mastra/claude @anthropic-ai/claude-agent-sdk
35
+ ```
36
+
37
+ **Yarn**:
38
+
39
+ ```bash
40
+ yarn add @mastra/claude @anthropic-ai/claude-agent-sdk
41
+ ```
42
+
43
+ **Bun**:
44
+
45
+ ```bash
46
+ bun add @mastra/claude @anthropic-ai/claude-agent-sdk
47
+ ```
48
+
49
+ Set the Claude SDK credential:
50
+
51
+ ```bash
52
+ export ANTHROPIC_API_KEY="..."
53
+ ```
54
+
55
+ ### Create a Claude SDK agent
56
+
57
+ Configure Claude Agent SDK through `sdkOptions`.
58
+
59
+ ```typescript
60
+ import { ClaudeSDKAgent } from '@mastra/claude'
61
+
62
+ export const claudeSDKAgent = new ClaudeSDKAgent({
63
+ id: 'claude-sdk-agent',
64
+ name: 'Claude SDK Agent',
65
+ description: 'Use Claude Agent SDK through Mastra.',
66
+ sdkOptions: {
67
+ model: 'claude-sonnet-4-6',
68
+ cwd: process.cwd(),
69
+ },
70
+ })
71
+ ```
72
+
73
+ ### Add Claude SDK tools
74
+
75
+ Claude Agent SDK tools are provided through Claude SDK Model Context Protocol (MCP) servers. Create the server with the Claude SDK, then pass it through `sdkOptions.mcpServers`.
76
+
77
+ ```typescript
78
+ import { createSdkMcpServer } from '@anthropic-ai/claude-agent-sdk'
79
+ import { ClaudeSDKAgent } from '@mastra/claude'
80
+ import { getTemperature } from '../tools/get-temperature'
81
+
82
+ const weatherServer = createSdkMcpServer({
83
+ name: 'weather',
84
+ version: '1.0.0',
85
+ tools: [getTemperature],
86
+ })
87
+
88
+ export const claudeSDKAgent = new ClaudeSDKAgent({
89
+ id: 'claude-sdk-agent',
90
+ name: 'Claude SDK Agent',
91
+ description: 'Use Claude Agent SDK through Mastra.',
92
+ sdkOptions: {
93
+ model: 'claude-sonnet-4-6',
94
+ cwd: process.cwd(),
95
+ mcpServers: {
96
+ weather: weatherServer,
97
+ },
98
+ allowedTools: ['mcp__weather__get_temperature'],
99
+ },
100
+ })
101
+ ```
102
+
103
+ The `allowedTools` value uses Claude Agent SDK MCP tool naming: `mcp__<server name>__<tool name>`.
104
+
105
+ ## Cursor Agent SDK
106
+
107
+ Use `@mastra/cursor` to register a Cursor SDK agent in Mastra while keeping Cursor-specific setup in Cursor SDK options.
108
+
109
+ ### Install Cursor packages
110
+
111
+ Install the Mastra package and the Cursor SDK peer dependency:
112
+
113
+ **npm**:
114
+
115
+ ```bash
116
+ npm install @mastra/cursor @cursor/sdk
117
+ ```
118
+
119
+ **pnpm**:
120
+
121
+ ```bash
122
+ pnpm add @mastra/cursor @cursor/sdk
123
+ ```
124
+
125
+ **Yarn**:
126
+
127
+ ```bash
128
+ yarn add @mastra/cursor @cursor/sdk
129
+ ```
130
+
131
+ **Bun**:
132
+
133
+ ```bash
134
+ bun add @mastra/cursor @cursor/sdk
135
+ ```
136
+
137
+ Set the Cursor SDK credential:
138
+
139
+ ```bash
140
+ export CURSOR_API_KEY="..."
141
+ ```
142
+
143
+ ### Create a Cursor SDK agent
144
+
145
+ Configure Cursor Agent SDK through `sdkOptions`.
146
+
147
+ ```typescript
148
+ import { CursorSDKAgent } from '@mastra/cursor'
149
+
150
+ export const cursorSDKAgent = new CursorSDKAgent({
151
+ id: 'cursor-sdk-agent',
152
+ name: 'Cursor SDK Agent',
153
+ description: 'Use Cursor Agent SDK through Mastra.',
154
+ sdkOptions: {
155
+ apiKey: process.env.CURSOR_API_KEY,
156
+ model: {
157
+ id: 'gpt-5.5',
158
+ },
159
+ local: {
160
+ cwd: process.cwd(),
161
+ },
162
+ },
163
+ })
164
+ ```
165
+
166
+ Cursor local agents require an explicit model. Set it in `sdkOptions.model`.
167
+
168
+ ### Use an existing Cursor SDK agent
169
+
170
+ If your app already creates a Cursor SDK agent, pass that agent to `CursorSDKAgent` instead:
171
+
172
+ ```typescript
173
+ import { Agent as CursorAgent } from '@cursor/sdk'
174
+ import { CursorSDKAgent } from '@mastra/cursor'
175
+
176
+ const cursorAgent = CursorAgent.create({
177
+ apiKey: process.env.CURSOR_API_KEY,
178
+ model: {
179
+ id: 'gpt-5.5',
180
+ },
181
+ local: {
182
+ cwd: process.cwd(),
183
+ },
184
+ })
185
+
186
+ export const cursorSDKAgent = new CursorSDKAgent({
187
+ id: 'cursor-sdk-agent',
188
+ name: 'Cursor SDK Agent',
189
+ description: 'Use Cursor Agent SDK through Mastra.',
190
+ agent: cursorAgent,
191
+ })
192
+ ```
193
+
194
+ ### Add Cursor SDK tools
195
+
196
+ Cursor Agent SDK tools are configured with Cursor SDK options. Pass Model Context Protocol (MCP) servers through `sdkOptions.mcpServers`:
197
+
198
+ ```typescript
199
+ import { CursorSDKAgent } from '@mastra/cursor'
200
+ import { mcpServers } from '../mcp/cursor'
201
+
202
+ export const cursorSDKAgent = new CursorSDKAgent({
203
+ id: 'cursor-sdk-agent',
204
+ name: 'Cursor SDK Agent',
205
+ description: 'Use Cursor Agent SDK through Mastra.',
206
+ sdkOptions: {
207
+ apiKey: process.env.CURSOR_API_KEY,
208
+ model: {
209
+ id: 'gpt-5.5',
210
+ },
211
+ local: {
212
+ cwd: process.cwd(),
213
+ },
214
+ mcpServers,
215
+ },
216
+ })
217
+ ```
218
+
219
+ ## Register SDK agents
220
+
221
+ Register SDK agents in the Mastra instance like other agents:
222
+
223
+ ```typescript
224
+ import { Mastra } from '@mastra/core'
225
+ import { claudeSDKAgent } from './agents/claude-sdk-agent'
226
+ import { cursorSDKAgent } from './agents/cursor-sdk-agent'
227
+
228
+ export const mastra = new Mastra({
229
+ agents: {
230
+ claudeSDKAgent,
231
+ cursorSDKAgent,
232
+ },
233
+ })
234
+ ```
235
+
236
+ After registration, call them with `mastra.getAgentById()`:
237
+
238
+ ```typescript
239
+ import { mastra } from './index'
240
+
241
+ const agent = mastra.getAgentById('cursor-sdk-agent')
242
+ const stream = await agent.stream('Inspect this project and describe the test setup.')
243
+
244
+ for await (const chunk of stream.textStream) {
245
+ process.stdout.write(chunk)
246
+ }
247
+ ```
248
+
249
+ ## Observability
250
+
251
+ SDK agents create Mastra agent and model spans for `generate()` and `stream()` calls. Mastra records SDK-provided usage, tool activity, and provider metadata when the vendor SDK exposes those events.
252
+
253
+ Claude SDK runs can include SDK-estimated cost from the Claude result message. Cursor SDK runs include token usage from Cursor interaction updates.
254
+
255
+ For storage and dashboard setup, see [Observability](https://mastra.ai/docs/observability/overview).
256
+
257
+ ## Related
258
+
259
+ - [Agents overview](https://mastra.ai/docs/agents/overview)
260
+ - [Tools](https://mastra.ai/docs/agents/using-tools)
261
+ - [Observability](https://mastra.ai/docs/observability/overview)
@@ -1,14 +1,14 @@
1
1
  # Signals
2
2
 
3
- > **Experimental:** This feature is in alpha. Breaking changes may occur without a major version bump until the API is stable.
3
+ > **Alpha:** This feature is in alpha. Breaking changes may occur without a major version bump until the API is stable.
4
4
 
5
- Signals are a way to interact with an agent through a thread. Instead of starting every interaction with `agent.stream()`, subscribe to a thread and send signals. Mastra either wakes the agent when the thread is idle or drops the signal into the running agent loop.
5
+ Signals are a way to interact with an agent through a thread. Instead of starting every interaction with `agent.stream()`, subscribe to a thread and send messages or signals. Mastra either wakes the agent when the thread is idle, drops input into the running agent loop, or queues input for the next turn.
6
6
 
7
- Signals are a context engineering tool for guiding the agent in real time as the agent loop progresses. Use them to add system-generated content from external event sources, such as incoming email notifications, GitHub pull request comments, background task notifications, and similar events.
7
+ Use message APIs for user-authored input. Use `sendSignal()` for lower-level system context, such as background task notifications, policy reminders, or processor-generated context.
8
8
 
9
9
  ## Quickstart
10
10
 
11
- Subscribe to the thread before sending signals. The subscription receives the active stream when the signal wakes the agent or enters a running loop.
11
+ Subscribe to the thread before sending messages. The subscription receives the active stream when the message wakes the agent or enters a running loop.
12
12
 
13
13
  ```typescript
14
14
  const subscription = await agent.subscribeToThread({
@@ -16,33 +16,65 @@ const subscription = await agent.subscribeToThread({
16
16
  threadId: 'thread_456',
17
17
  })
18
18
 
19
- agent.sendSignal(
19
+ agent.sendMessage('Compare that with the previous option.', {
20
+ resourceId: 'user_123',
21
+ threadId: 'thread_456',
22
+ })
23
+
24
+ for await (const chunk of subscription.stream) {
25
+ console.log(chunk)
26
+ }
27
+ ```
28
+
29
+ When the thread has a running agent stream, `sendMessage()` becomes new input inside that agent loop. When the thread is idle, Mastra starts a stream with the message as the first input.
30
+
31
+ ## Send a message now
32
+
33
+ Use `sendMessage()` when the user expects the active agent to see the message immediately.
34
+
35
+ ```typescript
36
+ agent.sendMessage(
20
37
  {
21
- type: 'user-message',
22
- contents: 'Compare that with the previous option.',
38
+ contents: 'Use the latest customer note too.',
39
+ attributes: { name: 'Jane', sentFrom: 'slack' },
23
40
  },
24
41
  {
25
42
  resourceId: 'user_123',
26
43
  threadId: 'thread_456',
27
44
  },
28
45
  )
46
+ ```
29
47
 
30
- for await (const chunk of subscription.stream) {
31
- console.log(chunk)
32
- }
48
+ The model receives attributed messages as XML-wrapped user input:
49
+
50
+ ```xml
51
+ <user name="Jane" sentFrom="slack">Use the latest customer note too.</user>
33
52
  ```
34
53
 
35
- When the thread has a running agent stream, the signal becomes new input inside that agent loop. When the thread is idle, Mastra starts a stream with the signal as the first input.
54
+ Messages without attributes are sent as plain user input.
36
55
 
37
- ## Control signal behavior
56
+ ## Queue a message for the next turn
38
57
 
39
- By default, Mastra delivers signals to active runs and wakes idle threads. Use `ifActive.behavior` and `ifIdle.behavior` to change that behavior.
58
+ Use `queueMessage()` when a user sends a follow-up but the active model call should finish first. Mastra waits for the active run to complete, then starts a new run on the same thread.
59
+
60
+ ```typescript
61
+ agent.queueMessage('Also check whether the tests need updates.', {
62
+ resourceId: 'user_123',
63
+ threadId: 'thread_456',
64
+ })
65
+ ```
66
+
67
+ When the thread is idle, `queueMessage()` starts a run immediately. When the thread is active, it preserves turn order by starting a new run after the active run completes.
68
+
69
+ ## Control low-level signal behavior
70
+
71
+ Use `sendSignal()` when you need to send system-generated context instead of user-authored input. For external events, use `type: 'notification'`. By default, Mastra delivers signals to active runs and wakes idle threads. Use `ifActive.behavior` and `ifIdle.behavior` to change that behavior.
40
72
 
41
73
  ```typescript
42
74
  const result = agent.sendSignal(
43
75
  {
44
- type: 'user-message',
45
- contents: 'Store this for later, but do not wake the agent.',
76
+ type: 'notification',
77
+ contents: 'GitHub CI failed on PR #123: 3 tests failed.',
46
78
  },
47
79
  {
48
80
  resourceId: 'user_123',
@@ -58,44 +90,43 @@ await result.persisted
58
90
 
59
91
  The behavior options are:
60
92
 
61
- - `ifActive.behavior: 'deliver'`: Add the signal to the running agent loop. This is the default.
62
- - `ifActive.behavior: 'persist'`: Save the signal to memory without adding it to the running loop.
63
- - `ifActive.behavior: 'discard'`: Ignore the signal while the thread is active.
64
- - `ifIdle.behavior: 'wake'`: Start a stream with the signal as the first input. This is the default.
65
- - `ifIdle.behavior: 'persist'`: Save the signal to memory without starting a stream.
66
- - `ifIdle.behavior: 'discard'`: Ignore the signal while the thread is idle.
93
+ - `ifActive.behavior: 'deliver'`: Add the signal or message to the running agent loop. This is the default.
94
+ - `ifActive.behavior: 'persist'`: Save the signal or message to memory without adding it to the running loop.
95
+ - `ifActive.behavior: 'discard'`: Ignore the signal or message while the thread is active.
96
+ - `ifIdle.behavior: 'wake'`: Start a stream with the signal or message as the first input. This is the default.
97
+ - `ifIdle.behavior: 'persist'`: Save the signal or message to memory without starting a stream.
98
+ - `ifIdle.behavior: 'discard'`: Ignore the signal or message while the thread is idle.
67
99
 
68
100
  Pass `ifIdle.streamOptions` when the idle wake-up stream needs options such as model settings, tools, or runtime context. You do not need to repeat `memory.resource` or `memory.thread`; Mastra uses the top-level `resourceId` and `threadId` for the thread.
69
101
 
70
102
  ```typescript
71
- agent.sendSignal(
72
- {
73
- type: 'user-message',
74
- contents: 'Continue with the next step.',
75
- },
76
- {
77
- resourceId: 'user_123',
78
- threadId: 'thread_456',
79
- ifIdle: {
80
- behavior: 'wake',
81
- streamOptions: {
82
- maxSteps: 3,
83
- },
103
+ agent.sendMessage('Continue with the next step.', {
104
+ resourceId: 'user_123',
105
+ threadId: 'thread_456',
106
+ ifIdle: {
107
+ behavior: 'wake',
108
+ streamOptions: {
109
+ maxSteps: 3,
84
110
  },
85
111
  },
86
- )
112
+ })
87
113
  ```
88
114
 
89
- ## Identify users with attributes
115
+ ## Send notification context
90
116
 
91
- Use `attributes` to tag each signal with user identity. The signal type and attributes are rendered as XML so the model can distinguish who said what in a multi-user thread:
117
+ Signals have a semantic `type` and an LLM-facing `tagName`. Use `type` to describe the signal category. Use `tagName` to control the XML tag the model sees.
118
+
119
+ For external events, use `type: 'notification'`. Reactive signals are reserved for processor- or runtime-generated context, such as policy guidance, background task results, and auto-loaded instructions.
92
120
 
93
121
  ```typescript
94
122
  agent.sendSignal(
95
123
  {
96
- type: 'user',
97
- contents: 'Can we simplify the API surface?',
98
- attributes: { name: 'Devin', from: 'slack' },
124
+ type: 'notification',
125
+ contents: 'PR #123 has a new review comment from User X about the API surface.',
126
+ attributes: {
127
+ source: 'github',
128
+ pr: '123',
129
+ },
99
130
  },
100
131
  {
101
132
  resourceId: 'user_123',
@@ -104,51 +135,67 @@ agent.sendSignal(
104
135
  )
105
136
  ```
106
137
 
107
- The model receives:
138
+ The model receives the signal as context like this:
108
139
 
109
140
  ```xml
110
- <user name="Devin" from="slack">Can we simplify the API surface?</user>
141
+ <notification source="github" pr="123">PR #123 has a new review comment from User X about the API surface.</notification>
111
142
  ```
112
143
 
113
- The UI sees just the message contents but can also read `attributes` and `metadata` off the signal message for custom rendering (e.g. showing user names, avatars, or platform badges).
144
+ Use XML-safe `tagName` and attribute names. They can contain letters, numbers, underscores, periods, and hyphens. They must start with a letter or underscore.
114
145
 
115
- ## Send external event context
146
+ ## Send processor context
116
147
 
117
- Use custom signal types for system-generated context. Non-user signal types are rendered as XML-style user-role context so they can appear inside conversation history without looking like assistant output.
148
+ Processors can send reactive signals during a run. A processor should inspect the chat history, react to a specific trigger, and avoid sending the same context more than once.
149
+
150
+ The following example demonstrates a processor that injects `AGENTS.md` instructions after a tool call reads an `AGENTS.md` file.
118
151
 
119
152
  ```typescript
120
- agent.sendSignal(
121
- {
122
- type: 'system-reminder',
123
- contents: 'User X has left a new PR comment asking for a smaller API surface.',
124
- attributes: {
125
- source: 'github',
126
- pr: '123',
127
- },
128
- },
129
- {
130
- resourceId: 'user_123',
131
- threadId: 'thread_456',
153
+ import type { Processor, ProcessInputStepArgs } from '@mastra/core/processors'
154
+
155
+ export const agentsMdReminderProcessor: Processor = {
156
+ id: 'agents-md-reminder',
157
+ async processInputStep({ messageList, sendSignal }: ProcessInputStepArgs) {
158
+ const messages = messageList.get.all.db()
159
+ const agentsMdPath = findAgentsMdPathFromToolCalls(messages)
160
+
161
+ if (!agentsMdPath || hasAlreadySentAgentsMdReminder(messages, agentsMdPath)) {
162
+ return messageList
163
+ }
164
+
165
+ await sendSignal?.({
166
+ type: 'reactive',
167
+ contents: readAgentsMdInstructions(agentsMdPath),
168
+ attributes: {
169
+ type: 'dynamic-agents-md',
170
+ path: agentsMdPath,
171
+ },
172
+ metadata: {
173
+ path: agentsMdPath,
174
+ },
175
+ })
176
+
177
+ return messageList
132
178
  },
133
- )
179
+ }
134
180
  ```
135
181
 
136
- The model receives the custom signal as context like this:
182
+ Reactive signals default to `tagName: 'system-reminder'`, so the model receives this context as
137
183
 
138
184
  ```xml
139
- <system-reminder source="github" pr="123">User X has left a new PR comment asking for a smaller API surface.</system-reminder>
185
+ <system-reminder type="dynamic-agents-md" path="packages/ui/AGENTS.md">
186
+ $agentsMdFileContents
187
+ </system-reminder>
140
188
  ```
141
189
 
142
- Use XML-safe signal type names and attribute names. Signal type names and attribute names can contain letters, numbers, underscores, periods, and hyphens. They must start with a letter or underscore.
190
+ Awaiting `sendSignal()` preserves stream echo ordering when a subscribed thread is active.
143
191
 
144
- ## Delivery attributes
192
+ ## Conditional attributes
145
193
 
146
- Use `ifActive.attributes` and `ifIdle.attributes` to tag a signal with context that depends on whether the agent is active or idle at delivery time. Mastra resolves the correct branch when the signal is accepted.
194
+ Use `ifActive.attributes` and `ifIdle.attributes` to tag input with context that depends on whether the agent is active or idle at delivery time. Mastra resolves the correct branch when the input is accepted.
147
195
 
148
196
  ```typescript
149
- agent.sendSignal(
197
+ agent.sendMessage(
150
198
  {
151
- type: 'user-message',
152
199
  contents: 'Also cover the edge cases.',
153
200
  attributes: { source: 'chat' },
154
201
  },
@@ -156,7 +203,7 @@ agent.sendSignal(
156
203
  resourceId: 'user_123',
157
204
  threadId: 'thread_456',
158
205
  ifActive: { attributes: { delivery: 'while-active' } },
159
- ifIdle: { attributes: { delivery: 'message' } },
206
+ ifIdle: { attributes: { delivery: 'new-message' } },
160
207
  },
161
208
  )
162
209
  ```
@@ -164,24 +211,50 @@ agent.sendSignal(
164
211
  When the agent is working, the model sees:
165
212
 
166
213
  ```xml
167
- <user-message source="chat" delivery="while-active">Also cover the edge cases.</user-message>
214
+ <user source="chat" delivery="while-active">Also cover the edge cases.</user>
168
215
  ```
169
216
 
170
217
  When the agent is idle:
171
218
 
172
219
  ```xml
173
- <user-message source="chat" delivery="message">Also cover the edge cases.</user-message>
220
+ <user source="chat" delivery="new-message">Also cover the edge cases.</user>
221
+ ```
222
+
223
+ Top-level `attributes` always apply. The selected branch's `attributes` are merged into them at delivery time. The `delivery` name shown above is not a special Mastra API field. It is a custom attribute name used for this example, you can add any attribute names that suit your use case.
224
+
225
+ ## Compatibility
226
+
227
+ Mastra still accepts legacy signal payloads such as `type: 'user-message'` and `type: 'system-reminder'`. It normalizes them internally to the new category and tag shape:
228
+
229
+ - `type: 'user-message'`: Normalizes to `type: 'user'` and `tagName: 'user'`
230
+ - `type: 'system-reminder'`: Normalizes to `type: 'reactive'` and `tagName: 'system-reminder'`
231
+
232
+ Existing stored signal rows and older clients continue to load through the compatibility layer.
233
+
234
+ > **Note:** Visit [Agent signals reference](https://mastra.ai/reference/agents/agent) for the full message, signal, and subscription types.
235
+
236
+ ## Approve tool calls
237
+
238
+ When a subscribed run pauses for tool approval, approve or decline the tool call with the subscription-native methods. The call returns a JSON acknowledgement. The resumed chunks arrive through the existing thread subscription.
239
+
240
+ ```typescript
241
+ await agent.sendToolApproval({
242
+ resourceId: 'user_123',
243
+ threadId: 'thread_456',
244
+ toolCallId: 'tool-call_456',
245
+ approved: true,
246
+ })
174
247
  ```
175
248
 
176
- Top-level `attributes` always apply. The selected branch's `attributes` are merged into them at delivery time. The `ifActive.attributes` branch merges when the signal is delivered to a running agent loop. The `ifIdle.attributes` branch merges when the signal wakes an idle thread. If the selected branch or its `attributes` field is `undefined`, no extra attributes are added.
249
+ Pass `approved: false` to decline the same pending tool call. Use the older `approveToolCall()` and `declineToolCall()` methods only when you are rendering the separate continuation stream directly.
177
250
 
178
- Delivery attributes work with any signal type and can carry any key-value pairs. The `delivery` name shown above is not a special Mastra API field. It is a custom attribute name used for this example; you can use any attribute names that fit your application.
251
+ ## Use HTTP routes
179
252
 
180
- > **Note:** Visit [Agent.sendSignal() reference](https://mastra.ai/reference/agents/agent) for the full signal input and options types.
253
+ If you call Mastra over HTTP directly, use `POST /api/agents/:agentId/send-message` for immediate messages and `POST /api/agents/:agentId/queue-message` for next-turn messages. For subscription-native tool approval, use `POST /api/agents/:agentId/send-tool-approval`. See [Server routes reference](https://mastra.ai/reference/server/routes) for request and response schemas.
181
254
 
182
255
  ## Use the client SDK
183
256
 
184
- The JavaScript client exposes the same thread signal APIs. Use `subscribeToThread()` before `sendSignal()` so the client can render the stream that wakes from, or receives, the signal.
257
+ The JavaScript client exposes thread signal APIs. Use `subscribeToThread()` before sending thread input so the client can render the stream that wakes from, or receives, the input.
185
258
 
186
259
  ```typescript
187
260
  const agent = client.getAgent('supportAgent')
@@ -230,7 +303,11 @@ Use heartbeats together with client-side reconnect logic. Heartbeats reduce idle
230
303
 
231
304
  ## Related
232
305
 
306
+ - [`Agent.sendMessage()`](https://mastra.ai/reference/agents/agent)
307
+ - [`Agent.queueMessage()`](https://mastra.ai/reference/agents/agent)
233
308
  - [`Agent.sendSignal()`](https://mastra.ai/reference/agents/agent)
234
309
  - [`Agent.subscribeToThread()`](https://mastra.ai/reference/agents/agent)
310
+ - [Server agent routes](https://mastra.ai/reference/server/routes)
235
311
  - [`client.getAgent().sendSignal()`](https://mastra.ai/reference/client-js/agents)
236
- - [`client.getAgent().subscribeToThread()`](https://mastra.ai/reference/client-js/agents)
312
+ - [`client.getAgent().subscribeToThread()`](https://mastra.ai/reference/client-js/agents)
313
+ - [`client.getAgent().sendToolApproval()`](https://mastra.ai/reference/client-js/agents)
@@ -178,7 +178,7 @@ const response = await testAgent.generate('Analyze the TypeScript programming la
178
178
  differentiators: z.array(z.string()),
179
179
  }),
180
180
  }),
181
- model: 'openai/gpt-5.4',
181
+ model: 'openai/gpt-5.5',
182
182
  },
183
183
  })
184
184
 
@@ -248,7 +248,7 @@ When `model` is provided to the `structuredOutput` property, Mastra uses a separ
248
248
  const response = await testAgent.generate('Tell me about TypeScript.', {
249
249
  structuredOutput: {
250
250
  schema: yourSchema,
251
- model: 'openai/gpt-5.4',
251
+ model: 'openai/gpt-5.5',
252
252
  },
253
253
  })
254
254
  ```
@@ -267,7 +267,7 @@ const response = await testAgent.generate('Return my profile as structured data.
267
267
  hometown: z.string(),
268
268
  petName: z.string(),
269
269
  }),
270
- model: 'openai/gpt-5.4',
270
+ model: 'openai/gpt-5.5',
271
271
  useAgent: true,
272
272
  },
273
273
  })
@@ -284,7 +284,7 @@ const result = await agent.stream('weather in vancouver?', {
284
284
  prepareStep: async ({ stepNumber }) => {
285
285
  if (stepNumber === 0) {
286
286
  return {
287
- model: 'openai/gpt-5.4',
287
+ model: 'openai/gpt-5.5',
288
288
  tools: {
289
289
  weatherTool,
290
290
  },
@@ -292,7 +292,7 @@ const result = await agent.stream('weather in vancouver?', {
292
292
  }
293
293
  }
294
294
  return {
295
- model: 'openai/gpt-5.4',
295
+ model: 'openai/gpt-5.5',
296
296
  tools: undefined,
297
297
  structuredOutput: {
298
298
  schema: z.object({
@@ -41,7 +41,7 @@ const supervisor = new Agent({
41
41
  id: 'supervisor',
42
42
  instructions: `You coordinate research and writing using specialized agents.
43
43
  Delegate to research-agent for facts, then writing-agent for content.`,
44
- model: 'openai/gpt-5.4',
44
+ model: 'openai/gpt-5.5',
45
45
  agents: { researchAgent, writingAgent },
46
46
  memory: new Memory({
47
47
  storage: new LibSQLStore({ id: 'storage', url: 'file:mastra.db' }),
@@ -326,7 +326,7 @@ Enable the [backgroundTasks manager](https://mastra.ai/reference/configuration)
326
326
  const supervisor = new Agent({
327
327
  id: 'supervisor',
328
328
  instructions: 'Coordinate research and writing using the available agents.',
329
- model: 'openai/gpt-5.4',
329
+ model: 'openai/gpt-5.5',
330
330
  agents: { researchAgent, writingAgent },
331
331
  backgroundTasks: {
332
332
  tools: {