@mastra/mcp-docs-server 1.2.16-alpha.3 → 1.2.16-alpha.6
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/docs/agents/a2a.md +1 -1
- package/.docs/docs/agents/guardrails.md +11 -10
- package/.docs/docs/agents/overview.md +2 -0
- package/.docs/docs/agents/processors.md +8 -8
- package/.docs/docs/agents/structured-output.md +1 -1
- package/.docs/docs/agents/using-tools.md +51 -12
- package/.docs/docs/browser/overview.md +22 -3
- package/.docs/docs/capabilities/subagents.md +2 -2
- package/.docs/docs/datasets/running-experiments.md +2 -2
- package/.docs/docs/deployment/overview.md +3 -3
- package/.docs/docs/deployment/sandbox.md +1 -1
- package/.docs/docs/deployment/workers.md +5 -5
- package/.docs/docs/deployment/workflow-runners.md +1 -1
- package/.docs/docs/editor/overview.md +3 -1
- package/.docs/docs/evals/custom-scorers.md +1 -1
- package/.docs/docs/evals/multi-turn.md +1 -1
- package/.docs/docs/evals/overview.md +3 -3
- package/.docs/docs/getting-started/develop.md +1 -1
- package/.docs/docs/harness/agent-controller.md +2 -2
- package/.docs/docs/harness/overview.md +1 -1
- package/.docs/docs/long-running-agents/background-tasks.md +2 -2
- package/.docs/docs/long-running-agents/goals.md +3 -2
- package/.docs/docs/long-running-agents/signals.md +2 -2
- package/.docs/docs/mastra-platform/deploy.md +1 -1
- package/.docs/docs/mastra-platform/github.md +1 -1
- package/.docs/docs/mastra-platform/observability.md +1 -1
- package/.docs/docs/mastra-platform/overview.md +3 -3
- package/.docs/docs/mastra-platform/server.md +2 -2
- package/.docs/docs/mastra-platform/trace-intelligence.md +3 -3
- package/.docs/docs/memory/memory-processors.md +1 -1
- package/.docs/docs/memory/message-history.md +2 -2
- package/.docs/docs/memory/observational-memory.md +13 -13
- package/.docs/docs/memory/semantic-recall.md +1 -1
- package/.docs/docs/memory/working-memory.md +1 -1
- package/.docs/docs/observability/logging.md +1 -1
- package/.docs/docs/observability/metrics/querying.md +1 -1
- package/.docs/docs/observability/tracing/overview.md +3 -3
- package/.docs/docs/server/custom-adapters.md +2 -2
- package/.docs/docs/server/custom-api-routes.md +1 -1
- package/.docs/docs/server/mastra-client.md +1 -1
- package/.docs/docs/server/server-adapters.md +1 -1
- package/.docs/docs/studio/deployment.md +2 -2
- package/.docs/docs/studio/observability.md +1 -1
- package/.docs/docs/studio/overview.md +2 -0
- package/.docs/docs/workflows/dynamic-workflows.md +1 -1
- package/.docs/docs/workflows/scheduled-workflows.md +1 -1
- package/.docs/docs/workflows/suspend-and-resume.md +1 -1
- package/.docs/docs/workspace/overview.md +2 -1
- package/.docs/docs/workspace/search.md +1 -1
- package/.docs/docs/workspace/skills.md +1 -1
- package/.docs/integrations/browsers/agent-browser.md +2 -3
- package/.docs/integrations/browsers/firecrawl.md +0 -1
- package/.docs/integrations/browsers/stagehand.md +2 -3
- package/.docs/models/gateways/openrouter.md +1 -2
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/kilo.md +6 -7
- package/.docs/models/providers/nano-gpt.md +2 -1
- package/.docs/reference/acp/acp-agent.md +1 -1
- package/.docs/reference/agent-controller/session.md +1 -1
- package/.docs/reference/agents/channels.md +1 -1
- package/.docs/reference/agents/inngest-agent.md +1 -1
- package/.docs/reference/ai-sdk/overview.md +1 -1
- package/.docs/reference/auth/auth0.md +1 -1
- package/.docs/reference/auth/google.md +1 -1
- package/.docs/reference/browser/agent-browser.md +2 -2
- package/.docs/reference/browser/browser-viewer.md +1 -1
- package/.docs/reference/browser/stagehand-browser.md +2 -2
- package/.docs/reference/channels/channel-provider.md +1 -1
- package/.docs/reference/channels/slack-provider.md +1 -1
- package/.docs/reference/cli/mastra.md +5 -5
- package/.docs/reference/code-sdk/mount-agent-controller.md +1 -1
- package/.docs/reference/coding-agent/build-base-prompt.md +2 -1
- package/.docs/reference/configuration.md +3 -3
- package/.docs/reference/core/getAgentById.md +1 -1
- package/.docs/reference/core/getWorkflow.md +2 -2
- package/.docs/reference/core/mastra-class.md +1 -1
- package/.docs/reference/deployer/netlify.md +1 -1
- package/.docs/reference/deployer.md +1 -1
- package/.docs/reference/editor/prompt-blocks.md +1 -1
- package/.docs/reference/editor/tools.md +1 -1
- package/.docs/reference/evals/completeness.md +1 -1
- package/.docs/reference/evals/noise-sensitivity.md +1 -1
- package/.docs/reference/evals/summarization.md +1 -1
- package/.docs/reference/file-based-agents/config.md +1 -1
- package/.docs/reference/file-based-agents/skills.md +5 -5
- package/.docs/reference/file-based-agents/workspace.md +1 -1
- package/.docs/reference/index.md +1 -1
- package/.docs/reference/logging/pino-logger.md +1 -1
- package/.docs/reference/memory/observational-memory.md +12 -4
- package/.docs/reference/migrations/upgrade-to-v1/agent.md +3 -3
- package/.docs/reference/migrations/upgrade-to-v1/client.md +1 -1
- package/.docs/reference/migrations/upgrade-to-v1/evals.md +1 -1
- package/.docs/reference/migrations/upgrade-to-v1/mastra.md +1 -1
- package/.docs/reference/migrations/upgrade-to-v1/mcp.md +1 -1
- package/.docs/reference/migrations/upgrade-to-v1/overview.md +1 -1
- package/.docs/reference/migrations/upgrade-to-v1/processors.md +1 -1
- package/.docs/reference/migrations/upgrade-to-v1/storage.md +5 -5
- package/.docs/reference/migrations/upgrade-to-v1/tools.md +1 -1
- package/.docs/reference/observability/tracing/bridges/datadog.md +1 -1
- package/.docs/reference/observability/tracing/bridges/otel.md +1 -1
- package/.docs/reference/observability/tracing/exporters/arize.md +1 -1
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +2 -2
- package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +1 -1
- package/.docs/reference/observability/tracing/exporters/otel.md +1 -1
- package/.docs/reference/observability/tracing/exporters/sentry.md +1 -1
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +27 -3
- package/.docs/reference/processors/batch-parts-processor.md +1 -1
- package/.docs/reference/processors/language-detector.md +1 -2
- package/.docs/reference/processors/processor-interface.md +16 -16
- package/.docs/reference/processors/stream-error-retry-processor.md +2 -2
- package/.docs/reference/processors/token-cost-control.md +154 -0
- package/.docs/reference/rag/chunking-and-embedding.md +1 -1
- package/.docs/reference/rag/metadata-filters.md +1 -1
- package/.docs/reference/server/koa-adapter.md +1 -1
- package/.docs/reference/signals/webhook-signal-provider.md +1 -1
- package/.docs/reference/storage/retention.md +1 -1
- package/.docs/reference/tools/bedrock-kb-tool.md +1 -1
- package/.docs/reference/tools/mcp-client.md +3 -3
- package/.docs/reference/tools/mcp-server.md +5 -5
- package/.docs/reference/tools/task-tools.md +1 -1
- package/.docs/reference/tools/vector-query-tool.md +1 -1
- package/.docs/reference/vectors/chroma.md +1 -1
- package/.docs/reference/vectors/convex.md +1 -1
- package/.docs/reference/vectors/couchbase.md +1 -1
- package/.docs/reference/vectors/mongodb.md +2 -2
- package/.docs/reference/vectors/pg.md +1 -1
- package/.docs/reference/vectors/qdrant.md +2 -2
- package/.docs/reference/voice/overview.md +1 -1
- package/.docs/reference/voice/speech-to-speech.md +1 -1
- package/.docs/reference/voice/speech-to-text.md +1 -1
- package/.docs/reference/voice/voice.on.md +1 -1
- package/.docs/reference/voice/voice.updateConfig.md +1 -1
- package/.docs/reference/workspace/local-sandbox.md +1 -1
- package/.docs/reference/workspace/workspace-class.md +1 -1
- package/CHANGELOG.md +14 -0
- package/package.json +5 -5
- package/.docs/docs/browser/recording.md +0 -120
- package/.docs/reference/processors/cost-guard-processor.md +0 -115
package/.docs/docs/agents/a2a.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# A2A (Agent-to-Agent)
|
|
4
4
|
|
|
5
|
-
Mastra supports version 0.3.0 of the [Agent-to-Agent (A2A) protocol](https://a2a-protocol.org/latest/) for cross-platform multi-agent systems. Use A2A to expose Mastra agents as remote agents
|
|
5
|
+
Mastra supports version 0.3.0 of the [Agent-to-Agent (A2A) protocol](https://a2a-protocol.org/latest/) for cross-platform multi-agent systems. Use A2A to expose Mastra agents as remote agents or consume remote A2A agents as Mastra subagents. You can also call A2A endpoints with the JavaScript client SDK.
|
|
6
6
|
|
|
7
7
|
A2A is an open protocol for delegating work to agents across network, framework, vendor, and language boundaries. A remote agent keeps its own tools, prompts, memory, workflows, and infrastructure private while exposing a protocol endpoint that other systems can discover and call.
|
|
8
8
|
|
|
@@ -188,16 +188,16 @@ Visit [`PIIDetector()`](https://mastra.ai/reference/processors/pii-detector) ref
|
|
|
188
188
|
|
|
189
189
|
### Enforce cost limits
|
|
190
190
|
|
|
191
|
-
The `
|
|
191
|
+
The `TokenCostControl()` monitors cumulative estimated cost across the agentic loop, blocking or warning when a monetary limit is exceeded. It queries cost data from observability storage before each LLM call. Cost checks are approximate, metrics are persisted asynchronously, so fast-running agents may briefly exceed the configured limit before the guard triggers.
|
|
192
192
|
|
|
193
193
|
```typescript
|
|
194
|
-
import {
|
|
194
|
+
import { TokenCostControl } from '@mastra/core/processors'
|
|
195
195
|
|
|
196
196
|
export const budgetedAgent = new Agent({
|
|
197
197
|
id: 'budgeted-agent',
|
|
198
198
|
name: 'Budgeted Agent',
|
|
199
199
|
inputProcessors: [
|
|
200
|
-
new
|
|
200
|
+
new TokenCostControl({
|
|
201
201
|
maxCost: 5.0,
|
|
202
202
|
scope: 'thread',
|
|
203
203
|
window: '24h',
|
|
@@ -206,7 +206,7 @@ export const budgetedAgent = new Agent({
|
|
|
206
206
|
})
|
|
207
207
|
```
|
|
208
208
|
|
|
209
|
-
Visit [`
|
|
209
|
+
Visit [`TokenCostControl()`](https://mastra.ai/reference/processors/token-cost-control) reference for scoping modes, time windows, metric persistence delays, and the `onViolation` callback. Requires observability storage with `getMetricAggregate` support.
|
|
210
210
|
|
|
211
211
|
## Processor strategies
|
|
212
212
|
|
|
@@ -232,18 +232,19 @@ All processors support an `onViolation` callback that fires when a policy violat
|
|
|
232
232
|
The callback receives a `ProcessorViolation` object with `processorId`, `message`, and `detail` (processor-specific metadata).
|
|
233
233
|
|
|
234
234
|
```typescript
|
|
235
|
-
import {
|
|
235
|
+
import { TokenCostControl, ModerationProcessor, PIIDetector } from '@mastra/core/processors'
|
|
236
236
|
|
|
237
237
|
// Alert when cost limits are exceeded
|
|
238
|
-
const
|
|
238
|
+
const tokenCostControl = new TokenCostControl({
|
|
239
239
|
maxCost: 10.0,
|
|
240
240
|
scope: 'resource',
|
|
241
241
|
window: '30d',
|
|
242
|
+
strategy: 'warn',
|
|
242
243
|
})
|
|
243
244
|
|
|
244
|
-
|
|
245
|
+
tokenCostControl.onViolation = ({ processorId, message, detail }) => {
|
|
245
246
|
alertSystem.notify(`[${processorId}] ${message}`)
|
|
246
|
-
// detail contains: { usage, limit, totalUsage, scope, scopeKey }
|
|
247
|
+
// detail contains: { usage, limit, totalUsage, scope, scopeKey, threshold }
|
|
247
248
|
}
|
|
248
249
|
|
|
249
250
|
// Log moderation violations
|
|
@@ -257,9 +258,9 @@ moderation.onViolation = ({ processorId, message, detail }) => {
|
|
|
257
258
|
}
|
|
258
259
|
```
|
|
259
260
|
|
|
260
|
-
The `onViolation` property is part of the base [`Processor` interface](https://mastra.ai/reference/processors/processor-interface), so any processor, including custom ones, can use it. The runner automatically invokes `onViolation` when any processor calls `abort()`. For processors using a `warn` strategy (like `
|
|
261
|
+
The `onViolation` property is part of the base [`Processor` interface](https://mastra.ai/reference/processors/processor-interface), so any processor, including custom ones, can use it. The runner automatically invokes `onViolation` when any processor calls `abort()`. For processors using a `warn` strategy (like `TokenCostControl`), the callback also fires on warnings without blocking the request.
|
|
261
262
|
|
|
262
|
-
Errors thrown by
|
|
263
|
+
Errors thrown by runner-invoked callbacks after `abort()` are silently caught to prevent interfering with the processor's main logic. On the `TokenCostControl` warning path, callback errors are caught and logged through the Mastra logger.
|
|
263
264
|
|
|
264
265
|
For more on how violation callbacks integrate with the processor pipeline, see [Violation callbacks](https://mastra.ai/docs/agents/processors) in the Processors documentation.
|
|
265
266
|
|
|
@@ -160,6 +160,8 @@ Once registered, it can be called from workflows, tools, or other agents, and ha
|
|
|
160
160
|
Visit the [agent reference](https://mastra.ai/reference/agents/agent) for more information on available properties and configurations.
|
|
161
161
|
|
|
162
162
|
> **Tip:** Use [Studio](https://mastra.ai/docs/studio/overview) to test your agent with different messages and inspect tool calls and responses, plus debug agent behavior.
|
|
163
|
+
>
|
|
164
|
+
> Use [Agent Builder](https://agent-builder.mastra.ai) to create and manage a fully stored agent through a browser instead of defining it in TypeScript.
|
|
163
165
|
|
|
164
166
|
## Use your agent
|
|
165
167
|
|
|
@@ -494,7 +494,7 @@ These fields are overridable per call:
|
|
|
494
494
|
|
|
495
495
|
### Tenant scoping
|
|
496
496
|
|
|
497
|
-
By default, `ResponseCache` looks up `MASTRA_RESOURCE_ID_KEY` on the request context and uses it as the cache scope.
|
|
497
|
+
By default, `ResponseCache` looks up `MASTRA_RESOURCE_ID_KEY` on the request context and uses it as the cache scope. An agent that already populates the resource id (e.g. via memory) gets per-user isolation automatically. Users never see each other's cached responses.
|
|
498
498
|
|
|
499
499
|
Override explicitly when you need a different scope:
|
|
500
500
|
|
|
@@ -538,7 +538,7 @@ For a custom backend, extend `MastraServerCache` and implement its abstract meth
|
|
|
538
538
|
|
|
539
539
|
`ResponseCache` hooks into `processLLMRequest` (cache lookup, short-circuits on hit) and `processLLMResponse` (cache write on completion). Both run inside the agentic loop _after_ memory has loaded and earlier input processors have transformed the prompt.
|
|
540
540
|
|
|
541
|
-
|
|
541
|
+
The cache key is derived from the resolved `LanguageModelV2Prompt` Mastra is about to send to the model. The key is created _after_ memory has loaded and earlier input processors have run, and each step in an agentic tool loop is independently cached.
|
|
542
542
|
|
|
543
543
|
### What's in the cache key
|
|
544
544
|
|
|
@@ -785,7 +785,7 @@ For streaming, access metadata from the `finish` chunk payload or the `stream.re
|
|
|
785
785
|
|
|
786
786
|
### Use workflows as processors
|
|
787
787
|
|
|
788
|
-
You can use Mastra workflows as processors to create complex processing pipelines with parallel execution
|
|
788
|
+
You can use Mastra workflows as processors to create complex processing pipelines with parallel execution and conditional branching, plus error handling:
|
|
789
789
|
|
|
790
790
|
```typescript
|
|
791
791
|
import { createWorkflow, createStep } from '@mastra/core/workflows'
|
|
@@ -842,7 +842,7 @@ When an agent is registered with Mastra, processor workflows are automatically r
|
|
|
842
842
|
|
|
843
843
|
### Retry mechanism
|
|
844
844
|
|
|
845
|
-
Processors can request that the LLM retry its response with feedback. This is useful for implementing quality checks
|
|
845
|
+
Processors can request that the LLM retry its response with feedback. This is useful for implementing quality checks or output validation, including iterative refinement:
|
|
846
846
|
|
|
847
847
|
```typescript
|
|
848
848
|
import type { Processor } from '@mastra/core/processors'
|
|
@@ -892,7 +892,7 @@ For `StreamErrorRetryProcessor`, also set its `maxRetries` to the same value. It
|
|
|
892
892
|
All processors expose an `onViolation` property that fires whenever a policy violation is detected, both when `abort()` is called (block strategy) and when a processor issues a warning (warn strategy). Use it for alerting, logging, or side effects without affecting the processor's main logic:
|
|
893
893
|
|
|
894
894
|
```typescript
|
|
895
|
-
import { ModerationProcessor,
|
|
895
|
+
import { ModerationProcessor, TokenCostControl } from '@mastra/core/processors'
|
|
896
896
|
|
|
897
897
|
const moderation = new ModerationProcessor({
|
|
898
898
|
model: 'openai/gpt-5-nano',
|
|
@@ -904,13 +904,13 @@ moderation.onViolation = ({ processorId, message, detail }) => {
|
|
|
904
904
|
monitor.track('processor_violation', { processorId, message, detail })
|
|
905
905
|
}
|
|
906
906
|
|
|
907
|
-
const
|
|
907
|
+
const tokenCostControl = new TokenCostControl({
|
|
908
908
|
maxCost: 10.0,
|
|
909
909
|
scope: 'resource',
|
|
910
910
|
window: '30d',
|
|
911
911
|
})
|
|
912
912
|
|
|
913
|
-
|
|
913
|
+
tokenCostControl.onViolation = ({ processorId, message, detail }) => {
|
|
914
914
|
alertSystem.notify(`[${processorId}] ${message}`)
|
|
915
915
|
}
|
|
916
916
|
```
|
|
@@ -921,7 +921,7 @@ The callback receives a `ProcessorViolation` object with:
|
|
|
921
921
|
- `message`: A human-readable description of what was violated
|
|
922
922
|
- `detail`: Processor-specific metadata (e.g. cost usage, detected PII types, moderation categories)
|
|
923
923
|
|
|
924
|
-
`onViolation` is part of the base [`Processor` interface](https://mastra.ai/reference/processors/processor-interface), so any custom processor can use it too. The runner automatically invokes it when any processor calls `abort()`. Errors thrown inside the callback are
|
|
924
|
+
`onViolation` is part of the base [`Processor` interface](https://mastra.ai/reference/processors/processor-interface), so any custom processor can use it too. The runner automatically invokes it when any processor calls `abort()`. Errors thrown inside the callback are caught to prevent interfering with the processor pipeline.
|
|
925
925
|
|
|
926
926
|
### Abort and tripwire chunks
|
|
927
927
|
|
|
@@ -6,7 +6,7 @@ Structured output lets an agent return an object that matches the shape defined
|
|
|
6
6
|
|
|
7
7
|
## When to use structured output
|
|
8
8
|
|
|
9
|
-
Use structured output when you need an agent to return a data object rather than text. Having well defined fields can make it simpler to pull out the values you need for API calls
|
|
9
|
+
Use structured output when you need an agent to return a data object rather than text. Having well defined fields can make it simpler to pull out the values you need for API calls and UI rendering, as well as application logic.
|
|
10
10
|
|
|
11
11
|
## Define schemas
|
|
12
12
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Tools
|
|
4
4
|
|
|
5
|
-
Agents use tools to call APIs
|
|
5
|
+
Agents use tools to call APIs or query databases. They can also run custom functions from your codebase. Tools give agents capabilities beyond language generation by providing structured access to data and performing clearly defined operations. You can also load tools from remote [MCP servers](https://mastra.ai/docs/mcp/overview) to expand an agent's capabilities.
|
|
6
6
|
|
|
7
7
|
**For AI agents:** Run `npx mastra api tool execute weather-tool '{"location":"San Francisco"}'` to test this tool directly instead of writing a temporary script. The command requires a running Mastra server; start the local server with `npx mastra dev`, or pass the reachable server's base URL with `--url`. Run `npx mastra api tool execute --schema` before constructing different input. Install Mastra's skill with `npx skills add mastra-ai/skills --skill mastra` for complete API CLI discovery, targeting, schema, authentication, and error-handling guidance.
|
|
8
8
|
|
|
@@ -287,7 +287,42 @@ Use `transform` when a tool returns raw data your application needs, but browser
|
|
|
287
287
|
|
|
288
288
|
If a transform is configured and it fails, Mastra doesn't fall back to the raw payload for display or transcript targets. Input deltas are suppressed when no safe `inputDelta` transform is available.
|
|
289
289
|
|
|
290
|
-
|
|
290
|
+
The following example redacts a secret from both targets:
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
import { createTool } from '@mastra/core/tools'
|
|
294
|
+
import { z } from 'zod'
|
|
295
|
+
|
|
296
|
+
export const customerTool = createTool({
|
|
297
|
+
id: 'lookup-customer',
|
|
298
|
+
description: 'Looks up a customer by id',
|
|
299
|
+
inputSchema: z.object({
|
|
300
|
+
customerId: z.string(),
|
|
301
|
+
}),
|
|
302
|
+
outputSchema: z.object({
|
|
303
|
+
ssn: z.string(),
|
|
304
|
+
}),
|
|
305
|
+
execute: async ({ customerId }) => {
|
|
306
|
+
// const response = await fetch(`https://your-crm.example.com/customers/${customerId}`)
|
|
307
|
+
// const { ssn } = await response.json()
|
|
308
|
+
return {
|
|
309
|
+
ssn: '123-45-6789',
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
transform: {
|
|
313
|
+
display: {
|
|
314
|
+
output: () => ({ ssn: '***-**-****' }),
|
|
315
|
+
},
|
|
316
|
+
transcript: {
|
|
317
|
+
output: () => ({ ssn: '***-**-****' }),
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
})
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Your application code still receives the raw `ssn` from the tool. Browser-facing streams get the `display` output, and user-visible transcript messages get the `transcript` output.
|
|
324
|
+
|
|
325
|
+
For more phases, including `input`, `inputDelta`, `error`, `approval`, `suspend`, and `resume`, see the [`createTool()` reference](https://mastra.ai/reference/tools/create-tool). For shared rules across several tools, configure the agent-level `transform` policy in the [`Agent` constructor](https://mastra.ai/reference/agents/agent).
|
|
291
326
|
|
|
292
327
|
## Run logic around tool calls
|
|
293
328
|
|
|
@@ -469,16 +504,18 @@ Note that for subagents, you'll see two different identifiers in stream response
|
|
|
469
504
|
|
|
470
505
|
Mastra includes agent-agnostic built-in tools in `@mastra/core/tools` that add interactive and organizational capabilities to any agent.
|
|
471
506
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
|
475
|
-
|
|
|
476
|
-
| `
|
|
477
|
-
| `
|
|
478
|
-
| `
|
|
479
|
-
| `
|
|
480
|
-
| `
|
|
481
|
-
| `
|
|
507
|
+
Each tool has two names: the export you import, and the tool ID the model sees in tool calls, traces, and `toolName` fields.
|
|
508
|
+
|
|
509
|
+
| Export | Tool ID | Purpose |
|
|
510
|
+
| ------------------ | -------------------- | --------------------------------------------------- |
|
|
511
|
+
| `askUserTool` | `ask_user` | Ask the user a question and wait for their answer |
|
|
512
|
+
| `submitPlanTool` | `submit_plan` | Submit a plan file for user approval |
|
|
513
|
+
| `taskWriteTool` | `task_write` | Create or replace a structured task list |
|
|
514
|
+
| `taskUpdateTool` | `task_update` | Update one tracked task by ID |
|
|
515
|
+
| `taskCompleteTool` | `task_complete` | Mark one tracked task completed |
|
|
516
|
+
| `taskCheckTool` | `task_check` | Check task list completion status |
|
|
517
|
+
| `webSearchTool` | `<provider.defined>` | Run the active provider's native web search |
|
|
518
|
+
| `webFetchTool` | `web_fetch` | Fetch a web page by URL and return its text content |
|
|
482
519
|
|
|
483
520
|
### Use provider web search
|
|
484
521
|
|
|
@@ -501,6 +538,8 @@ export const researchAgent = new Agent({
|
|
|
501
538
|
|
|
502
539
|
`webSearchTool` supports OpenAI, Anthropic, Google Gemini, and xAI models. If Mastra can't infer one of those providers from the active model, the agent run fails with a `MastraError`.
|
|
503
540
|
|
|
541
|
+
The resolved tool ID comes from the provider: `openai.web_search`, `anthropic.web_search_20250305`, `google.google_search`, or `xai.web_search`.
|
|
542
|
+
|
|
504
543
|
The `search` key is only the agent-local tool name. Use any key. The `webSearchTool` value tells Mastra to use provider web search.
|
|
505
544
|
|
|
506
545
|
### Fetch a web page
|
|
@@ -10,7 +10,6 @@ Mastra supports three SDK providers and one CLI provider:
|
|
|
10
10
|
- [**Stagehand**](https://mastra.ai/integrations/browsers/stagehand): A Browserbase provider with AI-powered element detection. Best for complex interactions that benefit from natural language selectors.
|
|
11
11
|
- [**FirecrawlBrowser**](https://mastra.ai/integrations/browsers/firecrawl): A Firecrawl Browser Sandbox provider that runs AgentBrowser tools against hosted browser sessions. Best for running automation on hosted browser sessions without managing local browser infrastructure.
|
|
12
12
|
- [**BrowserViewer**](https://mastra.ai/integrations/browsers/browser-viewer): A CLI provider that launches Chrome and injects CDP URLs into CLI tools like agent-browser, browser-use, and browse. Best for workspace agents that drive browsers through shell commands.
|
|
13
|
-
- [**Browser recording (alpha)**](https://mastra.ai/docs/browser/recording): An opt-in tool layer that saves browser sessions as Motion-JPEG AVI videos with optional captions.
|
|
14
13
|
|
|
15
14
|
## When to use browser
|
|
16
15
|
|
|
@@ -24,7 +23,7 @@ Use browser when your agent needs to:
|
|
|
24
23
|
|
|
25
24
|
## How it works
|
|
26
25
|
|
|
27
|
-
When you assign a browser to an agent, Mastra includes the provider's tools in the agent's toolset. The agent uses these tools to control the browser
|
|
26
|
+
When you assign a browser to an agent, Mastra includes the provider's tools in the agent's toolset. The agent uses these tools to control the browser. It can open URLs and select elements. It can also type text and read page content.
|
|
28
27
|
|
|
29
28
|
Each provider offers a different set of tools optimized for its approach.
|
|
30
29
|
|
|
@@ -176,12 +175,32 @@ const browser = new AgentBrowser({
|
|
|
176
175
|
})
|
|
177
176
|
```
|
|
178
177
|
|
|
178
|
+
## Record browser sessions
|
|
179
|
+
|
|
180
|
+
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
181
|
+
|
|
182
|
+
AgentBrowser and StagehandBrowser can opt into recording for reviewing, sharing, or debugging browser runs. Configure `outputDir` to add the recording tools:
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
import { join } from 'node:path'
|
|
186
|
+
import { AgentBrowser } from '@mastra/agent-browser'
|
|
187
|
+
|
|
188
|
+
export const browser = new AgentBrowser({
|
|
189
|
+
recording: {
|
|
190
|
+
outputDir: join(process.cwd(), 'browser-recordings'),
|
|
191
|
+
},
|
|
192
|
+
})
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
StagehandBrowser accepts the same `recording` option. The agent uses `browser_record` to start, check, and stop a recording, and `browser_record_caption` to label major actions. Stopping saves the video and lets the agent return its path. A custom `outputPath` must be absolute and stay inside `recording.outputDir`.
|
|
196
|
+
|
|
197
|
+
Recordings use Motion-JPEG AVI and don't require `ffmpeg`. The default maximum duration is 30 seconds, with a 120-second hard cap. The default maximum frame size is 1024 × 720, captions are limited to 80 characters, and only one recording can be active per process.
|
|
198
|
+
|
|
179
199
|
## Next steps
|
|
180
200
|
|
|
181
201
|
- [AgentBrowser](https://mastra.ai/integrations/browsers/agent-browser)
|
|
182
202
|
- [Stagehand](https://mastra.ai/integrations/browsers/stagehand)
|
|
183
203
|
- [Firecrawl](https://mastra.ai/integrations/browsers/firecrawl)
|
|
184
|
-
- [Browser recording (alpha)](https://mastra.ai/docs/browser/recording)
|
|
185
204
|
- [BrowserViewer](https://mastra.ai/integrations/browsers/browser-viewer)
|
|
186
205
|
- [MastraBrowser reference](https://mastra.ai/reference/browser/mastra-browser)
|
|
187
206
|
- 📹 [Mastra browser capabilities workshop](https://www.youtube.com/watch?v=E9KFsZEnQO8\&t=5s)
|
|
@@ -136,7 +136,7 @@ Called after a delegation finishes. Use it to inspect results or provide feedbac
|
|
|
136
136
|
- Return `{ feedback: '...' }`: Add feedback that gets saved to the parent agent's memory and is visible to subsequent iterations
|
|
137
137
|
- Return `{ resultText: '...' }`: Replace the tool result text the parent model sees for this delegation, within the current run
|
|
138
138
|
|
|
139
|
-
Use `resultText` when the subagent's own result would mislead the parent immediately. For example, a subagent that stops on a tool-calls step returns empty text
|
|
139
|
+
Use `resultText` when the subagent's own result would mislead the parent immediately. For example, a subagent that stops on a tool-calls step returns empty text. The parent model reads this as a successful but empty delegation. Unlike `feedback`, which only reaches the model on the next turn, `resultText` changes what the parent reasons on right away.
|
|
140
140
|
|
|
141
141
|
```typescript
|
|
142
142
|
const stream = await parentAgent.stream('Research AI trends', {
|
|
@@ -237,7 +237,7 @@ const stream = await parentAgent.stream('Research AI trends', {
|
|
|
237
237
|
})
|
|
238
238
|
```
|
|
239
239
|
|
|
240
|
-
Return `{ continue: true }` to keep iterating, or `{ continue: false }` to stop. Include optional `feedback` to inject guidance into the conversation. When `feedback` is combined with `continue: false`, the model may get one final turn
|
|
240
|
+
Return `{ continue: true }` to keep iterating, or `{ continue: false }` to stop. Include optional `feedback` to inject guidance into the conversation. When `feedback` is combined with `continue: false`, the model may get one final turn for a text response that incorporates the feedback. The extra turn is granted only while the current iteration is active (e.g., after tool calls).
|
|
241
241
|
|
|
242
242
|
## Memory isolation
|
|
243
243
|
|
|
@@ -69,7 +69,7 @@ Because the threads belong to the caller's resource, resource-scoped memory feat
|
|
|
69
69
|
- Resource-scoped working memory updates persist to the resource, and later items in the run see updates made by earlier items.
|
|
70
70
|
- Resource-scoped semantic recall can surface the resource's prior conversations to the experiment, and experiment transcripts become recallable in that resource's later conversations.
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
Use this approach to evaluate an agent against a real user's accumulated context. To keep experiment runs from touching real user state, use a dedicated evaluation resource id instead.
|
|
73
73
|
|
|
74
74
|
Thread injection is skipped in the following cases:
|
|
75
75
|
|
|
@@ -353,7 +353,7 @@ In [Studio](https://mastra.ai/docs/studio/overview), edit a dataset item to auth
|
|
|
353
353
|
### Limitations
|
|
354
354
|
|
|
355
355
|
- **No tool span for mocked calls.** A mocked call returns its output before the tool executes, so it doesn't create a tool span. Trajectory scorers backed by stored traces may therefore not see mocked tool calls. Trajectory extraction that falls back to the agent's message output still sees them, so trajectory scoring can differ depending on your observability configuration.
|
|
356
|
-
- **Storage support.**
|
|
356
|
+
- **Storage support.** The LibSQL, PostgreSQL, MongoDB, and Spanner adapters persist tool mocks and tool mock reports, while the MySQL adapter rejects writes that carry either one. All dataset storage adapters persist `unmockedToolPolicy`.
|
|
357
357
|
|
|
358
358
|
## Async experiments
|
|
359
359
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Deploy
|
|
4
4
|
|
|
5
|
-
Mastra applications can be deployed to any Node.js-compatible environment. You can deploy a Mastra server
|
|
5
|
+
Mastra applications can be deployed to any Node.js-compatible environment. You can deploy a Mastra server or integrate with an existing web framework. Other options include cloud providers and [Mastra platform](https://mastra.ai/docs/mastra-platform/overview) for observability, Studio, and server deployment.
|
|
6
6
|
|
|
7
7
|
## Runtime support
|
|
8
8
|
|
|
@@ -73,10 +73,10 @@ Use these guides when adding Mastra to an existing Next.js or Astro application.
|
|
|
73
73
|
|
|
74
74
|
## Workflow runners
|
|
75
75
|
|
|
76
|
-
Mastra workflows run using the built-in execution engine by default. For production workloads requiring managed infrastructure, workflows can also be deployed to specialized platforms like [Inngest](https://www.inngest.com) that provide step memoization
|
|
76
|
+
Mastra workflows run using the built-in execution engine by default. For production workloads requiring managed infrastructure, workflows can also be deployed to specialized platforms like [Inngest](https://www.inngest.com) that provide step memoization and automatic retries, with real-time monitoring.
|
|
77
77
|
|
|
78
78
|
Visit the [Workflow Runners guide](https://mastra.ai/docs/deployment/workflow-runners) for execution options and the [Inngest deployment guide](https://mastra.ai/integrations/deploy/inngest) for setup instructions.
|
|
79
79
|
|
|
80
80
|
## Workers
|
|
81
81
|
|
|
82
|
-
For production deployments, Mastra can run workflow orchestration
|
|
82
|
+
For production deployments, Mastra can run workflow orchestration and cron scheduling, along with background tool execution in dedicated worker processes separate from the API server. This lets you scale each concern independently and isolate failures. See [Workers](https://mastra.ai/docs/deployment/workers) for details.
|
|
@@ -69,7 +69,7 @@ export const mastra = new Mastra({
|
|
|
69
69
|
})
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
Vercel has two additional requirements:
|
|
73
73
|
|
|
74
74
|
- `timeout` can't exceed the maximum sandbox lifetime of your plan, 45 minutes on Pro. A higher value fails the deploy with a 400 from the Vercel API.
|
|
75
75
|
- Declare the server port in `ports`. Vercel exposes only ports declared at creation, unlike E2B and Daytona.
|
|
@@ -126,15 +126,15 @@ mastra worker start orchestration
|
|
|
126
126
|
|
|
127
127
|
## Network architecture
|
|
128
128
|
|
|
129
|
-
Workers are internal infrastructure. They're not exposed to end users and don't need their own subdomain
|
|
129
|
+
Workers are internal infrastructure. They're not exposed to end users and don't need their own subdomain or public URL, including an inbound HTTP route.
|
|
130
130
|
|
|
131
131
|
In a split deployment:
|
|
132
132
|
|
|
133
|
-
- **The API server is the only public-facing process**: It serves all client HTTP requests
|
|
133
|
+
- **The API server is the only public-facing process**: It serves all client HTTP requests. These requests include REST endpoints and agent interactions, plus workflow triggers and custom routes.
|
|
134
134
|
- **Workers connect outbound only**: They pull events from the distributed PubSub backend and read/write to the shared storage database. They don't accept inbound traffic from clients.
|
|
135
135
|
- **The orchestration worker calls the API internally**: It sends step execution requests to the API over the container network using `MASTRA_STEP_EXECUTION_URL`. This is internal service-to-service communication, not a public endpoint.
|
|
136
136
|
|
|
137
|
-
All three worker types (orchestration, scheduler, background task) sit behind the API on a private network. They share access to the PubSub backend and storage database but never receive traffic directly from clients.
|
|
137
|
+
All three worker types (orchestration, scheduler, background task) sit behind the API on a private network. They share access to the PubSub backend and storage database but never receive traffic directly from clients. HTTP routes for worker-related features run on the API server rather than the worker process. One example is token minting for a voice integration.
|
|
138
138
|
|
|
139
139
|
## Deploy split workers
|
|
140
140
|
|
|
@@ -337,7 +337,7 @@ In a fully split deployment, the orchestration worker delegates workflow step ex
|
|
|
337
337
|
MASTRA_STEP_EXECUTION_URL=http://api:4111/api
|
|
338
338
|
```
|
|
339
339
|
|
|
340
|
-
Without this variable, the orchestration worker attempts to execute steps in its own process
|
|
340
|
+
Without this variable, the orchestration worker attempts to execute steps in its own process, which doesn't have access to the full Mastra runtime in a split deployment.
|
|
341
341
|
|
|
342
342
|
The endpoint uses the server's normal auth pipeline. If the API has an auth provider, set `MASTRA_WORKER_AUTH_TOKEN` to a bearer token that provider accepts. Mastra forwards the value as an `Authorization: Bearer` credential. The configured auth provider validates the token. See [Worker authentication](https://mastra.ai/docs/server/auth/workers) for server configuration and other credential formats.
|
|
343
343
|
|
|
@@ -361,7 +361,7 @@ Run exactly one scheduler worker. Multiple schedulers polling the same storage c
|
|
|
361
361
|
|
|
362
362
|
### Crash recovery
|
|
363
363
|
|
|
364
|
-
A distributed PubSub backend persists unacknowledged events
|
|
364
|
+
A distributed PubSub backend persists unacknowledged events, which lets orchestration and background task workers resume after a restart. When the API is unavailable, a failed step-execution request causes the event to be delivered again. Because an event can be processed more than once, handlers should be idempotent when possible.
|
|
365
365
|
|
|
366
366
|
The scheduler calculates the next fire time from the current time after it restarts. It doesn't replay schedules that elapsed while it was unavailable.
|
|
367
367
|
|
|
@@ -6,7 +6,7 @@ Mastra [workflows](https://mastra.ai/docs/workflows/overview) can be executed us
|
|
|
6
6
|
|
|
7
7
|
## Inngest
|
|
8
8
|
|
|
9
|
-
Inngest is a developer platform for running background workflows without managing infrastructure. Mastra workflows can be deployed to Inngest
|
|
9
|
+
Inngest is a developer platform for running background workflows without managing infrastructure. Mastra workflows can be deployed to Inngest for step memoization and automatic retries. Inngest also provides real-time monitoring and suspend/resume capabilities.
|
|
10
10
|
|
|
11
11
|
Visit the [Inngest deployment guide](https://mastra.ai/integrations/deploy/inngest) for setup instructions and the [Inngest workflow example](https://github.com/mastra-ai/mastra/tree/main/examples/inngest) for a complete implementation.
|
|
12
12
|
|
|
@@ -14,6 +14,8 @@ A [deployed Studio](https://mastra.ai/docs/studio/deployment) makes Editor avail
|
|
|
14
14
|
|
|
15
15
|
Use Editor when an agent is defined in code but the people responsible for its behavior shouldn't edit the codebase. It works well when instructions or tools change often and need testing before they reach users. If developers own every change and release agent configuration with the application, keep the [agent configuration in code](https://mastra.ai/docs/agents/overview) instead.
|
|
16
16
|
|
|
17
|
+
Use [Agent Builder](https://agent-builder.mastra.ai) instead when collaborators need to create and manage fully stored agents in a browser rather than start from agents defined in code.
|
|
18
|
+
|
|
17
19
|
## Quickstart
|
|
18
20
|
|
|
19
21
|
Install `@mastra/editor`. This quickstart uses LibSQL to store Editor changes:
|
|
@@ -304,7 +306,7 @@ Version selection supports:
|
|
|
304
306
|
- Compare two versions in an A/B test.
|
|
305
307
|
- Give a draft to a small group before publishing it for everyone.
|
|
306
308
|
- Keep production on the published version while staging uses the latest draft.
|
|
307
|
-
- Pin a customer to a
|
|
309
|
+
- Pin a customer to a specific version.
|
|
308
310
|
|
|
309
311
|
The same version controls work when a supervisor calls sub-agents. Developers can test a draft sub-agent without changing the rest of the system.
|
|
310
312
|
|
|
@@ -104,7 +104,7 @@ console.log(result.analyzeStepResult) // { hasSources: true, sources: ["Wikipedi
|
|
|
104
104
|
|
|
105
105
|
### Agent Type for Agent Evaluation
|
|
106
106
|
|
|
107
|
-
For type safety and compatibility with both live agent scoring and trace scoring, use `type: 'agent'` when creating scorers for agent evaluation.
|
|
107
|
+
For type safety and compatibility with both live agent scoring and trace scoring, use `type: 'agent'` when creating scorers for agent evaluation. The same scorer can evaluate an agent and score traces:
|
|
108
108
|
|
|
109
109
|
```typescript
|
|
110
110
|
const myScorer = createScorer({
|
|
@@ -113,7 +113,7 @@ Semantics:
|
|
|
113
113
|
- `result.turnResults[i]` reports each turn's `gateResults`, `thresholdResults`, and `scores`, so a failure points at the exact turn. Across multiple conversations, turn results are averaged by turn index.
|
|
114
114
|
- A turn with no `gates` or `scorers` advances the conversation.
|
|
115
115
|
- Top-level `scorers`/`gates` still run as a whole over the accumulated output, so you can combine "this turn must call the tool" with "the answer mentions Brooklyn."
|
|
116
|
-
- When the agent has storage configured, each per-turn scorer/gate result is persisted like top-level scores, so per-turn outcomes appear in your scores store. Each stored per-turn score
|
|
116
|
+
- When the agent has storage configured, each per-turn scorer/gate result is persisted like top-level scores, so per-turn outcomes appear in your scores store. Each stored per-turn score uses its turn index as a label (`metadata.turnIndex`) and shares the conversation's `threadId`. It also includes a link to that turn's trace span.
|
|
117
117
|
|
|
118
118
|
Use `inputs` when a single whole-conversation score over the whole conversation is enough. Use `turns` when correctness depends on individual turns. `turns` can't be combined with `input` or `inputs` in the same data item.
|
|
119
119
|
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
While traditional software tests have clear pass/fail conditions, AI outputs are non-deterministic, they can vary with the same input. **Scorers** help bridge this gap by providing quantifiable metrics for measuring agent quality.
|
|
6
6
|
|
|
7
|
-
Scorers are automated tests that evaluate Agents outputs using model-graded, rule-based, and statistical methods. Scorers return **scores**: numerical values (typically between 0 and 1) that quantify how well an output meets your evaluation criteria. These scores enable you to objectively track performance
|
|
7
|
+
Scorers are automated tests that evaluate Agents outputs using model-graded, rule-based, and statistical methods. Scorers return **scores**: numerical values (typically between 0 and 1) that quantify how well an output meets your evaluation criteria. These scores enable you to objectively track performance and compare different approaches while identifying areas for improvement in your AI systems. Scorers can be customized with your own prompts and scoring functions.
|
|
8
8
|
|
|
9
|
-
Scorers can
|
|
9
|
+
Scorers can run in the cloud to capture real-time results. Scorers can also be part of your CI/CD pipeline for testing and monitoring agents over time.
|
|
10
10
|
|
|
11
11
|
> **📹 Watch:** Watch [Mastra evals overview](https://www.youtube.com/watch?v=12WN6u2DrBk) for an introduction to evals and how to reason about agent quality.
|
|
12
12
|
|
|
@@ -113,7 +113,7 @@ For the step-level `scorers` API, see the [Step class reference](https://mastra.
|
|
|
113
113
|
|
|
114
114
|
### How live evaluations work
|
|
115
115
|
|
|
116
|
-
**Asynchronous execution**: Live evaluations run in the background without blocking your agent responses or workflow execution.
|
|
116
|
+
**Asynchronous execution**: Live evaluations run in the background without blocking your agent responses or workflow execution. Your AI systems remain responsive while live evaluations monitor them.
|
|
117
117
|
|
|
118
118
|
**Sampling control**: The `sampling.rate` parameter (0-1) controls what percentage of outputs get scored:
|
|
119
119
|
|
|
@@ -44,7 +44,7 @@ Mastra provides a skill and a CLI to help your coding agent write high-quality M
|
|
|
44
44
|
|
|
45
45
|
### Mastra skill
|
|
46
46
|
|
|
47
|
-
AI models may not have up-to-date knowledge of Mastra's APIs. Use the [Mastra skill](https://github.com/mastra-ai/skills) to give your coding agent implementation guidance
|
|
47
|
+
AI models may not have up-to-date knowledge of Mastra's APIs. Use the [Mastra skill](https://github.com/mastra-ai/skills) to give your coding agent implementation guidance and best practices, including instructions for fetching the latest Mastra documentation.
|
|
48
48
|
|
|
49
49
|
Install the skill manually with:
|
|
50
50
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
`AgentController` is a shared runtime host for interactive agent applications. It coordinates modes, models, storage, workspaces, tool approvals, subagents, and channels. Each user or active task works through an isolated [`Session`](https://mastra.ai/reference/agent-controller/session).
|
|
8
8
|
|
|
9
|
-
[Mastra Code](https://code.mastra.ai)
|
|
9
|
+
[Mastra Code](https://code.mastra.ai) and [Mastra Factory](https://factory.mastra.ai) are the flagship AgentController implementations. They're coding agents with multi-model support, persistent conversations, and plan-then-execute workflows. Read [Building a coding agent](https://mastra.ai/blog/building-a-coding-agent) for a step-by-step TUI guide.
|
|
10
10
|
|
|
11
11
|
## When to use the Agent Controller
|
|
12
12
|
|
|
@@ -341,7 +341,7 @@ Point each platform webhook at the controller-specific route:
|
|
|
341
341
|
/api/agent-controllers/<CONTROLLER_ID>/channels/<PLATFORM>/webhook
|
|
342
342
|
```
|
|
343
343
|
|
|
344
|
-
Each external chat thread maps to one controller Session and Mastra thread. By default, new sessions use a resource ID derived from the adapter's chat-thread ID, prefixed with `channel:`. Use `resolveResourceId` to map direct messages to an existing application user or choose another memory owner. The callback only affects new threads
|
|
344
|
+
Each external chat thread maps to one controller Session and Mastra thread. By default, new sessions use a resource ID derived from the adapter's chat-thread ID, prefixed with `channel:`. Use `resolveResourceId` to map direct messages to an existing application user or choose another memory owner. The callback only affects new threads. An existing thread keeps its stored resource ID.
|
|
345
345
|
|
|
346
346
|
Channel sessions are created by the controller rather than by your code, so `onSessionStart` is where you configure them. It runs once per session, after the session is bound to its mapped thread and before the first message is handled. A channel session starts with controller defaults, so this is where you set its model and memory settings. Later messages in the same thread reuse the session and don't call it again. Errors are logged and swallowed so a session that can't be configured still answers the message.
|
|
347
347
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
A harness lets an agent pursue long-running, complex goals while keeping its work durable, visible, and steerable. It preserves progress across retries and interruptions, while giving people and other systems a way to inspect progress, add context, approve actions, redirect the agent, or stop it.
|
|
6
6
|
|
|
7
|
-
Agent harnesses are useful wherever work continues over time. Common examples include coding agents that carry changes through CI and review, software factories that coordinate many tasks in parallel, SRE agents that adapt as incidents evolve, and go-to-market agents that respond as accounts, signals, and conversations change.
|
|
7
|
+
Agent harnesses are useful wherever work continues over time. Common examples include coding agents that carry changes through CI and review, software factories (like [Mastra Factory](https://factory.mastra.ai)) that coordinate many tasks in parallel, SRE agents that adapt as incidents evolve, and go-to-market agents that respond as accounts, signals, and conversations change.
|
|
8
8
|
|
|
9
9
|
In Mastra, harness refers to a set of capabilities for managing an agent beyond a single uninterrupted run. You can adopt these capabilities individually or combine them as needed.
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**Added in:** `@mastra/core@1.29.0`
|
|
6
6
|
|
|
7
|
-
Background tasks let an agent dispatch a long-running tool call without blocking the agentic loop. The tool returns an immediate acknowledgement
|
|
7
|
+
Background tasks let an agent dispatch a long-running tool call without blocking the agentic loop. The tool returns an immediate acknowledgement while the LLM continues responding. The task then runs to completion in the background. When it finishes, its result is written to memory and if you use `stream()` with the [`untilIdle`](https://mastra.ai/reference/streaming/agents/stream) option the agent is re-invoked automatically so the result is processed in the same call.
|
|
8
8
|
|
|
9
9
|
## When to use background tasks
|
|
10
10
|
|
|
@@ -273,7 +273,7 @@ await mastra.backgroundTaskManager?.resume(taskId, {
|
|
|
273
273
|
|
|
274
274
|
### What happens to the agent loop
|
|
275
275
|
|
|
276
|
-
When a task suspends mid-`stream()` with `untilIdle`, the wrapper treats it as terminal for the current iteration and closes. To continue the agent immediately when the resume payload is in hand, call `agent.resumeStream(resumeData, { runId, toolCallId, memory, untilIdle: true })`: the resumed bg task runs to completion
|
|
276
|
+
When a task suspends mid-`stream()` with `untilIdle`, the wrapper treats it as terminal for the current iteration and closes. To continue the agent immediately when the resume payload is in hand, call `agent.resumeStream(resumeData, { runId, toolCallId, memory, untilIdle: true })`: the resumed bg task runs to completion and adds its result to the message list. The agent then runs a follow-up turn, all on the same SSE connection. If you'd rather drive the resume out-of-band, call `mastra.backgroundTaskManager.resume(taskId, resumeData)` directly and the result still writes into the thread for the next user turn to pick up.
|
|
277
277
|
|
|
278
278
|
### Re-registering the executor on resume
|
|
279
279
|
|
|
@@ -114,5 +114,6 @@ Per-objective values written by `setObjective` / `updateObjectiveOptions` take p
|
|
|
114
114
|
## Related
|
|
115
115
|
|
|
116
116
|
- [Supervisor agents](https://mastra.ai/docs/capabilities/subagents): `isTaskComplete` and the rubric scorer
|
|
117
|
-
- [Signal providers](https://mastra.ai/docs/long-running-agents/signal-providers):
|
|
118
|
-
- [Memory storage](https://mastra.ai/docs/storage/overview):
|
|
117
|
+
- [Signal providers](https://mastra.ai/docs/long-running-agents/signal-providers): How the objective is projected into context
|
|
118
|
+
- [Memory storage](https://mastra.ai/docs/storage/overview): The storage backend goals require
|
|
119
|
+
- [Mastra Factory](https://factory.mastra.ai) and [Mastra Code](https://code.mastra.ai): Examples of goal-driven coding agents
|
|
@@ -151,7 +151,7 @@ Notification inbox storage is available in the storage adapters that support ric
|
|
|
151
151
|
|
|
152
152
|
### Send processor context
|
|
153
153
|
|
|
154
|
-
Processors can send reactive signals during a run. A processor should inspect the chat history
|
|
154
|
+
Processors can send reactive signals during a run. A processor should inspect the chat history and react to a specific trigger without sending the same context more than once.
|
|
155
155
|
|
|
156
156
|
The following example demonstrates a processor that injects `AGENTS.md` instructions after a tool call reads an `AGENTS.md` file.
|
|
157
157
|
|
|
@@ -350,7 +350,7 @@ Mastra still accepts legacy signal payloads such as `type: 'user-message'` and `
|
|
|
350
350
|
- `type: 'user-message'`: Normalizes to `type: 'user'` and `tagName: 'user'`
|
|
351
351
|
- `type: 'system-reminder'`: Normalizes to `type: 'reactive'` and `tagName: 'system-reminder'`
|
|
352
352
|
|
|
353
|
-
Existing stored signal rows and older clients continue to load through the compatibility layer. New clients call the message routes when the server supports them
|
|
353
|
+
Existing stored signal rows and older clients continue to load through the compatibility layer. New clients call the message routes when the server supports them. React's thread signal path falls back to the legacy `/signals` route when it detects an older server. Visit [Agent signals reference](https://mastra.ai/reference/agents/agent) for the full message, signal, and subscription types.
|
|
354
354
|
|
|
355
355
|
### Approve tool calls
|
|
356
356
|
|
|
@@ -93,7 +93,7 @@ The region is fixed when the environment is created. Databases attached to an en
|
|
|
93
93
|
|
|
94
94
|
Preflight validates the built output before anything includes, and only flags issues in your own code:
|
|
95
95
|
|
|
96
|
-
- **Local storage paths**: A hard block. File-backed storage (for example `file:./mastra.db`) is lost on every deploy. Preflight passes when the path is guarded by an environment variable that's set locally
|
|
96
|
+
- **Local storage paths**: A hard block. File-backed storage (for example `file:./mastra.db`) is lost on every deploy. Preflight passes when the path is guarded by an environment variable that's set locally or stored on the platform, including values provided by a managed database:
|
|
97
97
|
|
|
98
98
|
```ts
|
|
99
99
|
import { LibSQLStore } from '@mastra/libsql'
|