@mastra/mcp-docs-server 1.2.17-alpha.7 → 1.2.17
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/02-agent-tools-mcp/32-conclusion.md +1 -1
- package/.docs/docs/agents/code-mode.md +3 -3
- package/.docs/docs/agents/guardrails.md +1 -1
- package/.docs/docs/agents/{agent-approval.md → human-in-the-loop.md} +5 -5
- package/.docs/docs/agents/networks.md +3 -3
- package/.docs/docs/agents/overview.md +7 -7
- package/.docs/docs/agents/processors.md +3 -3
- package/.docs/docs/agents/{using-tools.md → tools.md} +7 -7
- package/.docs/docs/{server/auth → auth}/custom-auth-provider.md +1 -1
- package/.docs/docs/{server/auth → auth}/fga.md +27 -1
- package/.docs/docs/{server/auth.md → auth/overview.md} +4 -4
- package/.docs/docs/{server/auth → auth}/simple-auth.md +1 -1
- package/.docs/docs/{server/auth → auth}/workers.md +2 -2
- package/.docs/docs/{capabilities/channels.md → channels.md} +2 -2
- package/.docs/docs/{agents → connections}/a2a.md +2 -2
- package/.docs/docs/{agents → connections}/acp.md +18 -6
- package/.docs/docs/{mcp/overview.md → connections/mcp.md} +1 -1
- package/.docs/docs/connections/overview.md +5 -5
- package/.docs/docs/{agents → connections}/sdk-agents.md +3 -1
- package/.docs/docs/deployment/cloud-providers.md +1 -0
- package/.docs/docs/deployment/mastra-server.md +2 -2
- package/.docs/docs/deployment/overview.md +2 -1
- package/.docs/docs/deployment/sandbox.md +3 -3
- package/.docs/docs/deployment/workers.md +4 -4
- package/.docs/docs/guides/multi-agent-systems.md +7 -7
- package/.docs/docs/guides/streaming.md +1 -1
- package/.docs/docs/harness/agent-controller.md +5 -3
- package/.docs/docs/{long-running-agents → harness}/background-tasks.md +5 -5
- package/.docs/docs/{long-running-agents → harness}/durable-agents.md +18 -2
- package/.docs/docs/{long-running-agents → harness}/goals.md +6 -6
- package/.docs/docs/harness/overview.md +11 -10
- package/.docs/docs/{long-running-agents → harness}/schedules.md +5 -5
- package/.docs/docs/{long-running-agents → harness}/signal-providers.md +4 -4
- package/.docs/docs/mastra-platform/deploy.md +1 -1
- package/.docs/docs/mastra-platform/overview.md +1 -1
- package/.docs/docs/mastra-platform/server.md +1 -1
- package/.docs/docs/memory/message-history.md +1 -1
- package/.docs/docs/memory/overview.md +4 -4
- package/.docs/docs/memory/working-memory.md +1 -1
- package/.docs/docs/observability/integrations/exporters/mastra-storage.md +1 -1
- package/.docs/docs/{workspace → sandbox}/filesystem.md +2 -2
- package/.docs/docs/{workspace → sandbox}/lsp.md +3 -3
- package/.docs/docs/{workspace/sandbox.md → sandbox/overview.md} +4 -3
- package/.docs/docs/{workspace → sandbox}/search.md +2 -2
- package/.docs/docs/{workspace → sandbox}/skills.md +5 -5
- package/.docs/docs/server/custom-api-routes.md +2 -2
- package/.docs/docs/server/mastra-client.md +2 -2
- package/.docs/docs/server/{mastra-server.md → overview.md} +3 -3
- package/.docs/docs/server/pubsub.md +2 -2
- package/.docs/docs/server/server-adapters.md +4 -4
- package/.docs/docs/{agents/skills.md → skills.md} +4 -4
- package/.docs/docs/{storage/overview.md → storage.md} +2 -1
- package/.docs/docs/studio/auth.md +4 -4
- package/.docs/docs/studio/overview.md +2 -2
- package/.docs/docs/{capabilities/subagents.md → subagents.md} +35 -5
- package/.docs/docs/workflows/agents-and-tools.md +1 -1
- package/.docs/docs/workflows/control-flow.md +0 -4
- package/.docs/docs/workflows/human-in-the-loop.md +0 -4
- package/.docs/docs/workflows/overview.md +1 -1
- package/.docs/docs/workflows/scheduled-workflows.md +2 -2
- package/.docs/docs/workflows/snapshots.md +1 -1
- package/.docs/docs/workflows/suspend-and-resume.md +0 -4
- package/.docs/integrations/agentic-ui/ai-sdk-ui.md +1 -1
- package/.docs/integrations/agentic-ui/copilotkit.md +1 -1
- package/.docs/integrations/auth/google.md +2 -2
- package/.docs/integrations/auth/workos.md +1 -1
- package/.docs/integrations/browsers/agent-browser.md +2 -2
- package/.docs/integrations/browsers/browser-viewer.md +6 -6
- package/.docs/integrations/browsers/firecrawl.md +1 -1
- package/.docs/integrations/browsers/stagehand.md +2 -2
- package/.docs/integrations/channels/discord.md +2 -2
- package/.docs/integrations/channels/github.md +1 -1
- package/.docs/integrations/channels/imessage.md +4 -4
- package/.docs/integrations/channels/slack.md +5 -5
- package/.docs/integrations/channels/teams.md +2 -2
- package/.docs/integrations/channels/telegram.md +2 -2
- package/.docs/integrations/channels/whatsapp.md +2 -2
- package/.docs/integrations/databases/postgresql.md +1 -0
- package/.docs/integrations/deploy/amazon-ec2.md +2 -2
- package/.docs/integrations/deploy/aws-lambda.md +3 -3
- package/.docs/integrations/deploy/azure-app-services.md +2 -2
- package/.docs/integrations/deploy/cloudflare.md +2 -2
- package/.docs/integrations/deploy/digital-ocean.md +3 -3
- package/.docs/integrations/deploy/kubernetes.md +11 -11
- package/.docs/integrations/deploy/netlify.md +3 -3
- package/.docs/integrations/deploy/render.md +389 -0
- package/.docs/integrations/deploy/vercel.md +2 -2
- package/.docs/integrations/file-storage/amazon-s3.md +1 -1
- package/.docs/integrations/file-storage/azure-blob.md +1 -1
- package/.docs/integrations/file-storage/google-cloud-storage.md +1 -1
- package/.docs/integrations/file-storage/mesa.md +2 -2
- package/.docs/integrations/file-storage/vercel-files.md +1 -1
- package/.docs/integrations/frameworks/astro.md +6 -2
- package/.docs/integrations/frameworks/electron.md +1 -1
- package/.docs/integrations/frameworks/express.md +1 -1
- package/.docs/integrations/frameworks/hono.md +1 -1
- package/.docs/integrations/frameworks/nestjs.md +1 -1
- package/.docs/integrations/frameworks/next-js.md +6 -2
- package/.docs/integrations/frameworks/nuxt.md +1 -1
- package/.docs/integrations/frameworks/sveltekit.md +1 -1
- package/.docs/integrations/frameworks/vite-react.md +6 -2
- package/.docs/integrations/sandboxes/agentcore.md +1 -1
- package/.docs/integrations/sandboxes/apple-container.md +1 -1
- package/.docs/integrations/sandboxes/cloudflare-sandbox.md +118 -0
- package/.docs/integrations/sandboxes/daytona.md +1 -1
- package/.docs/integrations/sandboxes/docker.md +4 -3
- package/.docs/integrations/sandboxes/e2b.md +1 -1
- package/.docs/integrations/sandboxes/modal.md +1 -1
- package/.docs/integrations/sandboxes/railway.md +11 -0
- package/.docs/integrations.md +4 -0
- package/.docs/models/environment-variables.md +8 -2
- package/.docs/models/gateways/merge-gateway.md +212 -0
- package/.docs/models/gateways/openrouter.md +5 -1
- package/.docs/models/gateways/vercel.md +22 -1
- package/.docs/models/gateways.md +1 -0
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/alibaba-token-plan-cn.md +2 -1
- package/.docs/models/providers/alibaba-token-plan.md +2 -1
- package/.docs/models/providers/ambient.md +2 -2
- package/.docs/models/providers/amd.md +73 -0
- package/.docs/models/providers/arcee.md +79 -0
- package/.docs/models/providers/baseten.md +1 -1
- package/.docs/models/providers/cerebras.md +2 -3
- package/.docs/models/providers/chutes.md +2 -1
- package/.docs/models/providers/cloudflare-workers-ai.md +3 -2
- package/.docs/models/providers/cortecs.md +2 -1
- package/.docs/models/providers/crof.md +1 -1
- package/.docs/models/providers/crossmodel.md +3 -2
- package/.docs/models/providers/deepinfra.md +5 -1
- package/.docs/models/providers/digitalocean.md +3 -2
- package/.docs/models/providers/edenai.md +19 -5
- package/.docs/models/providers/empiriolabs.md +10 -1
- package/.docs/models/providers/hetzner.md +6 -8
- package/.docs/models/providers/huggingface.md +4 -1
- package/.docs/models/providers/hyper.md +9 -8
- package/.docs/models/providers/inferx.md +19 -13
- package/.docs/models/providers/jalapeno.md +89 -0
- package/.docs/models/providers/kilo.md +17 -14
- package/.docs/models/providers/kosmik.md +73 -0
- package/.docs/models/providers/llmgateway.md +3 -3
- package/.docs/models/providers/llmtr.md +35 -10
- package/.docs/models/providers/nano-gpt.md +18 -19
- package/.docs/models/providers/ofox.md +3 -3
- package/.docs/models/providers/opencode-go.md +2 -2
- package/.docs/models/providers/requesty.md +3 -3
- package/.docs/models/providers/runinfra.md +76 -0
- package/.docs/models/providers/sakana.md +3 -2
- package/.docs/models/providers/scnet-token-plan.md +85 -0
- package/.docs/models/providers/scx-ai.md +76 -0
- package/.docs/models/providers/togetherai.md +2 -1
- package/.docs/models/providers/umans-ai-coding-plan.md +2 -1
- package/.docs/models/providers/umans-ai.md +2 -1
- package/.docs/models/providers/vivgrid.md +2 -1
- package/.docs/models/providers/wandb.md +2 -1
- package/.docs/models/providers/xai.md +2 -1
- package/.docs/models/providers.md +7 -2
- package/.docs/reference/acp/acp-agent.md +2 -2
- package/.docs/reference/acp/create-acp-tool.md +1 -1
- package/.docs/reference/agent-controller/agent-controller-class.md +2 -2
- package/.docs/reference/agents/agent.md +2 -2
- package/.docs/reference/agents/channels.md +2 -2
- package/.docs/reference/agents/createSkill.md +2 -2
- package/.docs/reference/agents/durable-agent.md +1 -1
- package/.docs/reference/agents/generate.md +3 -1
- package/.docs/reference/agents/getSkill.md +1 -1
- package/.docs/reference/agents/listSkills.md +1 -1
- package/.docs/reference/agents/listSuspendedRuns.md +6 -6
- package/.docs/reference/agents/listTools.md +2 -2
- package/.docs/reference/agents/network.md +3 -1
- package/.docs/reference/ai-sdk/chat-route.md +1 -1
- package/.docs/reference/ai-sdk/handle-chat-stream.md +1 -1
- package/.docs/reference/ai-sdk/handle-network-stream.md +2 -2
- package/.docs/reference/ai-sdk/handle-workflow-stream.md +1 -1
- package/.docs/reference/ai-sdk/network-route.md +2 -2
- package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +1 -1
- package/.docs/reference/ai-sdk/workflow-route.md +1 -1
- package/.docs/reference/auth/fga.md +7 -5
- package/.docs/reference/auth/jwt.md +1 -1
- package/.docs/reference/browser/agent-browser.md +2 -2
- package/.docs/reference/browser/browser-viewer.md +2 -2
- package/.docs/reference/browser/firecrawl-browser.md +1 -1
- package/.docs/reference/browser/mastra-browser.md +1 -1
- package/.docs/reference/browser/stagehand-browser.md +2 -2
- package/.docs/reference/build-with-ai.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 +2 -0
- package/.docs/reference/client-js/agents.md +24 -4
- package/.docs/reference/coding-agent/create-coding-agent.md +142 -13
- package/.docs/reference/configuration.md +6 -6
- package/.docs/reference/core/getEditor.md +1 -1
- package/.docs/reference/core/getMCPServer.md +1 -1
- package/.docs/reference/core/getMCPServerById.md +1 -1
- package/.docs/reference/core/getTool.md +1 -1
- package/.docs/reference/core/getToolById.md +1 -1
- package/.docs/reference/core/listMCPServers.md +1 -1
- package/.docs/reference/core/listTools.md +1 -1
- package/.docs/reference/core/removeWorkspace.md +1 -1
- package/.docs/reference/editor/mastra-editor.md +2 -2
- package/.docs/reference/editor/prompt-blocks.md +2 -2
- package/.docs/reference/editor/tool-provider.md +108 -1
- package/.docs/reference/editor/tools.md +1 -1
- package/.docs/reference/editor/versioning.md +3 -3
- package/.docs/reference/evals/prompt-alignment.md +18 -0
- package/.docs/reference/evals/rubric.md +1 -1
- package/.docs/reference/file-based-agents/memory.md +2 -2
- package/.docs/reference/file-based-agents/server.md +3 -3
- package/.docs/reference/file-based-agents/skills.md +1 -1
- package/.docs/reference/file-based-agents/storage.md +3 -3
- package/.docs/reference/file-based-agents/subagents.md +1 -1
- package/.docs/reference/file-based-agents/workspace.md +3 -3
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/manual-install.md +3 -3
- package/.docs/reference/memory/memory-class.md +1 -0
- package/.docs/reference/memory/settled.md +57 -0
- package/.docs/reference/migrations/network-to-supervisor.md +2 -2
- package/.docs/reference/processors/provider-history-compat.md +6 -5
- package/.docs/reference/processors/skill-search-processor.md +3 -1
- package/.docs/reference/processors/token-limiter-processor.md +4 -0
- package/.docs/reference/processors/tool-call-filter.md +7 -7
- package/.docs/reference/processors/tool-search-processor.md +1 -1
- package/.docs/reference/project-structure.md +1 -1
- package/.docs/reference/pubsub/lease-provider.md +3 -3
- package/.docs/reference/pubsub/redis-streams.md +1 -1
- package/.docs/reference/rag/graph-rag.md +71 -8
- package/.docs/reference/rag/retrieval.md +26 -18
- package/.docs/reference/schedules/overview.md +1 -1
- package/.docs/reference/streaming/ChunkType.md +2 -2
- package/.docs/reference/streaming/agents/stream.md +29 -4
- package/.docs/reference/streaming/agents/streamUntilIdle.md +1 -1
- package/.docs/reference/tools/ask-user-tool.md +1 -1
- package/.docs/reference/tools/create-code-mode.md +1 -1
- package/.docs/reference/tools/create-tool.md +4 -4
- package/.docs/reference/tools/mcp-client.md +2 -0
- package/.docs/reference/tools/mcp-server.md +97 -4
- package/.docs/reference/tools/submit-plan-tool.md +1 -1
- package/.docs/reference/tools/task-tools.md +2 -2
- package/.docs/reference/vectors/vectorize.md +12 -2
- package/.docs/reference/workers/overview.md +2 -2
- package/.docs/reference/workspace/local-filesystem.md +1 -1
- package/.docs/reference/workspace/local-sandbox.md +4 -3
- package/.docs/reference/workspace/platform-sandbox.md +11 -0
- package/.docs/reference/workspace/process-manager.md +20 -4
- package/.docs/reference/workspace/sandbox.md +1 -1
- package/.docs/reference/workspace/workspace-class.md +5 -5
- package/CHANGELOG.md +80 -0
- package/package.json +6 -6
- package/.docs/models/providers/merge-gateway.md +0 -265
- /package/.docs/docs/{server/auth → auth}/composite-auth.md +0 -0
- /package/.docs/docs/{server/auth → auth}/jwt.md +0 -0
- /package/.docs/docs/{browser/overview.md → browser.md} +0 -0
- /package/.docs/docs/{getting-started/develop.md → develop.md} +0 -0
- /package/.docs/docs/{long-running-agents → harness}/signals.md +0 -0
- /package/.docs/docs/{editor/overview.md → studio/editor.md} +0 -0
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
A file-based agent discovers skills from its `skills/` directory and bundles them at build time. Skills are reusable procedures or reference material that the agent can load when relevant, instead of putting every detail into the always-on prompt.
|
|
8
8
|
|
|
9
|
-
Use this page for the file-based convention. For code-defined skills, see [Agent skills](https://mastra.ai/docs/
|
|
9
|
+
Use this page for the file-based convention. For code-defined skills, see [Agent skills](https://mastra.ai/docs/skills). For the `SKILL.md` package format, see [Workspace skills](https://mastra.ai/docs/sandbox/skills).
|
|
10
10
|
|
|
11
11
|
## Quickstart
|
|
12
12
|
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
6
|
|
|
7
|
-
Mastra sets the project's default [storage](https://mastra.ai/docs/storage
|
|
7
|
+
Mastra sets the project's default [storage](https://mastra.ai/docs/storage) from a `storage.ts` file directly under `src/mastra/`. The file default-exports a store, which replaces the built-in in-memory store used for memory, workflows, observability, and other storage domains.
|
|
8
8
|
|
|
9
|
-
Use this page for the file-based convention. For backend choice, storage domains, retention, and provider details, see [storage overview](https://mastra.ai/docs/storage
|
|
9
|
+
Use this page for the file-based convention. For backend choice, storage domains, retention, and provider details, see [storage overview](https://mastra.ai/docs/storage).
|
|
10
10
|
|
|
11
11
|
## Quickstart
|
|
12
12
|
|
|
@@ -25,7 +25,7 @@ Mastra registers the store before file-based agents and workflows, so storage-de
|
|
|
25
25
|
|
|
26
26
|
## Production backends
|
|
27
27
|
|
|
28
|
-
`storage.ts` can export any Mastra storage adapter, such as LibSQL, PostgreSQL, or MongoDB. For setup patterns, provider support, and schema details, see [storage overview](https://mastra.ai/docs/storage
|
|
28
|
+
`storage.ts` can export any Mastra storage adapter, such as LibSQL, PostgreSQL, or MongoDB. For setup patterns, provider support, and schema details, see [storage overview](https://mastra.ai/docs/storage), [observability signal support](https://mastra.ai/docs/observability/overview), and the [storage reference](https://mastra.ai/reference/storage/overview).
|
|
29
29
|
|
|
30
30
|
## Precedence with code
|
|
31
31
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
A file-based agent can declare **subagents**, specialist child agents it delegates to. The parent model sees each subagent as a delegation tool named after the subagent directory and calls that tool to hand off a task. The subagent's result returns to the parent conversation.
|
|
8
8
|
|
|
9
|
-
Use this page for the file-based convention. For broader delegation patterns, hooks, memory isolation, tool approval propagation, and scoring, see [Supervisor agents](https://mastra.ai/docs/
|
|
9
|
+
Use this page for the file-based convention. For broader delegation patterns, hooks, memory isolation, tool approval propagation, and scoring, see [Supervisor agents](https://mastra.ai/docs/subagents).
|
|
10
10
|
|
|
11
11
|
## Quickstart
|
|
12
12
|
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
6
6
|
|
|
7
|
-
A [workspace](https://mastra.ai/docs/
|
|
7
|
+
A [workspace](https://mastra.ai/docs/sandbox/overview) assembles capabilities such as filesystem access and command execution. The configured backends determine which tools are available. File-based agents get a default workspace automatically when discovered through `mastra dev` or `mastra build`. This default includes filesystem access and command execution, so agents can read and write files and run shell commands without extra configuration.
|
|
8
8
|
|
|
9
|
-
Use this page for the file-based convention. For workspace providers, tools, search, lifecycle, and sandbox details, see [Sandbox](https://mastra.ai/docs/
|
|
9
|
+
Use this page for the file-based convention. For workspace providers, tools, search, lifecycle, and sandbox details, see [Sandbox](https://mastra.ai/docs/sandbox/overview).
|
|
10
10
|
|
|
11
11
|
## Default workspace
|
|
12
12
|
|
|
@@ -65,7 +65,7 @@ Customize the workspace when the default local directory isn't enough. Common re
|
|
|
65
65
|
- Add workspace search with BM25 or vector search.
|
|
66
66
|
- Share one workspace across multiple agents.
|
|
67
67
|
|
|
68
|
-
For provider patterns and runtime behavior, see the [sandbox guide](https://mastra.ai/docs/
|
|
68
|
+
For provider patterns and runtime behavior, see the [sandbox guide](https://mastra.ai/docs/sandbox/overview) and [workspace search](https://mastra.ai/docs/sandbox/search).
|
|
69
69
|
|
|
70
70
|
## Runtime boundary
|
|
71
71
|
|
package/.docs/reference/index.md
CHANGED
|
@@ -211,6 +211,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
211
211
|
- [.getThreadById()](https://mastra.ai/reference/memory/getThreadById)
|
|
212
212
|
- [.listThreads()](https://mastra.ai/reference/memory/listThreads)
|
|
213
213
|
- [.recall()](https://mastra.ai/reference/memory/recall)
|
|
214
|
+
- [.settled()](https://mastra.ai/reference/memory/settled)
|
|
214
215
|
- [.summarizeThread()](https://mastra.ai/reference/memory/summarizeThread)
|
|
215
216
|
- [AgentNetwork to .network()](https://mastra.ai/reference/migrations/agentnetwork)
|
|
216
217
|
- [AI SDK v4 to v5](https://mastra.ai/reference/migrations/ai-sdk-v4-to-v5)
|
|
@@ -157,7 +157,7 @@ If you prefer not to use our automatic CLI tool, you can set up your project you
|
|
|
157
157
|
})
|
|
158
158
|
```
|
|
159
159
|
|
|
160
|
-
> **Note:** We've shortened and simplified the `weatherTool` example here. You can see the complete weather tool under [Giving an Agent a Tool](https://mastra.ai/docs/agents/
|
|
160
|
+
> **Note:** We've shortened and simplified the `weatherTool` example here. You can see the complete weather tool under [Giving an Agent a Tool](https://mastra.ai/docs/agents/tools).
|
|
161
161
|
|
|
162
162
|
5. Create a `weather-agent.ts` file:
|
|
163
163
|
|
|
@@ -244,7 +244,7 @@ If you prefer not to use our automatic CLI tool, you can set up your project you
|
|
|
244
244
|
|
|
245
245
|
- [Review the project structure](https://mastra.ai/reference/project-structure): Understand how `src/mastra/` files map to agents, tools, workflows, storage, and configuration.
|
|
246
246
|
- [Test your agent in Studio](https://mastra.ai/docs/studio/overview): Open the local Studio UI and run the weather agent.
|
|
247
|
-
- [Use tools with agents](https://mastra.ai/docs/agents/
|
|
247
|
+
- [Use tools with agents](https://mastra.ai/docs/agents/tools): Replace the example weather tool with a real tool that calls an API or service.
|
|
248
248
|
- [Add memory](https://mastra.ai/docs/memory/overview): Persist conversation history and user-specific context.
|
|
249
|
-
- [Configure storage](https://mastra.ai/docs/storage
|
|
249
|
+
- [Configure storage](https://mastra.ai/docs/storage): Add a persistent storage adapter for memory, workflows, observability, and other runtime state.
|
|
250
250
|
- [Build and deploy](https://mastra.ai/docs/deployment/overview): Build the Mastra server and deploy it to a hosting platform.
|
|
@@ -145,4 +145,5 @@ export const agent = new Agent({
|
|
|
145
145
|
- [listThreads](https://mastra.ai/reference/memory/listThreads)
|
|
146
146
|
- [deleteMessages](https://mastra.ai/reference/memory/deleteMessages)
|
|
147
147
|
- [cloneThread](https://mastra.ai/reference/memory/cloneThread)
|
|
148
|
+
- [settled](https://mastra.ai/reference/memory/settled)
|
|
148
149
|
- [Clone Utility Methods](https://mastra.ai/reference/memory/clone-utilities)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Memory.settled()
|
|
4
|
+
|
|
5
|
+
The `.settled()` method resolves once all background work the `Memory` instance started has finished. Some memory work continues after an agent run returns:
|
|
6
|
+
|
|
7
|
+
- Observational memory cycles (buffered observation and reflection, including the nested agent runs they spawn)
|
|
8
|
+
- Vector cleanup started by `deleteThread()` and `deleteMessages()`
|
|
9
|
+
|
|
10
|
+
Await this method before closing a storage connection you own. Without it, background statements can run against a closed connection.
|
|
11
|
+
|
|
12
|
+
The method is declared on the base memory class, so it's also available on the `MastraMemory` instance returned by `agent.getMemory()`.
|
|
13
|
+
|
|
14
|
+
## Usage example
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
await agent.generate('Hello', {
|
|
18
|
+
memory: { thread: 'thread-123', resource: 'user-456' },
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
await memory.settled()
|
|
22
|
+
await store.close()
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Parameters
|
|
26
|
+
|
|
27
|
+
This method takes no parameters.
|
|
28
|
+
|
|
29
|
+
## Returns
|
|
30
|
+
|
|
31
|
+
**void** (`Promise<void>`): A promise that resolves when all background memory work has finished. Background work that fails does not reject this promise.
|
|
32
|
+
|
|
33
|
+
## Extended usage example
|
|
34
|
+
|
|
35
|
+
Test suites and short-lived processes are the most common places to need this, since they close the store immediately after a run finishes.
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { Memory } from '@mastra/memory'
|
|
39
|
+
import { PostgresStore } from '@mastra/pg'
|
|
40
|
+
|
|
41
|
+
const store = new PostgresStore({ connectionString })
|
|
42
|
+
const memory = new Memory({ storage: store })
|
|
43
|
+
|
|
44
|
+
// ... run your agent ...
|
|
45
|
+
|
|
46
|
+
// Wait for observational memory and vector cleanup to finish before closing.
|
|
47
|
+
await memory.settled()
|
|
48
|
+
await store.close()
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
> **Note:** `settled()` joins the work that had started by the time you called it, plus any work that work enqueues. It does not prevent new work from starting afterwards, so call it once the agent runs you care about have returned.
|
|
52
|
+
|
|
53
|
+
## Related
|
|
54
|
+
|
|
55
|
+
- [Memory Class Reference](https://mastra.ai/reference/memory/memory-class)
|
|
56
|
+
- [Observational Memory](https://mastra.ai/docs/memory/observational-memory)
|
|
57
|
+
- [deleteMessages](https://mastra.ai/reference/memory/deleteMessages)
|
|
@@ -255,9 +255,9 @@ const stream = await supervisorAgent.stream('Research AI in education', {
|
|
|
255
255
|
|
|
256
256
|
## See also
|
|
257
257
|
|
|
258
|
-
- [Supervisor Agents](https://mastra.ai/docs/
|
|
258
|
+
- [Supervisor Agents](https://mastra.ai/docs/subagents)
|
|
259
259
|
- [Agent Networks](https://mastra.ai/docs/agents/networks)
|
|
260
260
|
- [Agent.stream() Reference](https://mastra.ai/reference/streaming/agents/stream)
|
|
261
261
|
- [Agent.generate() Reference](https://mastra.ai/reference/agents/generate)
|
|
262
|
-
- [Agent Approval](https://mastra.ai/docs/agents/
|
|
262
|
+
- [Agent Approval](https://mastra.ai/docs/agents/human-in-the-loop)
|
|
263
263
|
- [Guide: Research Coordinator](https://mastra.ai/blog/build-a-research-coordinator-with-supervisor-agents)
|
|
@@ -45,11 +45,12 @@ Mastra agents don't add this processor automatically. Add it explicitly when you
|
|
|
45
45
|
|
|
46
46
|
`ProviderHistoryCompat` includes these built-in compatibility rules:
|
|
47
47
|
|
|
48
|
-
| Rule | Provider
|
|
49
|
-
| ------------------------------------------- |
|
|
50
|
-
| `anthropic-tool-id-format` | Anthropic
|
|
51
|
-
| `cerebras-strip-reasoning-content` | Cerebras
|
|
52
|
-
| `anthropic-strip-foreign-reasoning-content` | Anthropic
|
|
48
|
+
| Rule | Provider | Timing | Behavior |
|
|
49
|
+
| ------------------------------------------- | ------------ | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
50
|
+
| `anthropic-tool-id-format` | Anthropic | Reactive API error recovery | Rewrites tool call IDs that contain characters outside `[a-zA-Z0-9_-]` and retries the request. |
|
|
51
|
+
| `cerebras-strip-reasoning-content` | Cerebras | Preemptive prompt rewrite | Removes assistant `reasoning` parts from the outbound prompt so they're not serialized as unsupported `reasoning_content` fields. |
|
|
52
|
+
| `anthropic-strip-foreign-reasoning-content` | Anthropic | Preemptive prompt rewrite | Removes non-Anthropic assistant `reasoning` parts from the outbound prompt. Anthropic-native thinking history is preserved. |
|
|
53
|
+
| `azure-system-reminder-transform` | Azure OpenAI | Preemptive prompt rewrite | Renames `<system-reminder>` wrappers in user text and system instructions to `<memory-context>` for the outbound request. Stored history remains unchanged. |
|
|
53
54
|
|
|
54
55
|
Preemptive rules run through `processLLMRequest` after Mastra converts messages to the model prompt format and before the prompt is sent to the provider. These rewrites affect only the current provider call.
|
|
55
56
|
|
|
@@ -41,6 +41,8 @@ const skillSearch = new SkillSearchProcessor({
|
|
|
41
41
|
|
|
42
42
|
**options.ttl** (`number`): Time-to-live for thread state in milliseconds. After this duration of inactivity, thread state will be cleaned up. Set to 0 to disable cleanup.
|
|
43
43
|
|
|
44
|
+
**options.blockingRefresh** (`boolean`): When true, awaits the skills staleness check before the first step of each request so skill changes appear in the same turn. When false, the cached catalog is served and revalidated in the background, so skill changes can lag by one turn plus the staleness cooldown (up to 30 seconds).
|
|
45
|
+
|
|
44
46
|
## Returns
|
|
45
47
|
|
|
46
48
|
**id** (`string`): Processor identifier set to 'skill-search'
|
|
@@ -112,4 +114,4 @@ Reserve workspace file tools such as `mastra_workspace_read_file` for explicit f
|
|
|
112
114
|
|
|
113
115
|
- [ToolSearchProcessor](https://mastra.ai/reference/processors/tool-search-processor)
|
|
114
116
|
- [Processors](https://mastra.ai/docs/agents/processors)
|
|
115
|
-
- [Workspace Skills](https://mastra.ai/docs/
|
|
117
|
+
- [Workspace Skills](https://mastra.ai/docs/sandbox/skills)
|
|
@@ -64,6 +64,10 @@ for await (const part of stream.fullStream) {
|
|
|
64
64
|
}
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
+
## Media token counting
|
|
68
|
+
|
|
69
|
+
Images and file attachments are estimated rather than tokenized. This applies to `file` message parts and to tool results shaped like `{ data, mediaType }`. Images use a flat per-image estimate, other media is estimated from its decoded byte size, and remote URLs or provider file ids use a flat fallback because their size isn't known locally. Encoded payloads such as base64 data are never counted as text, which would otherwise inflate the count by an order of magnitude and truncate history unnecessarily.
|
|
70
|
+
|
|
67
71
|
## Error behavior
|
|
68
72
|
|
|
69
73
|
When used as an input processor (both `processInput` and `processInputStep`), `TokenLimiterProcessor` throws a `TripWire` error in the following cases:
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# ToolCallFilter
|
|
4
4
|
|
|
5
|
-
The `ToolCallFilter` is an **input processor** that filters out tool calls and their results from the
|
|
5
|
+
The `ToolCallFilter` is an **input processor** that filters out tool calls and their results from the prompt sent to the model. This is useful when you want to exclude specific tool interactions from context or remove all tool calls entirely.
|
|
6
|
+
|
|
7
|
+
Filtering happens in the `processLLMRequest` hook, which runs after the message list is converted to a model prompt. Changes are transient: they affect only what's sent to the model on that call. Stored messages, memory, and UI history keep their original tool calls and results.
|
|
6
8
|
|
|
7
9
|
## Usage example
|
|
8
10
|
|
|
@@ -44,13 +46,11 @@ const filterWithCompactToolHistory = new ToolCallFilter({
|
|
|
44
46
|
|
|
45
47
|
**name** (`string`): Processor display name set to 'ToolCallFilter'
|
|
46
48
|
|
|
47
|
-
**
|
|
48
|
-
|
|
49
|
-
**processInputStep** (`(args: ProcessInputStepArgs) => Promise<ProcessInputStepResult>`): Processes agent loop step input when filterAfterToolSteps is configured. Returns no changes when step filtering is disabled
|
|
49
|
+
**processLLMRequest** (`(args: ProcessLLMRequestArgs) => Promise<ProcessLLMRequestResult | undefined>`): Filters tool calls and results out of the model prompt before it is sent to the provider. Returns undefined when nothing is filtered. Changes are transient and are not persisted to the message list or memory
|
|
50
50
|
|
|
51
51
|
## Step filtering
|
|
52
52
|
|
|
53
|
-
By default, `ToolCallFilter` filters
|
|
53
|
+
By default, `ToolCallFilter` filters tool calls from history but leaves tool calls made during the current agent loop in place. Set `filterAfterToolSteps` to also filter tool calls produced by the current loop.
|
|
54
54
|
|
|
55
55
|
`filterAfterToolSteps` counts tool-producing steps. For example, `filterAfterToolSteps: 2` keeps tool calls and results from the two most recent tool-producing steps and filters older tool calls and results. Non-tool text remains in context.
|
|
56
56
|
|
|
@@ -64,9 +64,9 @@ const filter = new ToolCallFilter({
|
|
|
64
64
|
|
|
65
65
|
## Preserve compact model output
|
|
66
66
|
|
|
67
|
-
Set `preserveModelOutput: true` to retain compact `toModelOutput` history for
|
|
67
|
+
Set `preserveModelOutput: true` to retain compact `toModelOutput` history for tool results that the filter removes. The removed tool call and result are replaced with a single text part in the prompt, so the model still sees the output while the raw tool arguments are dropped.
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
Tool results without model output that can be represented as text are removed entirely.
|
|
70
70
|
|
|
71
71
|
```typescript
|
|
72
72
|
const filter = new ToolCallFilter({
|
|
@@ -44,7 +44,7 @@ Mastra recommends organizing your code into the following folders:
|
|
|
44
44
|
|
|
45
45
|
Mastra has two special folder conventions:
|
|
46
46
|
|
|
47
|
-
- `src/mastra/agents/<name>`: You can define an agent by file convention instead of constructing it in code. Learn more in the [File-based Agents](https://mastra.ai/docs/
|
|
47
|
+
- `src/mastra/agents/<name>`: You can define an agent by file convention instead of constructing it in code. Learn more in the [File-based Agents](https://mastra.ai/docs/develop) docs.
|
|
48
48
|
- `src/mastra/public`: Contents are copied into the `.build/output` directory during the build process, making them available for serving at runtime.
|
|
49
49
|
|
|
50
50
|
### Top-level files
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# LeaseProvider
|
|
4
4
|
|
|
5
|
-
`LeaseProvider` is the distributed leasing contract, separate from event delivery ([`PubSub`](https://mastra.ai/reference/pubsub/base)). Mastra's [signals layer](https://mastra.ai/docs/
|
|
5
|
+
`LeaseProvider` is the distributed leasing contract, separate from event delivery ([`PubSub`](https://mastra.ai/reference/pubsub/base)). Mastra's [signals layer](https://mastra.ai/docs/harness/signals) uses it to elect a single owner across multiple processes (for example, serverless invocations) for a resource, most commonly a thread key. The owner is the process that wakes and runs the agent stream, so other processes route follow-up work to it instead of starting a competing run.
|
|
6
6
|
|
|
7
7
|
Leasing is a distinct concern from pub/sub. A backend implements `LeaseProvider` only when it can actually coordinate a lock, such as Redis via atomic `SET`/Lua, or an in-memory map for single-process. Backends that can't lease omit it; the signals runtime feature-detects the capability and falls back to a no-op provider, preserving single-process behavior.
|
|
8
8
|
|
|
@@ -129,5 +129,5 @@ When the configured pub/sub backend doesn't implement `LeaseProvider`, the runti
|
|
|
129
129
|
|
|
130
130
|
- [PubSub](https://mastra.ai/reference/pubsub/base): The event delivery contract, separate from leasing
|
|
131
131
|
- [RedisStreamsPubSub](https://mastra.ai/reference/pubsub/redis-streams): The built-in backend that implements `LeaseProvider`
|
|
132
|
-
- [Signals](https://mastra.ai/docs/
|
|
133
|
-
- [Channels](https://mastra.ai/docs/
|
|
132
|
+
- [Signals](https://mastra.ai/docs/harness/signals): The runtime that uses leasing to coordinate thread execution across processes
|
|
133
|
+
- [Channels](https://mastra.ai/docs/channels): Uses leasing to coordinate agent runs in serverless and multi-instance deployments
|
|
@@ -131,7 +131,7 @@ When a subscriber calls `nack`, the event is republished with an incremented `de
|
|
|
131
131
|
|
|
132
132
|
## Distributed leasing
|
|
133
133
|
|
|
134
|
-
`RedisStreamsPubSub` implements the [`LeaseProvider`](https://mastra.ai/reference/pubsub/lease-provider) contract on top of the same Redis connection. The [signals runtime](https://mastra.ai/docs/
|
|
134
|
+
`RedisStreamsPubSub` implements the [`LeaseProvider`](https://mastra.ai/reference/pubsub/lease-provider) contract on top of the same Redis connection. The [signals runtime](https://mastra.ai/docs/harness/signals) uses it to elect a single owner (usually per thread key) so that across instances only one process wakes and runs the agent, and others route follow-up work to the holder. This is what makes signals work on serverless and multi-instance deployments; without a shared lease, each instance would start its own competing run.
|
|
135
135
|
|
|
136
136
|
Lease keys are namespaced under the same `keyPrefix` as topics, as `<keyPrefix>:lease:<key>`. All operations are atomic: `acquireLease` uses `SET NX PX` and refreshes its own TTL idempotently, while `releaseLease`, `renewLease`, and `transferLease` use Lua scripts that check ownership before mutating, so a concurrent renewal from another owner is never clobbered.
|
|
137
137
|
|
|
@@ -9,10 +9,7 @@ The `GraphRAG` class implements a graph-based approach to retrieval augmented ge
|
|
|
9
9
|
```typescript
|
|
10
10
|
import { GraphRAG } from '@mastra/rag'
|
|
11
11
|
|
|
12
|
-
const graphRag = new GraphRAG(
|
|
13
|
-
dimension: 1536,
|
|
14
|
-
threshold: 0.7,
|
|
15
|
-
})
|
|
12
|
+
const graphRag = new GraphRAG(1536, 0.7)
|
|
16
13
|
|
|
17
14
|
// Create the graph from chunks and embeddings
|
|
18
15
|
graphRag.createGraph(documentChunks, embeddings)
|
|
@@ -88,13 +85,79 @@ Returns an array of `RankedNode` objects, where each node contains:
|
|
|
88
85
|
|
|
89
86
|
**score** (`number`): Combined relevance score from graph traversal
|
|
90
87
|
|
|
88
|
+
### `serialize`
|
|
89
|
+
|
|
90
|
+
Returns a JSON-safe snapshot of the graph so it can be persisted and restored later instead of rebuilt with `createGraph`.
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
serialize(): GraphRAGSnapshot
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### Returns
|
|
97
|
+
|
|
98
|
+
Returns a `GraphRAGSnapshot` object containing:
|
|
99
|
+
|
|
100
|
+
**version** (`number`): Snapshot format version, used to reject snapshots this version of the class can't load
|
|
101
|
+
|
|
102
|
+
**dimension** (`number`): Dimension of the embedding vectors the graph was built with
|
|
103
|
+
|
|
104
|
+
**threshold** (`number`): Similarity threshold the graph was built with
|
|
105
|
+
|
|
106
|
+
**nodes** (`GraphNode[]`): All nodes in the graph, each including its full embedding
|
|
107
|
+
|
|
108
|
+
**edges** (`GraphEdge[]`): All edges in the graph
|
|
109
|
+
|
|
110
|
+
The snapshot is a deep copy, so mutating it doesn't affect the graph it came from. Every node carries its full embedding, so snapshots are large: a 1,000-node graph built with 1536-dimension embeddings serializes to about 20 MB of JSON. Size your storage column accordingly.
|
|
111
|
+
|
|
112
|
+
### `deserialize`
|
|
113
|
+
|
|
114
|
+
Rebuilds a `GraphRAG` instance from a snapshot produced by `serialize`.
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
static deserialize(snapshot: GraphRAGSnapshot): GraphRAG
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### Parameters
|
|
121
|
+
|
|
122
|
+
**snapshot** (`GraphRAGSnapshot`): A snapshot previously returned by serialize
|
|
123
|
+
|
|
124
|
+
Throws if the snapshot version is unsupported, if a node embedding doesn't match the snapshot dimension, or if an edge references a node that isn't in the snapshot. A bad snapshot therefore fails at load time instead of during a later query.
|
|
125
|
+
|
|
126
|
+
## Persisting a graph
|
|
127
|
+
|
|
128
|
+
Building a graph is O(n²) in the number of chunks, so rebuilding it on every process start is wasteful. Serialize the graph once and store the snapshot wherever you already keep state. A snapshot is plain JSON, so any store works (a file, a blob column, a key-value cache), and `GraphRAG` doesn't depend on a storage backend.
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { readFile, writeFile } from 'node:fs/promises'
|
|
132
|
+
import { GraphRAG } from '@mastra/rag'
|
|
133
|
+
import type { GraphRAGSnapshot } from '@mastra/rag'
|
|
134
|
+
|
|
135
|
+
const SNAPSHOT_PATH = './docs-graph.json'
|
|
136
|
+
|
|
137
|
+
async function loadOrBuildGraph() {
|
|
138
|
+
try {
|
|
139
|
+
const snapshot = JSON.parse(await readFile(SNAPSHOT_PATH, 'utf8')) as GraphRAGSnapshot
|
|
140
|
+
return GraphRAG.deserialize(snapshot)
|
|
141
|
+
} catch {
|
|
142
|
+
// No usable snapshot yet, so build the graph from scratch
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const graphRag = new GraphRAG(1536, 0.7)
|
|
146
|
+
graphRag.createGraph(documentChunks, embeddings)
|
|
147
|
+
|
|
148
|
+
await writeFile(SNAPSHOT_PATH, JSON.stringify(graphRag.serialize()))
|
|
149
|
+
|
|
150
|
+
return graphRag
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
A snapshot reflects the chunks it was built from and isn't updated incrementally. When the underlying documents change, build the graph again and store a new snapshot.
|
|
155
|
+
|
|
91
156
|
## Advanced example
|
|
92
157
|
|
|
93
158
|
```typescript
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
threshold: 0.8, // Stricter similarity threshold
|
|
97
|
-
})
|
|
159
|
+
// Stricter similarity threshold
|
|
160
|
+
const graphRag = new GraphRAG(1536, 0.8)
|
|
98
161
|
|
|
99
162
|
// Create graph from chunks and embeddings
|
|
100
163
|
graphRag.createGraph(documentChunks, embeddings)
|
|
@@ -266,6 +266,23 @@ For detailed configuration options and advanced usage, see the [Vector Query Too
|
|
|
266
266
|
|
|
267
267
|
Vector store prompts define query patterns and filtering capabilities for each vector database implementation. When implementing filtering, these prompts are required in the agent's instructions to specify valid operators and syntax for each vector store implementation.
|
|
268
268
|
|
|
269
|
+
**MongoDB**:
|
|
270
|
+
|
|
271
|
+
```ts
|
|
272
|
+
import { MONGODB_PROMPT } from '@mastra/mongodb'
|
|
273
|
+
|
|
274
|
+
export const ragAgent = new Agent({
|
|
275
|
+
id: 'rag-agent',
|
|
276
|
+
name: 'RAG Agent',
|
|
277
|
+
model: 'openai/gpt-5.6-sol',
|
|
278
|
+
instructions: `
|
|
279
|
+
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
280
|
+
${MONGODB_PROMPT}
|
|
281
|
+
`,
|
|
282
|
+
tools: { vectorQueryTool },
|
|
283
|
+
})
|
|
284
|
+
```
|
|
285
|
+
|
|
269
286
|
**pgVector**:
|
|
270
287
|
|
|
271
288
|
```ts
|
|
@@ -402,23 +419,6 @@ export const ragAgent = new Agent({
|
|
|
402
419
|
})
|
|
403
420
|
```
|
|
404
421
|
|
|
405
|
-
**MongoDB**:
|
|
406
|
-
|
|
407
|
-
```ts
|
|
408
|
-
import { MONGODB_PROMPT } from '@mastra/mongodb'
|
|
409
|
-
|
|
410
|
-
export const ragAgent = new Agent({
|
|
411
|
-
id: 'rag-agent',
|
|
412
|
-
name: 'RAG Agent',
|
|
413
|
-
model: 'openai/gpt-5.6-sol',
|
|
414
|
-
instructions: `
|
|
415
|
-
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
416
|
-
${MONGODB_PROMPT}
|
|
417
|
-
`,
|
|
418
|
-
tools: { vectorQueryTool },
|
|
419
|
-
})
|
|
420
|
-
```
|
|
421
|
-
|
|
422
422
|
**OpenSearch**:
|
|
423
423
|
|
|
424
424
|
```ts
|
|
@@ -520,7 +520,13 @@ The weights control how different factors influence the final ranking:
|
|
|
520
520
|
|
|
521
521
|
> **Note:** For semantic scoring to work properly during re-ranking, each result must include the text content in its `metadata.text` field.
|
|
522
522
|
|
|
523
|
-
You can also use other relevance score providers like Cohere or ZeroEntropy:
|
|
523
|
+
You can also use other relevance score providers like Voyage AI, Cohere, or ZeroEntropy:
|
|
524
|
+
|
|
525
|
+
```ts
|
|
526
|
+
import { VoyageRelevanceScorer } from '@mastra/voyageai'
|
|
527
|
+
|
|
528
|
+
const relevanceProvider = new VoyageRelevanceScorer({ model: 'rerank-2.5' })
|
|
529
|
+
```
|
|
524
530
|
|
|
525
531
|
```ts
|
|
526
532
|
const relevanceProvider = new CohereRelevanceScorer('rerank-v3.5')
|
|
@@ -530,6 +536,8 @@ const relevanceProvider = new CohereRelevanceScorer('rerank-v3.5')
|
|
|
530
536
|
const relevanceProvider = new ZeroEntropyRelevanceScorer('zerank-1')
|
|
531
537
|
```
|
|
532
538
|
|
|
539
|
+
Voyage AI provides dedicated reranking models: `rerank-2.5` and `rerank-2.5-lite` both allow up to 32,000 tokens for the query and any single document combined, and up to 600,000 tokens across a request. `VoyageRelevanceScorer` reads `VOYAGE_API_KEY` from the environment, or accepts an `apiKey` in its config.
|
|
540
|
+
|
|
533
541
|
The re-ranked results combine vector similarity with semantic understanding to improve retrieval quality.
|
|
534
542
|
|
|
535
543
|
For more details about re-ranking, see the [rerank()](https://mastra.ai/reference/rag/rerankWithScorer) method.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
`mastra.schedules` is the CRUD service for persisted cron schedules. Use it to create, list, update, pause, resume, manually run, and delete schedules for agents or workflows.
|
|
10
10
|
|
|
11
|
-
For usage patterns and concepts, see [Schedules](https://mastra.ai/docs/
|
|
11
|
+
For usage patterns and concepts, see [Schedules](https://mastra.ai/docs/harness/schedules).
|
|
12
12
|
|
|
13
13
|
## Usage example
|
|
14
14
|
|
|
@@ -402,7 +402,7 @@ Contains output from workflow step execution, used primarily for usage tracking
|
|
|
402
402
|
|
|
403
403
|
## Background task chunks
|
|
404
404
|
|
|
405
|
-
Emitted when a tool call is dispatched as a [background task](https://mastra.ai/docs/
|
|
405
|
+
Emitted when a tool call is dispatched as a [background task](https://mastra.ai/docs/harness/background-tasks) and `streamUntilIdle()` is used.
|
|
406
406
|
|
|
407
407
|
### background-task-started
|
|
408
408
|
|
|
@@ -614,7 +614,7 @@ Contains monitoring and observability data from agent execution. Can include wor
|
|
|
614
614
|
|
|
615
615
|
### goal
|
|
616
616
|
|
|
617
|
-
Emitted on every evaluation of an agent [goal](https://mastra.ai/docs/
|
|
617
|
+
Emitted on every evaluation of an agent [goal](https://mastra.ai/docs/harness/goals). Consumers use this to render judge progress and the result mid-run. A goal that has no judge model configured produces no `goal` chunk.
|
|
618
618
|
|
|
619
619
|
**type** (`"goal"`): Chunk type identifier
|
|
620
620
|
|
|
@@ -80,7 +80,7 @@ const stream = await agent.stream('message for agent')
|
|
|
80
80
|
|
|
81
81
|
**options.onError** (`({ error }: { error: Error | string }) => Promise<void> | void`): Callback function called when an error occurs during streaming.
|
|
82
82
|
|
|
83
|
-
**options.onAbort** (`(event: any) => Promise<void> | void`): Callback function called when the stream is aborted.
|
|
83
|
+
**options.onAbort** (`(event: { steps: any[]; text?: string }) => Promise<void> | void`): Callback function called when the stream is aborted. steps contains the steps that completed before the abort, and text contains the assistant text streamed so far for the step that was in flight.
|
|
84
84
|
|
|
85
85
|
**options.abortSignal** (`AbortSignal`): Signal object that allows you to abort the agent's execution. When the signal is aborted, all ongoing operations will be terminated, including any in-flight subagent runs the agent delegated to.
|
|
86
86
|
|
|
@@ -158,6 +158,8 @@ const stream = await agent.stream('message for agent')
|
|
|
158
158
|
|
|
159
159
|
**options.modelSettings.frequencyPenalty** (`number`): Penalty for token frequency (-2 to 2). Reduces repetition of frequent tokens.
|
|
160
160
|
|
|
161
|
+
**options.modelSettings.timeout** (`object`): Time-based execution budget for the run. Accepts totalMs, the maximum duration of the entire agent run across every loop iteration, tool call and retry, and stepMs, the maximum duration of a single model call including the time spent consuming its stream. Exceeding either budget fails with a MastraTimeoutError. A totalMs timeout ends the run and does not try fallback models, because it is a hard deadline for the whole run. A stepMs timeout is not retried against the same model but does advance to the next entry in models when fallback models are configured.
|
|
162
|
+
|
|
161
163
|
**options.modelSettings.stopSequences** (`string[]`): Stop sequences. If set, the model will stop generating text when one of the stop sequences is generated.
|
|
162
164
|
|
|
163
165
|
**options.toolChoice** (`'auto' | 'none' | 'required' | { type: 'tool'; toolName: string }`): Controls how the agent uses tools during streaming.
|
|
@@ -178,6 +180,8 @@ const stream = await agent.stream('message for agent')
|
|
|
178
180
|
|
|
179
181
|
**options.savePerStep** (`boolean`): Save messages incrementally after each stream step completes (default: false).
|
|
180
182
|
|
|
183
|
+
**options.persistPartialOnAbort** (`boolean`): Save the assistant text that was streamed before an abort to memory (default: false). Only text emitted before the abort is persisted; output a provider keeps producing after cancellation is discarded, and nothing is saved when no text was streamed.
|
|
184
|
+
|
|
181
185
|
**options.requireToolApproval** (`boolean`): When true, all tool calls require explicit approval before execution. The stream will emit tool-call-approval chunks and pause until approveToolCall() or declineToolCall() is called.
|
|
182
186
|
|
|
183
187
|
**options.autoResumeSuspendedTools** (`boolean`): When true, automatically resumes suspended tools when the user sends a new message on the same thread. The agent extracts resumeData from the user's message based on the tool's resumeSchema. Requires memory to be configured.
|
|
@@ -262,6 +266,26 @@ for await (const chunk of stream.fullStream) {
|
|
|
262
266
|
const fullText = await stream.text
|
|
263
267
|
```
|
|
264
268
|
|
|
269
|
+
### Limiting execution time
|
|
270
|
+
|
|
271
|
+
Use `modelSettings.timeout` to bound how long a run may take. `totalMs` limits the entire run, including every loop iteration, tool call and retry. `stepMs` limits a single model call, covering both establishing the stream and consuming it.
|
|
272
|
+
|
|
273
|
+
```ts
|
|
274
|
+
const stream = await agent.stream('Tell me a story', {
|
|
275
|
+
modelSettings: {
|
|
276
|
+
timeout: {
|
|
277
|
+
totalMs: 30000, // fail the run if it takes longer than 30s
|
|
278
|
+
stepMs: 10000, // fail an individual model call after 10s
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
})
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Exceeding either budget fails with a `MastraTimeoutError`, which carries a `timeoutType` of `'total'` or `'step'`. Each budget behaves differently when the agent is configured with fallback [`models`](https://mastra.ai/reference/agents/agent):
|
|
285
|
+
|
|
286
|
+
- A `totalMs` timeout ends the run immediately and doesn't try the next model, because it's a hard deadline for the run as a whole.
|
|
287
|
+
- A `stepMs` timeout isn't retried against the same model, but does advance to the next model, which makes it a way to fail over from a slow provider.
|
|
288
|
+
|
|
265
289
|
### AI SDK v5+ Format
|
|
266
290
|
|
|
267
291
|
To use the stream with AI SDK v5 (and later), you can convert it using our utility function `toAISdkStream`.
|
|
@@ -301,8 +325,9 @@ const stream = await agent.stream('Tell me a story', {
|
|
|
301
325
|
onError: ({ error }) => {
|
|
302
326
|
console.error('Streaming error:', error)
|
|
303
327
|
},
|
|
304
|
-
onAbort:
|
|
305
|
-
console.log('Stream aborted
|
|
328
|
+
onAbort: ({ steps, text }) => {
|
|
329
|
+
console.log('Stream aborted after', steps.length, 'steps')
|
|
330
|
+
console.log('Partial text:', text)
|
|
306
331
|
},
|
|
307
332
|
})
|
|
308
333
|
|
|
@@ -399,4 +424,4 @@ Responses WebSocket connections run one response at a time. Mastra rejects overl
|
|
|
399
424
|
|
|
400
425
|
- [Generating responses](https://mastra.ai/docs/agents/overview)
|
|
401
426
|
- [Streaming responses](https://mastra.ai/docs/agents/overview)
|
|
402
|
-
- [Agent Approval](https://mastra.ai/docs/agents/
|
|
427
|
+
- [Agent Approval](https://mastra.ai/docs/agents/human-in-the-loop)
|
|
@@ -101,7 +101,7 @@ for await (const chunk of stream.fullStream) {
|
|
|
101
101
|
|
|
102
102
|
## Related
|
|
103
103
|
|
|
104
|
-
- [Background tasks](https://mastra.ai/docs/
|
|
104
|
+
- [Background tasks](https://mastra.ai/docs/harness/background-tasks)
|
|
105
105
|
- [`Agent.stream()` reference](https://mastra.ai/reference/streaming/agents/stream)
|
|
106
106
|
- [backgroundTasks configuration reference](https://mastra.ai/reference/configuration)
|
|
107
107
|
- [Stream chunk types](https://mastra.ai/reference/streaming/ChunkType)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
A built-in, agent-agnostic tool that asks the user a question and waits for their response. The tool supports free-text questions, single-select prompts, and multi-select prompts.
|
|
6
6
|
|
|
7
|
-
The tool pauses through the native [tool suspension](https://mastra.ai/docs/agents/
|
|
7
|
+
The tool pauses through the native [tool suspension](https://mastra.ai/docs/agents/human-in-the-loop) primitive: it calls `suspend()` with the question payload, which makes the agent emit a `tool-call-suspended` event and persist run state. Resume the run with `agent.resumeStream(answer, { runId })`.
|
|
8
8
|
|
|
9
9
|
When executed outside an agent run (no `suspend` available), the tool returns a readable fallback string containing the question and choices.
|
|
10
10
|
|
|
@@ -126,4 +126,4 @@ export const codeModeTool = createCodeModeTool({
|
|
|
126
126
|
|
|
127
127
|
- [Code mode](https://mastra.ai/docs/agents/code-mode)
|
|
128
128
|
- [createTool()](https://mastra.ai/reference/tools/create-tool)
|
|
129
|
-
- [Sandbox](https://mastra.ai/docs/
|
|
129
|
+
- [Sandbox](https://mastra.ai/docs/sandbox/overview)
|
|
@@ -519,8 +519,8 @@ These annotations follow the [MCP specification](https://spec.modelcontextprotoc
|
|
|
519
519
|
|
|
520
520
|
## Related
|
|
521
521
|
|
|
522
|
-
- [MCP Overview](https://mastra.ai/docs/mcp
|
|
523
|
-
- [Using Tools with Agents](https://mastra.ai/docs/agents/
|
|
524
|
-
- [Agent Approval](https://mastra.ai/docs/agents/
|
|
525
|
-
- [Tool Streaming](https://mastra.ai/docs/agents/
|
|
522
|
+
- [MCP Overview](https://mastra.ai/docs/connections/mcp)
|
|
523
|
+
- [Using Tools with Agents](https://mastra.ai/docs/agents/tools)
|
|
524
|
+
- [Agent Approval](https://mastra.ai/docs/agents/human-in-the-loop)
|
|
525
|
+
- [Tool Streaming](https://mastra.ai/docs/agents/tools)
|
|
526
526
|
- [Request Context](https://mastra.ai/docs/server/request-context)
|