@mastra/mcp-docs-server 1.1.35-alpha.8 → 1.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +48 -4
- package/.docs/docs/agents/background-tasks.md +62 -2
- package/.docs/docs/agents/processors.md +9 -1
- package/.docs/docs/agents/response-caching.md +148 -0
- package/.docs/docs/agents/signals.md +151 -0
- package/.docs/docs/agents/using-tools.md +8 -0
- package/.docs/docs/browser/agent-browser.md +15 -0
- package/.docs/docs/browser/stagehand.md +25 -1
- package/.docs/docs/editor/tools.md +1 -1
- package/.docs/docs/index.md +2 -2
- package/.docs/docs/mastra-platform/configuration.md +1 -1
- package/.docs/docs/mastra-platform/overview.md +1 -1
- package/.docs/docs/memory/observational-memory.md +61 -13
- package/.docs/docs/memory/semantic-recall.md +68 -6
- package/.docs/docs/observability/logging.md +2 -2
- package/.docs/docs/observability/metrics/overview.md +4 -4
- package/.docs/docs/observability/overview.md +6 -6
- package/.docs/docs/observability/tracing/bridges/otel.md +25 -0
- package/.docs/docs/observability/tracing/exporters/arize.md +5 -5
- package/.docs/docs/observability/tracing/exporters/braintrust.md +37 -0
- package/.docs/docs/observability/tracing/exporters/langfuse.md +21 -0
- package/.docs/docs/observability/tracing/exporters/{cloud.md → mastra-platform.md} +28 -26
- package/.docs/docs/observability/tracing/exporters/{default.md → mastra-storage.md} +56 -19
- package/.docs/docs/observability/tracing/exporters/otel.md +79 -2
- package/.docs/docs/observability/tracing/overview.md +30 -29
- package/.docs/docs/observability/tracing/processors/sensitive-data-filter.md +6 -6
- package/.docs/docs/server/mastra-server.md +30 -19
- package/.docs/docs/studio/observability.md +4 -4
- package/.docs/docs/studio/overview.md +6 -0
- package/.docs/docs/voice/overview.md +84 -0
- package/.docs/docs/workflows/suspend-and-resume.md +28 -1
- package/.docs/guides/deployment/inngest.md +23 -0
- package/.docs/guides/migrations/mastra-cloud.md +6 -6
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +19 -17
- package/.docs/models/gateways/netlify.md +2 -1
- package/.docs/models/gateways/openrouter.md +4 -1
- package/.docs/models/gateways/vercel.md +2 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/chutes.md +23 -54
- package/.docs/models/providers/databricks.md +96 -0
- package/.docs/models/providers/deepseek.md +3 -1
- package/.docs/models/providers/digitalocean.md +9 -2
- package/.docs/models/providers/firepass.md +71 -0
- package/.docs/models/providers/google.md +3 -2
- package/.docs/models/providers/kilo.md +5 -3
- package/.docs/models/providers/llmgateway.md +7 -1
- package/.docs/models/providers/nebius.md +37 -55
- package/.docs/models/providers/novita-ai.md +5 -5
- package/.docs/models/providers/nvidia.md +59 -49
- package/.docs/models/providers/ollama-cloud.md +1 -1
- package/.docs/models/providers/openai.md +2 -0
- package/.docs/models/providers/opencode.md +44 -43
- package/.docs/models/providers/poe.md +4 -1
- package/.docs/models/providers/sarvam.md +72 -0
- package/.docs/models/providers/wafer.ai.md +2 -1
- package/.docs/models/providers/xiaomi-token-plan-ams.md +6 -5
- package/.docs/models/providers/xiaomi-token-plan-cn.md +6 -5
- package/.docs/models/providers/xiaomi-token-plan-sgp.md +6 -5
- package/.docs/models/providers.md +3 -1
- package/.docs/reference/agents/agent.md +85 -0
- package/.docs/reference/browser/agent-browser.md +37 -11
- package/.docs/reference/browser/stagehand-browser.md +35 -9
- package/.docs/reference/cli/mastra.md +33 -1
- package/.docs/reference/client-js/agents.md +115 -1
- package/.docs/reference/client-js/responses.md +4 -0
- package/.docs/reference/configuration.md +6 -6
- package/.docs/reference/editor/tool-provider.md +3 -3
- package/.docs/reference/harness/harness-class.md +21 -8
- package/.docs/reference/index.md +5 -0
- package/.docs/reference/memory/observational-memory.md +11 -1
- package/.docs/reference/observability/metrics/automatic-metrics.md +2 -4
- package/.docs/reference/observability/tracing/bridges/datadog.md +2 -2
- package/.docs/reference/observability/tracing/bridges/otel.md +26 -4
- package/.docs/reference/observability/tracing/configuration.md +6 -3
- package/.docs/reference/observability/tracing/exporters/arize.md +1 -1
- package/.docs/reference/observability/tracing/exporters/braintrust.md +2 -0
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +3 -1
- package/.docs/reference/observability/tracing/exporters/console-exporter.md +2 -2
- package/.docs/reference/observability/tracing/exporters/default-exporter.md +7 -1
- package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +263 -0
- package/.docs/reference/observability/tracing/exporters/mastra-storage-exporter.md +194 -0
- package/.docs/reference/observability/tracing/exporters/otel.md +12 -8
- package/.docs/reference/observability/tracing/instances.md +2 -2
- package/.docs/reference/observability/tracing/interfaces.md +37 -2
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +22 -0
- package/.docs/reference/observability/tracing/span-filtering.md +2 -2
- package/.docs/reference/processors/prefill-error-handler.md +3 -3
- package/.docs/reference/processors/response-cache.md +114 -0
- package/.docs/reference/processors/tool-call-filter.md +28 -0
- package/.docs/reference/storage/clickhouse.md +8 -8
- package/.docs/reference/storage/cloudflare-d1.md +1 -1
- package/.docs/reference/storage/cloudflare.md +1 -1
- package/.docs/reference/storage/composite.md +1 -1
- package/.docs/reference/storage/convex.md +1 -1
- package/.docs/reference/storage/dsql.md +428 -0
- package/.docs/reference/storage/duckdb.md +3 -3
- package/.docs/reference/storage/dynamodb.md +1 -1
- package/.docs/reference/storage/lance.md +1 -1
- package/.docs/reference/storage/libsql.md +1 -1
- package/.docs/reference/storage/postgresql.md +1 -1
- package/.docs/reference/storage/upstash.md +1 -1
- package/.docs/reference/streaming/ChunkType.md +44 -0
- package/.docs/reference/tools/brightdata.md +167 -0
- package/.docs/reference/tools/create-tool.md +46 -0
- package/.docs/reference/voice/inworld.md +133 -0
- package/.docs/reference/workflows/workflow-state-reader.md +113 -0
- package/CHANGELOG.md +106 -0
- package/package.json +5 -5
|
@@ -94,6 +94,89 @@ export const agent = new Agent({
|
|
|
94
94
|
})
|
|
95
95
|
```
|
|
96
96
|
|
|
97
|
+
## Thread signals
|
|
98
|
+
|
|
99
|
+
Use Agent signals to send real-time context into a memory thread. Signals are useful when a user adds input while an agent is already streaming, or when another process needs to add structured context to the thread.
|
|
100
|
+
|
|
101
|
+
A `user-message` signal represents user input. When the target thread is running, Mastra delivers the signal into the active agent loop. When the thread is idle, Mastra starts a stream with the signal as the first input by default.
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
const subscription = await agent.subscribeToThread({
|
|
105
|
+
resourceId: 'user-123',
|
|
106
|
+
threadId: 'thread-abc',
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
void (async () => {
|
|
110
|
+
for await (const chunk of subscription.stream) {
|
|
111
|
+
console.log(chunk)
|
|
112
|
+
}
|
|
113
|
+
})()
|
|
114
|
+
|
|
115
|
+
agent.sendSignal(
|
|
116
|
+
{ type: 'user-message', contents: 'Use the latest customer note too.' },
|
|
117
|
+
{
|
|
118
|
+
resourceId: 'user-123',
|
|
119
|
+
threadId: 'thread-abc',
|
|
120
|
+
ifIdle: {
|
|
121
|
+
streamOptions: {
|
|
122
|
+
maxSteps: 3,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Use a custom signal type for contextual messages that should reach the model as XML-wrapped context instead of normal user input:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
agent.sendSignal(
|
|
133
|
+
{
|
|
134
|
+
type: 'system-reminder',
|
|
135
|
+
contents: 'Continue from the previous tool result.',
|
|
136
|
+
attributes: { reminderType: 'tool-result' },
|
|
137
|
+
},
|
|
138
|
+
{ resourceId: 'user-123', threadId: 'thread-abc' },
|
|
139
|
+
)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### `sendSignal(signal, options)`
|
|
143
|
+
|
|
144
|
+
Sends a signal to an active run or memory thread.
|
|
145
|
+
|
|
146
|
+
**signal** (`{ type: 'user-message'; contents: MessageListInput } | { type: string; contents: string }`): \`user-message\` signals are treated as user input. Other signal types are converted to XML context before the next model call.
|
|
147
|
+
|
|
148
|
+
**options.runId** (`string`): Run ID to target directly. Use this when you already know the active run ID.
|
|
149
|
+
|
|
150
|
+
**options.resourceId** (`string`): Resource ID for the memory thread. Required with \`threadId\` for thread-targeted signals.
|
|
151
|
+
|
|
152
|
+
**options.threadId** (`string`): Thread ID to target. Required with \`resourceId\` for thread-targeted signals.
|
|
153
|
+
|
|
154
|
+
**options.ifActive.behavior** (`'deliver' | 'persist' | 'discard'`): Controls what happens when the target thread is active. Defaults to \`deliver\`.
|
|
155
|
+
|
|
156
|
+
**options.ifIdle.behavior** (`'wake' | 'persist' | 'discard'`): Controls what happens when the target thread is idle. Defaults to \`wake\`.
|
|
157
|
+
|
|
158
|
+
**options.ifIdle.streamOptions** (`AgentExecutionOptions`): Options for the stream that starts when \`ifIdle.behavior\` is \`wake\`. Mastra uses the top-level \`resourceId\` and \`threadId\` for memory context.
|
|
159
|
+
|
|
160
|
+
Returns `{ accepted: true, runId: string, signal: CreatedAgentSignal, persisted?: Promise<void> }`. `persisted` is only present for `persist` behavior and resolves when Mastra finishes writing the signal to memory.
|
|
161
|
+
|
|
162
|
+
### `subscribeToThread(options)`
|
|
163
|
+
|
|
164
|
+
Subscribes to raw stream chunks for a memory thread. Use this before calling `sendSignal()` when you need to render stream output, observe signal echoes, or abort the active run.
|
|
165
|
+
|
|
166
|
+
**options.resourceId** (`string`): Resource ID for the memory thread.
|
|
167
|
+
|
|
168
|
+
**options.threadId** (`string`): Thread ID to subscribe to.
|
|
169
|
+
|
|
170
|
+
Returns an `AgentThreadSubscription` object with these members:
|
|
171
|
+
|
|
172
|
+
**stream** (`AsyncIterable<AgentChunkType>`): Raw agent stream chunks for the subscribed thread.
|
|
173
|
+
|
|
174
|
+
**activeRunId** (`() => string | null`): Returns the active run ID for the thread, or \`null\` when no run is active.
|
|
175
|
+
|
|
176
|
+
**abort** (`() => boolean`): Aborts the active run for the thread. Returns \`true\` when a run was aborted.
|
|
177
|
+
|
|
178
|
+
**unsubscribe** (`() => void`): Stops the subscription without aborting the active run.
|
|
179
|
+
|
|
97
180
|
## Constructor parameters
|
|
98
181
|
|
|
99
182
|
**id** (`string`): Unique identifier for the agent. Defaults to \`name\` if not provided.
|
|
@@ -110,6 +193,8 @@ export const agent = new Agent({
|
|
|
110
193
|
|
|
111
194
|
**tools** (`ToolsInput | ({ requestContext: RequestContext }) => ToolsInput | Promise<ToolsInput>`): Tools that the agent can access. Can be provided statically or resolved dynamically.
|
|
112
195
|
|
|
196
|
+
**transform** (`ToolPayloadTransformPolicy`): Shared policy for transforming tool payloads before display streams or user-visible transcript messages receive them. Use per-tool \`transform\` on \`createTool()\` for tool-local rules.
|
|
197
|
+
|
|
113
198
|
**workflows** (`Record<string, Workflow> | ({ requestContext: RequestContext }) => Record<string, Workflow> | Promise<Record<string, Workflow>>`): Workflows that the agent can execute. Can be static or dynamically resolved.
|
|
114
199
|
|
|
115
200
|
**defaultOptions** (`AgentExecutionOptions | ({ requestContext: RequestContext }) => AgentExecutionOptions | Promise<AgentExecutionOptions>`): Default options used when calling \`stream()\` and \`generate()\`.
|
|
@@ -44,22 +44,25 @@ then interact with elements using their refs (e.g., @e5).`,
|
|
|
44
44
|
|
|
45
45
|
**screencast** (`ScreencastOptions`): Configuration for streaming browser frames to Studio.
|
|
46
46
|
|
|
47
|
+
**excludeTools** (`BrowserToolName[]`): Tool names to exclude from the browser toolset. Use this to disable specific tools for models that do not support certain capabilities, such as vision.
|
|
48
|
+
|
|
47
49
|
## Tools
|
|
48
50
|
|
|
49
|
-
`AgentBrowser` provides
|
|
51
|
+
`AgentBrowser` provides 16 deterministic tools for browser automation. All tools that interact with elements use refs from the accessibility tree snapshot.
|
|
50
52
|
|
|
51
53
|
### Core tools
|
|
52
54
|
|
|
53
|
-
| Tool
|
|
54
|
-
|
|
|
55
|
-
| `browser_goto`
|
|
56
|
-
| `browser_snapshot`
|
|
57
|
-
| `browser_click`
|
|
58
|
-
| `browser_type`
|
|
59
|
-
| `browser_press`
|
|
60
|
-
| `browser_select`
|
|
61
|
-
| `browser_scroll`
|
|
62
|
-
| `
|
|
55
|
+
| Tool | Description |
|
|
56
|
+
| -------------------- | ------------------------------------------------------------------------------------- |
|
|
57
|
+
| `browser_goto` | Navigate to a URL |
|
|
58
|
+
| `browser_snapshot` | Get accessibility tree snapshot with element refs |
|
|
59
|
+
| `browser_click` | Click an element by ref |
|
|
60
|
+
| `browser_type` | Type text into an element |
|
|
61
|
+
| `browser_press` | Press keyboard keys |
|
|
62
|
+
| `browser_select` | Select option from dropdown |
|
|
63
|
+
| `browser_scroll` | Scroll the page or element |
|
|
64
|
+
| `browser_screenshot` | Capture a screenshot as PNG (viewport by default; set `fullPage: true` for full page) |
|
|
65
|
+
| `browser_close` | Close the browser |
|
|
63
66
|
|
|
64
67
|
### Extended tools
|
|
65
68
|
|
|
@@ -73,6 +76,14 @@ then interact with elements using their refs (e.g., @e5).`,
|
|
|
73
76
|
| `browser_drag` | Drag and drop elements |
|
|
74
77
|
| `browser_evaluate` | Execute JavaScript in the page (escape hatch) |
|
|
75
78
|
|
|
79
|
+
To exclude specific tools, pass `excludeTools` in the constructor:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
const browser = new AgentBrowser({
|
|
83
|
+
excludeTools: ['browser_screenshot'],
|
|
84
|
+
})
|
|
85
|
+
```
|
|
86
|
+
|
|
76
87
|
## Tool reference
|
|
77
88
|
|
|
78
89
|
### `browser_goto`
|
|
@@ -339,6 +350,21 @@ Execute JavaScript in the page context. Use as an escape hatch when other tools
|
|
|
339
350
|
| `script` | `string` | JavaScript to execute (required) |
|
|
340
351
|
| `returnValue` | `boolean` | Whether to return the result (optional) |
|
|
341
352
|
|
|
353
|
+
### `browser_screenshot`
|
|
354
|
+
|
|
355
|
+
Capture a screenshot of the current page as PNG (viewport by default; set `fullPage: true` for full-page capture). Returns image content that vision-capable models can interpret directly. Use `browser_snapshot` when you only need text or structured data.
|
|
356
|
+
|
|
357
|
+
```text
|
|
358
|
+
// Viewport only (default)
|
|
359
|
+
|
|
360
|
+
// Full scrollable page
|
|
361
|
+
{ "fullPage": true }
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
| Parameter | Type | Description |
|
|
365
|
+
| ---------- | --------- | ---------------------------------------------------------------------------------------- |
|
|
366
|
+
| `fullPage` | `boolean` | Capture the full scrollable page instead of just the viewport (optional, default: false) |
|
|
367
|
+
|
|
342
368
|
### `browser_close`
|
|
343
369
|
|
|
344
370
|
Close the browser and clean up resources.
|
|
@@ -61,18 +61,29 @@ Use stagehand_extract to get data from pages.`,
|
|
|
61
61
|
|
|
62
62
|
**screencast** (`ScreencastOptions`): Configuration for streaming browser frames to Studio.
|
|
63
63
|
|
|
64
|
+
**excludeTools** (`StagehandToolName[]`): Tool names to exclude from the browser toolset. Use this to disable specific tools for models that do not support certain capabilities, such as vision.
|
|
65
|
+
|
|
64
66
|
## Tools
|
|
65
67
|
|
|
66
|
-
`StagehandBrowser` provides
|
|
68
|
+
`StagehandBrowser` provides 7 AI-powered tools for browser automation:
|
|
69
|
+
|
|
70
|
+
| Tool | Description |
|
|
71
|
+
| ---------------------- | ------------------------------------------------------------------------------------- |
|
|
72
|
+
| `stagehand_act` | Perform actions using natural language instructions |
|
|
73
|
+
| `stagehand_extract` | Extract structured data from pages |
|
|
74
|
+
| `stagehand_observe` | Discover actionable elements on a page |
|
|
75
|
+
| `stagehand_navigate` | Navigate to a URL |
|
|
76
|
+
| `stagehand_tabs` | Manage browser tabs |
|
|
77
|
+
| `stagehand_screenshot` | Capture a screenshot as PNG (viewport by default; set `fullPage: true` for full page) |
|
|
78
|
+
| `stagehand_close` | Close the browser |
|
|
67
79
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
| `stagehand_close` | Close the browser |
|
|
80
|
+
To exclude specific tools, pass `excludeTools` in the constructor:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
const browser = new StagehandBrowser({
|
|
84
|
+
excludeTools: ['stagehand_screenshot'],
|
|
85
|
+
})
|
|
86
|
+
```
|
|
76
87
|
|
|
77
88
|
## Tool reference
|
|
78
89
|
|
|
@@ -224,6 +235,21 @@ Manage browser tabs.
|
|
|
224
235
|
{ "action": "close", "index": 1 }
|
|
225
236
|
```
|
|
226
237
|
|
|
238
|
+
### `stagehand_screenshot`
|
|
239
|
+
|
|
240
|
+
Capture a screenshot of the current page as PNG (viewport by default; set `fullPage: true` for full-page capture). Returns image content that vision-capable models can interpret directly. Use `stagehand_observe` or `stagehand_extract` when you only need text or structured data.
|
|
241
|
+
|
|
242
|
+
```text
|
|
243
|
+
// Viewport only (default)
|
|
244
|
+
|
|
245
|
+
// Full scrollable page
|
|
246
|
+
{ "fullPage": true }
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
| Parameter | Type | Description |
|
|
250
|
+
| ---------- | --------- | ---------------------------------------------------------------------------------------- |
|
|
251
|
+
| `fullPage` | `boolean` | Capture the full scrollable page instead of just the viewport (optional, default: false) |
|
|
252
|
+
|
|
227
253
|
### `stagehand_close`
|
|
228
254
|
|
|
229
255
|
Close the browser and clean up resources.
|
|
@@ -464,10 +464,42 @@ mastra auth tokens revoke <token-id>
|
|
|
464
464
|
|
|
465
465
|
## `mastra lint`
|
|
466
466
|
|
|
467
|
-
The `mastra lint` command validates the structure and code of your Mastra project
|
|
467
|
+
The `mastra lint` command validates the structure and code of your Mastra project.
|
|
468
|
+
|
|
469
|
+
By default, `mastra lint` runs project checks against your source files and configuration. Use `--preflight` to also run bundle checks against `.mastra/output` before deployment.
|
|
470
|
+
|
|
471
|
+
```bash
|
|
472
|
+
mastra lint --preflight
|
|
473
|
+
```
|
|
468
474
|
|
|
469
475
|
It accepts [common flags](#common-flags).
|
|
470
476
|
|
|
477
|
+
### Flags
|
|
478
|
+
|
|
479
|
+
#### `--preflight`
|
|
480
|
+
|
|
481
|
+
Runs deployment preflight checks against the built Mastra output. This builds the project before checking it unless you also pass `--skip-build`.
|
|
482
|
+
|
|
483
|
+
#### `--skip-build`
|
|
484
|
+
|
|
485
|
+
Skips the build step and reuses the existing `.mastra/output` directory. This flag only applies when `--preflight` is set.
|
|
486
|
+
|
|
487
|
+
#### `--env-file <file>`
|
|
488
|
+
|
|
489
|
+
Uses the specified environment file for preflight validation. This flag only applies when `--preflight` is set.
|
|
490
|
+
|
|
491
|
+
#### `--strict`
|
|
492
|
+
|
|
493
|
+
Treats warnings as errors.
|
|
494
|
+
|
|
495
|
+
#### `--json`
|
|
496
|
+
|
|
497
|
+
Emits machine-readable JSON output.
|
|
498
|
+
|
|
499
|
+
#### `--debug`
|
|
500
|
+
|
|
501
|
+
Enables debug logs.
|
|
502
|
+
|
|
471
503
|
## `mastra scorers`
|
|
472
504
|
|
|
473
505
|
The `mastra scorers` command provides management capabilities for evaluation scorers that measure the quality, accuracy, and performance of AI-generated outputs.
|
|
@@ -151,6 +151,95 @@ for await (const part of uiMessageStream) {
|
|
|
151
151
|
}
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
+
### `sendSignal()`
|
|
155
|
+
|
|
156
|
+
Send a signal to an active agent run or memory thread. Use this with `subscribeToThread()` so the client can render the stream that wakes from, or receives, the signal.
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
const agent = mastraClient.getAgent('support-agent')
|
|
160
|
+
|
|
161
|
+
const result = await agent.sendSignal({
|
|
162
|
+
signal: {
|
|
163
|
+
type: 'user-message',
|
|
164
|
+
contents: 'Also consider the customer note I just added.',
|
|
165
|
+
},
|
|
166
|
+
resourceId: 'user-123',
|
|
167
|
+
threadId: 'thread-abc',
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
console.log(result.runId)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Use `ifActive.behavior` and `ifIdle.behavior` to control whether Mastra delivers, persists, discards, or wakes from a signal:
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
await agent.sendSignal({
|
|
177
|
+
signal: { type: 'user-message', contents: 'Store this for later.' },
|
|
178
|
+
resourceId: 'user-123',
|
|
179
|
+
threadId: 'thread-abc',
|
|
180
|
+
ifIdle: {
|
|
181
|
+
behavior: 'persist',
|
|
182
|
+
},
|
|
183
|
+
})
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Pass `ifIdle.streamOptions` when the idle wake-up stream needs options such as model settings, tools, or runtime context:
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
await agent.sendSignal({
|
|
190
|
+
signal: { type: 'user-message', contents: 'Start from this signal.' },
|
|
191
|
+
resourceId: 'user-123',
|
|
192
|
+
threadId: 'thread-abc',
|
|
193
|
+
ifIdle: {
|
|
194
|
+
behavior: 'wake',
|
|
195
|
+
streamOptions: {
|
|
196
|
+
maxSteps: 3,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
})
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Returns `{ accepted: true, runId: string }`.
|
|
203
|
+
|
|
204
|
+
**signal** (`{ type: 'user-message'; contents: MessageListInput } | { type: string; contents: string }`): \`user-message\` signals are treated as user input. Other signal types are converted to contextual XML before the next model call.
|
|
205
|
+
|
|
206
|
+
**runId** (`string`): Run ID to target directly.
|
|
207
|
+
|
|
208
|
+
**resourceId** (`string`): Resource ID for the memory thread. Use with \`threadId\` for thread-targeted signals.
|
|
209
|
+
|
|
210
|
+
**threadId** (`string`): Thread ID to target. Use with \`resourceId\` for thread-targeted signals.
|
|
211
|
+
|
|
212
|
+
**ifActive.behavior** (`'deliver' | 'persist' | 'discard'`): Controls what happens when the target thread is active. Defaults to \`deliver\`.
|
|
213
|
+
|
|
214
|
+
**ifIdle.behavior** (`'wake' | 'persist' | 'discard'`): Controls what happens when the target thread is idle. Defaults to \`wake\`.
|
|
215
|
+
|
|
216
|
+
**ifIdle.streamOptions** (`Omit<AgentExecutionOptions, 'messages'>`): Options for the stream that starts when \`ifIdle.behavior\` is \`wake\`.
|
|
217
|
+
|
|
218
|
+
### `subscribeToThread()`
|
|
219
|
+
|
|
220
|
+
Subscribe to raw stream chunks for a memory thread. Use this to render output from a thread that may be started or continued by `sendSignal()`.
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
const agent = mastraClient.getAgent('support-agent')
|
|
224
|
+
|
|
225
|
+
const subscription = await agent.subscribeToThread({
|
|
226
|
+
resourceId: 'user-123',
|
|
227
|
+
threadId: 'thread-abc',
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
await subscription.processDataStream({
|
|
231
|
+
onChunk: async chunk => {
|
|
232
|
+
console.log(chunk)
|
|
233
|
+
},
|
|
234
|
+
})
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
`subscribeToThread()` returns the underlying `Response` plus a `processDataStream()` helper. The helper reads the subscription stream until the connection closes or the request is aborted.
|
|
238
|
+
|
|
239
|
+
**resourceId** (`string`): Resource ID for the memory thread.
|
|
240
|
+
|
|
241
|
+
**threadId** (`string`): Thread ID to subscribe to.
|
|
242
|
+
|
|
154
243
|
### `streamUntilIdle()`
|
|
155
244
|
|
|
156
245
|
Stream a response and keep the stream open until every [background task](https://mastra.ai/docs/agents/background-tasks) dispatched during the run completes. The server re-enters the agentic loop on each task completion so the LLM can react to results in the same call. Requires background tasks to be [enabled on the Mastra instance](https://mastra.ai/reference/configuration) and a memory thread; otherwise the call falls through to a plain `stream()`.
|
|
@@ -161,7 +250,7 @@ const response = await agent.streamUntilIdle('Research solana for me', {
|
|
|
161
250
|
thread: 'thread-1',
|
|
162
251
|
resource: 'resource-1',
|
|
163
252
|
},
|
|
164
|
-
maxIdleMs: 5 * 60_000,
|
|
253
|
+
maxIdleMs: 5 * 60_000, //optional
|
|
165
254
|
})
|
|
166
255
|
|
|
167
256
|
response.processDataStream({
|
|
@@ -173,6 +262,31 @@ response.processDataStream({
|
|
|
173
262
|
})
|
|
174
263
|
```
|
|
175
264
|
|
|
265
|
+
### `resumeStreamUntilIdle()`
|
|
266
|
+
|
|
267
|
+
Resume a suspended agent stream with custom data and keep the stream open until every [background task](https://mastra.ai/docs/agents/background-tasks) dispatched during the run completes. Use this to continue execution after a suspension point, such as a workflow suspend within an agent. Requires background tasks to be [enabled on the Mastra instance](https://mastra.ai/reference/configuration) and a memory thread; otherwise the call falls through to a plain `resumeStream()`:
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
const response = await agent.resumeStreamUntilIdle(
|
|
271
|
+
{ approved: true, selectedOption: 'plan-b' },
|
|
272
|
+
{
|
|
273
|
+
memory: {
|
|
274
|
+
thread: 'thread-1',
|
|
275
|
+
resource: 'resource-1',
|
|
276
|
+
},
|
|
277
|
+
runId: 'run-123',
|
|
278
|
+
toolCallId: 'tool-call-456', // optional
|
|
279
|
+
maxIdleMs: 5 * 60_000, //optional
|
|
280
|
+
},
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
await response.processDataStream({
|
|
284
|
+
onChunk: chunk => {
|
|
285
|
+
console.log(chunk)
|
|
286
|
+
},
|
|
287
|
+
})
|
|
288
|
+
```
|
|
289
|
+
|
|
176
290
|
The stream emits the same chunk types as `stream()`, plus `background-task-*` chunks for task lifecycle events. Visit [`Agent.streamUntilIdle()`](https://mastra.ai/reference/streaming/agents/streamUntilIdle) for the full server-side API and [background task chunks](https://mastra.ai/reference/streaming/ChunkType) for the payload shapes.
|
|
177
291
|
|
|
178
292
|
### `getTool()`
|
|
@@ -59,6 +59,8 @@ for await (const event of stream) {
|
|
|
59
59
|
}
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
+
Streaming responses can also include tool events. Tool-call streams use `response.output_item.added`, `response.function_call_arguments.delta`, `response.function_call_arguments.done`, and `response.output_item.done` events. Tool results appear as `function_call_output` items with `<toolCallId>:output` IDs.
|
|
63
|
+
|
|
62
64
|
**Returns:** `Promise<ResponsesStream>`.
|
|
63
65
|
|
|
64
66
|
#### `retrieve(responseId, requestContext?)`
|
|
@@ -130,6 +132,8 @@ Use [`client.conversations`](https://mastra.ai/reference/client-js/conversations
|
|
|
130
132
|
|
|
131
133
|
If the model calls a function, that activity appears in `response.output` as `function_call` and `function_call_output` items alongside the final assistant `message`.
|
|
132
134
|
|
|
135
|
+
When `stream: true`, function calls are also emitted as Responses stream events. Read `response.function_call_arguments.delta` events for partial argument chunks and prefer `response.function_call_arguments.done` for the finalized arguments payload and tool name. Read `response.output_item.done` events for completed `function_call` and `function_call_output` items. Tool output items use `<toolCallId>:output` IDs.
|
|
136
|
+
|
|
133
137
|
## Structured output
|
|
134
138
|
|
|
135
139
|
Use `text.format` when you want JSON output.
|
|
@@ -175,20 +175,20 @@ Custom ID generator function for creating unique identifiers. Mastra passes opti
|
|
|
175
175
|
> **Warning:** This is used internally by Mastra for creating IDs for workflow runs, agent conversations, and other resources. Most users won't need to configure this option.
|
|
176
176
|
|
|
177
177
|
```typescript
|
|
178
|
+
import { v4 as uuid } from '@lukeed/uuid'
|
|
178
179
|
import { Mastra } from '@mastra/core'
|
|
179
|
-
import { nanoid } from 'nanoid'
|
|
180
180
|
|
|
181
181
|
export const mastra = new Mastra({
|
|
182
182
|
idGenerator: context => {
|
|
183
183
|
if (context?.idType === 'message' && context?.threadId) {
|
|
184
|
-
return `msg-${context.threadId}-${
|
|
184
|
+
return `msg-${context.threadId}-${uuid()}`
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
if (context?.idType === 'run' && context?.source && context?.entityId) {
|
|
188
|
-
return `${context.source}-run-${context.entityId}-${
|
|
188
|
+
return `${context.source}-run-${context.entityId}-${uuid()}`
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
return
|
|
191
|
+
return uuid()
|
|
192
192
|
},
|
|
193
193
|
})
|
|
194
194
|
```
|
|
@@ -277,7 +277,7 @@ Visit the [Observability documentation](https://mastra.ai/docs/observability/ove
|
|
|
277
277
|
```typescript
|
|
278
278
|
import { Mastra } from '@mastra/core'
|
|
279
279
|
import { LibSQLStore } from '@mastra/libsql'
|
|
280
|
-
import { Observability,
|
|
280
|
+
import { Observability, MastraStorageExporter } from '@mastra/observability'
|
|
281
281
|
|
|
282
282
|
export const mastra = new Mastra({
|
|
283
283
|
storage: new LibSQLStore({
|
|
@@ -288,7 +288,7 @@ export const mastra = new Mastra({
|
|
|
288
288
|
configs: {
|
|
289
289
|
default: {
|
|
290
290
|
serviceName: 'my-app',
|
|
291
|
-
exporters: [new
|
|
291
|
+
exporters: [new MastraStorageExporter()],
|
|
292
292
|
},
|
|
293
293
|
},
|
|
294
294
|
}),
|
|
@@ -14,7 +14,7 @@ Tool providers implement these methods:
|
|
|
14
14
|
|
|
15
15
|
**getToolSchema(slug)** (`(slug: string) => Promise<JSONSchema>`): Returns the JSON schema for a specific tool identified by its slug.
|
|
16
16
|
|
|
17
|
-
**resolveTools(slugs, options?)** (`(slugs: string[], options?) => Promise<Record<string, ToolAction>>`): Resolves tool slugs into executable Mastra tool actions.
|
|
17
|
+
**resolveTools(slugs, options?)** (`(slugs: string[], options?) => Promise<Record<string, ToolAction>>`): Resolves tool slugs into executable Mastra tool actions. Built-in providers use resourceId from request context for per-user authentication.
|
|
18
18
|
|
|
19
19
|
***
|
|
20
20
|
|
|
@@ -47,7 +47,7 @@ Composio tools use uppercase slug format: `GITHUB_CREATE_ISSUE`, `SLACK_SEND_MES
|
|
|
47
47
|
|
|
48
48
|
### Authentication
|
|
49
49
|
|
|
50
|
-
Tool execution is scoped to
|
|
50
|
+
Tool execution is scoped to the `resourceId` passed through request context. The provider maps that value to the user identity required by Composio's auth flow.
|
|
51
51
|
|
|
52
52
|
***
|
|
53
53
|
|
|
@@ -82,4 +82,4 @@ Arcade tools use `Toolkit.ToolName` format: `Github.GetRepository`, `Slack.SendM
|
|
|
82
82
|
|
|
83
83
|
### Authentication
|
|
84
84
|
|
|
85
|
-
Like Composio, tool execution
|
|
85
|
+
Like Composio, tool execution uses `resourceId` from request context for per-user authorization. The provider maps that value to the user identity required by Arcade's auth flow.
|
|
@@ -98,7 +98,7 @@ await harness.sendMessage({ content: 'Hello!' })
|
|
|
98
98
|
|
|
99
99
|
**omConfig** (`HarnessOMConfig`): Default configuration for observational memory (observer/reflector model IDs and thresholds).
|
|
100
100
|
|
|
101
|
-
**disableBuiltinTools** (`BuiltinToolId[]`): Built-in harness tool IDs to remove from the \`harnessBuiltIn\` toolset. Valid values are \`ask\_user\`, \`submit\_plan\`, \`task\_write\`, \`task\_check\`, and \`subagent\`.
|
|
101
|
+
**disableBuiltinTools** (`BuiltinToolId[]`): Built-in harness tool IDs to remove from the \`harnessBuiltIn\` toolset. Valid values are \`ask\_user\`, \`submit\_plan\`, \`task\_write\`, \`task\_update\`, \`task\_complete\`, \`task\_check\`, and \`subagent\`.
|
|
102
102
|
|
|
103
103
|
**heartbeatHandlers** (`HeartbeatHandler[]`): Periodic background tasks started during \`init()\`. Use for gateway sync, cache refresh, and similar tasks.
|
|
104
104
|
|
|
@@ -162,6 +162,17 @@ Return the current `HarnessDisplayState` snapshot for UI rendering.
|
|
|
162
162
|
const displayState = harness.getDisplayState()
|
|
163
163
|
```
|
|
164
164
|
|
|
165
|
+
#### `restoreDisplayTasks(tasks)`
|
|
166
|
+
|
|
167
|
+
Restore the task portion of `HarnessDisplayState` after a UI replays persisted task tool history. This emits `display_state_changed` without emitting a live `task_updated` event.
|
|
168
|
+
|
|
169
|
+
If later task tools should read the replayed tasks, persist the same task list with `setState({ tasks })` before calling `restoreDisplayTasks(tasks)`.
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
await harness.setState({ tasks: replayedTasks })
|
|
173
|
+
harness.restoreDisplayTasks(replayedTasks)
|
|
174
|
+
```
|
|
175
|
+
|
|
165
176
|
#### `setState(updates)`
|
|
166
177
|
|
|
167
178
|
Update the harness state. Validates against `stateSchema` if provided, and emits a `state_changed` event with the new state and changed keys.
|
|
@@ -831,13 +842,15 @@ The harness emits events through registered listeners. The following table lists
|
|
|
831
842
|
|
|
832
843
|
The harness provides built-in tools to agents in every mode:
|
|
833
844
|
|
|
834
|
-
| Tool
|
|
835
|
-
|
|
|
836
|
-
| `ask_user`
|
|
837
|
-
| `submit_plan`
|
|
838
|
-
| `task_write`
|
|
839
|
-
| `
|
|
840
|
-
| `
|
|
845
|
+
| Tool | Description |
|
|
846
|
+
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
847
|
+
| `ask_user` | Ask the user a question and wait for their response. Supports free text, single-select choices, and multi-select choices. |
|
|
848
|
+
| `submit_plan` | Submit a plan for user review and approval. |
|
|
849
|
+
| `task_write` | Create or replace a structured task list for tracking progress. Assigns task IDs when omitted and returns the structured task list snapshot. |
|
|
850
|
+
| `task_update` | Update one tracked task by ID and return the structured task list snapshot. |
|
|
851
|
+
| `task_complete` | Mark one tracked task completed by ID and return the structured task list snapshot. |
|
|
852
|
+
| `task_check` | Check the completion status of the current task list and return `tasks`, `summary`, `incompleteTasks`, and `isError` fields. |
|
|
853
|
+
| `subagent` | Spawn a focused subagent with constrained tools (only available when `subagents` is configured). Pass `forked: true` to inherit the parent conversation — see [Forked subagents](#forked-subagents). |
|
|
841
854
|
|
|
842
855
|
### `ask_user` selections
|
|
843
856
|
|
package/.docs/reference/index.md
CHANGED
|
@@ -170,6 +170,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
170
170
|
- [PromptInjectionDetector](https://mastra.ai/reference/processors/prompt-injection-detector)
|
|
171
171
|
- [ProviderHistoryCompat](https://mastra.ai/reference/processors/provider-history-compat)
|
|
172
172
|
- [RegexFilterProcessor](https://mastra.ai/reference/processors/regex-filter-processor)
|
|
173
|
+
- [ResponseCache](https://mastra.ai/reference/processors/response-cache)
|
|
173
174
|
- [SemanticRecall](https://mastra.ai/reference/processors/semantic-recall-processor)
|
|
174
175
|
- [SkillSearchProcessor](https://mastra.ai/reference/processors/skill-search-processor)
|
|
175
176
|
- [StreamErrorRetryProcessor](https://mastra.ai/reference/processors/stream-error-retry-processor)
|
|
@@ -198,6 +199,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
198
199
|
- [registerApiRoute()](https://mastra.ai/reference/server/register-api-route)
|
|
199
200
|
- [Server Routes](https://mastra.ai/reference/server/routes)
|
|
200
201
|
- [Overview](https://mastra.ai/reference/storage/overview)
|
|
202
|
+
- [Aurora DSQL Storage](https://mastra.ai/reference/storage/dsql)
|
|
201
203
|
- [ClickHouse Storage](https://mastra.ai/reference/storage/clickhouse)
|
|
202
204
|
- [Cloudflare D1 Storage](https://mastra.ai/reference/storage/cloudflare-d1)
|
|
203
205
|
- [Cloudflare KV Storage](https://mastra.ai/reference/storage/cloudflare)
|
|
@@ -222,6 +224,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
222
224
|
- [.stream()](https://mastra.ai/reference/streaming/workflows/stream)
|
|
223
225
|
- [.timeTravelStream()](https://mastra.ai/reference/streaming/workflows/timeTravelStream)
|
|
224
226
|
- [Overview](https://mastra.ai/reference/templates/overview)
|
|
227
|
+
- [Bright Data Tools](https://mastra.ai/reference/tools/brightdata)
|
|
225
228
|
- [createDocumentChunkerTool()](https://mastra.ai/reference/tools/document-chunker-tool)
|
|
226
229
|
- [createGraphRAGTool()](https://mastra.ai/reference/tools/graph-rag-tool)
|
|
227
230
|
- [createTool()](https://mastra.ai/reference/tools/create-tool)
|
|
@@ -256,6 +259,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
256
259
|
- [Events](https://mastra.ai/reference/voice/voice.events)
|
|
257
260
|
- [Google](https://mastra.ai/reference/voice/google)
|
|
258
261
|
- [Google Gemini Live](https://mastra.ai/reference/voice/google-gemini-live)
|
|
262
|
+
- [Inworld](https://mastra.ai/reference/voice/inworld)
|
|
259
263
|
- [Mastra Voice](https://mastra.ai/reference/voice/mastra-voice)
|
|
260
264
|
- [Murf](https://mastra.ai/reference/voice/murf)
|
|
261
265
|
- [OpenAI](https://mastra.ai/reference/voice/openai)
|
|
@@ -278,6 +282,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
278
282
|
- [Run Class](https://mastra.ai/reference/workflows/run)
|
|
279
283
|
- [Step Class](https://mastra.ai/reference/workflows/step)
|
|
280
284
|
- [Workflow Class](https://mastra.ai/reference/workflows/workflow)
|
|
285
|
+
- [Workflow State Reader](https://mastra.ai/reference/workflows/workflow-state-reader)
|
|
281
286
|
- [.branch()](https://mastra.ai/reference/workflows/workflow-methods/branch)
|
|
282
287
|
- [.commit()](https://mastra.ai/reference/workflows/workflow-methods/commit)
|
|
283
288
|
- [.createRun()](https://mastra.ai/reference/workflows/workflow-methods/create-run)
|
|
@@ -36,7 +36,9 @@ OM performs thresholding with fast local token estimation. Text uses `tokenx`, a
|
|
|
36
36
|
|
|
37
37
|
**scope** (`'resource' | 'thread'`): Memory scope for observations. \`'thread'\` keeps observations per-thread. \`'resource'\` (experimental) shares observations across all threads for a resource, enabling cross-conversation memory. (Default: `'thread'`)
|
|
38
38
|
|
|
39
|
-
**activateAfterIdle** (`number | string`): Time before buffered observations
|
|
39
|
+
**activateAfterIdle** (`number | string | false`): Time before buffered observations are forced to activate after inactivity, even before \`observation.messageTokens\` is reached. Accepts a numeric millisecond value such as \`300\_000\`, duration strings like \`"5m"\` or \`"1hr"\`, or \`false\` to disable inherited observation idle activation. Reflections do not inherit this setting. Use \`reflection.activateAfterIdle\` to opt reflections into idle activation.
|
|
40
|
+
|
|
41
|
+
**activateOnProviderChange** (`boolean`): Force buffered observations to activate when the actor provider or model changes. Reflections do not inherit this setting. Use \`reflection.activateOnProviderChange\` to opt reflections into provider-change activation. (Default: `false`)
|
|
40
42
|
|
|
41
43
|
**shareTokenBudget** (`boolean`): Share the token budget between messages and observations. When enabled, the total budget is \`observation.messageTokens + reflection.observationTokens\`. Messages can use more space when observations are small, and vice versa. This maximizes context usage through flexible allocation. \`shareTokenBudget\` is not yet compatible with async buffering. You must set \`observation: { bufferTokens: false }\` when using this option (this is a temporary limitation). (Default: `false`)
|
|
42
44
|
|
|
@@ -66,6 +68,10 @@ OM performs thresholding with fast local token estimation. Text uses `tokenx`, a
|
|
|
66
68
|
|
|
67
69
|
**observation.bufferActivation** (`number`): Controls how much of the message window to retain after activation. Accepts a ratio (0-1) or an absolute token count (≥ 1000). For example, \`0.8\` means: activate enough buffers to remove 80% of \`messageTokens\` and leave 20% as active message history. An absolute token count like \`4000\` targets a goal of keeping \~4k message tokens remaining after activation. Higher values remove more message history per activation when using a ratio. Higher values keep more message history when using a token count.
|
|
68
70
|
|
|
71
|
+
**observation.activateAfterIdle** (`number | string | false`): Time before buffered observations are forced to activate after inactivity. Accepts milliseconds, a duration string, or \`false\`. If unset, the top-level \`activateAfterIdle\` value is used for observations. Set \`false\` to disable the top-level idle setting for observations.
|
|
72
|
+
|
|
73
|
+
**observation.activateOnProviderChange** (`boolean`): Force buffered observations to activate when the actor provider or model changes. If unset, the top-level \`activateOnProviderChange\` value is used for observations.
|
|
74
|
+
|
|
69
75
|
**observation.blockAfter** (`number`): Token threshold above which synchronous (blocking) observation is forced. Between \`messageTokens\` and \`blockAfter\`, only async buffering/activation is used. Above \`blockAfter\`, a synchronous observation runs as a last resort, while buffered activation still preserves a minimum remaining context (min(1000, retention floor)). Accepts a multiplier (1 < value < 2, multiplied by \`messageTokens\`) or an absolute token count (≥ 2, must be greater than \`messageTokens\`). Only relevant when \`bufferTokens\` is set. Defaults to \`1.2\` when async buffering is enabled.
|
|
70
76
|
|
|
71
77
|
**observation.previousObserverTokens** (`number | false`): Optional token budget for the observer's previous-observations context. When set to a number, the observations passed to the Observer agent are tail-truncated to fit within this budget while keeping the newest observations and preserving highlighted 🔴 items when possible. When a buffered reflection is pending, the already-reflected observation lines are automatically replaced with the reflection summary before truncation. Set to \`0\` to omit previous observations entirely, or \`false\` to disable truncation explicitly.
|
|
@@ -86,6 +92,10 @@ OM performs thresholding with fast local token estimation. Text uses `tokenx`, a
|
|
|
86
92
|
|
|
87
93
|
**reflection.bufferActivation** (`number`): Ratio (0-1) controlling when async reflection buffering starts. When observation tokens reach \`observationTokens \* bufferActivation\`, reflection runs in the background. On activation at the full threshold, the buffered reflection replaces the observations it covers, preserving any new observations appended after that range.
|
|
88
94
|
|
|
95
|
+
**reflection.activateAfterIdle** (`number | string | false`): Time before buffered reflections are forced to activate after inactivity. Accepts milliseconds, a duration string, or \`false\`. Reflections do not inherit top-level \`activateAfterIdle\`; set this explicitly to opt reflections into idle activation.
|
|
96
|
+
|
|
97
|
+
**reflection.activateOnProviderChange** (`boolean`): Force buffered reflections to activate when the actor provider or model changes. Reflections do not inherit top-level \`activateOnProviderChange\`; set this explicitly to opt reflections into provider-change activation.
|
|
98
|
+
|
|
89
99
|
**reflection.blockAfter** (`number`): Token threshold above which synchronous (blocking) reflection is forced. Between \`observationTokens\` and \`blockAfter\`, only async buffering/activation is used. Above \`blockAfter\`, a synchronous reflection runs as a last resort. Accepts a multiplier (1 < value < 2, multiplied by \`observationTokens\`) or an absolute token count (≥ 2, must be greater than \`observationTokens\`). Only relevant when \`bufferActivation\` is set. Defaults to \`1.2\` when async reflection is enabled.
|
|
90
100
|
|
|
91
101
|
### Token estimate metadata cache
|