@mastra/mcp-docs-server 1.3.9 → 1.3.10-alpha.2
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/code-mode.md +2 -2
- package/.docs/docs/agents/guardrails.md +5 -5
- package/.docs/docs/agents/human-in-the-loop.md +18 -5
- package/.docs/docs/agents/networks.md +1 -1
- package/.docs/docs/agents/overview.md +7 -7
- package/.docs/docs/agents/processors.md +66 -20
- package/.docs/docs/agents/structured-output.md +6 -6
- package/.docs/docs/agents/tools.md +10 -10
- package/.docs/docs/browser.md +13 -1
- package/.docs/docs/channels.md +33 -6
- package/.docs/docs/connections/a2a.md +1 -1
- package/.docs/docs/connections/acp.md +2 -2
- package/.docs/docs/connections/mcp.md +159 -50
- package/.docs/docs/connections/overview.md +1 -1
- package/.docs/docs/connections/sdk-agents.md +8 -8
- package/.docs/docs/develop.md +1 -1
- package/.docs/docs/evals/custom-scorers.md +5 -5
- package/.docs/docs/evals/experiments.md +2 -2
- package/.docs/docs/evals/multi-turn.md +2 -2
- package/.docs/docs/evals/overview.md +4 -4
- package/.docs/docs/evals/quick-checks.md +2 -2
- package/.docs/docs/guides/build-an-eval-loop.md +3 -3
- package/.docs/docs/guides/context-engineering.md +13 -6
- package/.docs/docs/guides/mcp-authentication-authorization.md +2 -2
- package/.docs/docs/guides/streaming.md +1 -1
- package/.docs/docs/harness/agent-controller.md +7 -7
- package/.docs/docs/harness/background-tasks.md +3 -3
- package/.docs/docs/harness/durable-agents.md +5 -5
- package/.docs/docs/harness/goals.md +5 -5
- package/.docs/docs/harness/overview.md +2 -2
- package/.docs/docs/harness/schedules.md +5 -5
- package/.docs/docs/index.md +6 -6
- package/.docs/docs/mastra-platform/connect/channels.md +1 -1
- package/.docs/docs/mastra-platform/connect/tools.md +4 -4
- package/.docs/docs/mastra-platform/observability.md +1 -1
- package/.docs/docs/memory/memory-processors.md +7 -7
- package/.docs/docs/memory/message-history.md +5 -5
- package/.docs/docs/memory/multi-user-threads.md +1 -1
- package/.docs/docs/memory/observational-memory.md +14 -14
- package/.docs/docs/memory/semantic-recall.md +2 -2
- package/.docs/docs/memory/working-memory.md +2 -2
- package/.docs/docs/observability/logging.md +5 -5
- package/.docs/docs/observability/tracing/overview.md +1 -0
- package/.docs/docs/sandbox/filesystem.md +1 -0
- package/.docs/docs/sandbox/overview.md +1 -1
- package/.docs/docs/server/mastra-client.md +1 -1
- package/.docs/docs/server/middleware.md +1 -1
- package/.docs/docs/server/request-context.md +3 -3
- package/.docs/docs/server/server-adapters.md +12 -204
- package/.docs/docs/signals/notifications.md +233 -0
- package/.docs/docs/signals/overview.md +94 -0
- package/.docs/docs/signals/running-across-processes.md +132 -0
- package/.docs/docs/signals/sending-signals.md +166 -0
- package/.docs/docs/signals/signal-providers.md +278 -0
- package/.docs/docs/signals/state-signals.md +103 -0
- package/.docs/docs/signals/thread-streams.md +94 -0
- package/.docs/docs/skills.md +4 -4
- package/.docs/docs/storage.md +1 -1
- package/.docs/docs/studio/editor.md +39 -23
- package/.docs/docs/subagents.md +6 -6
- package/.docs/integrations/agentic-ui/ai-sdk-ui.md +1 -1
- package/.docs/integrations/agentic-ui/copilotkit.md +1 -1
- package/.docs/integrations/agentic-ui/openui.md +1 -1
- package/.docs/integrations/browsers/agent-browser.md +1 -1
- package/.docs/integrations/browsers/browser-viewer.md +1 -1
- package/.docs/integrations/browsers/firecrawl.md +1 -1
- package/.docs/integrations/browsers/stagehand.md +6 -6
- package/.docs/integrations/channels/discord.md +1 -1
- package/.docs/integrations/channels/github.md +2 -2
- package/.docs/integrations/channels/imessage.md +2 -50
- package/.docs/integrations/channels/slack.md +1 -1
- package/.docs/integrations/channels/teams.md +1 -1
- package/.docs/integrations/channels/telegram.md +1 -1
- package/.docs/integrations/channels/whatsapp.md +1 -1
- package/.docs/integrations/databases/aurora-dsql.md +1 -1
- package/.docs/integrations/databases/cloudflare-kv.md +4 -0
- package/.docs/integrations/databases/elasticsearch.md +1 -1
- package/.docs/integrations/databases/mongodb.md +1 -1
- package/.docs/integrations/databases/oracledb.md +1 -1
- package/.docs/integrations/databases/postgresql.md +1 -1
- package/.docs/integrations/databases/redis.md +1 -1
- package/.docs/integrations/databases/upstash.md +1 -1
- package/.docs/integrations/deploy/kubernetes.md +1 -1
- package/.docs/integrations/deploy/neon.md +2 -1
- package/.docs/integrations/deploy/render.md +2 -2
- package/.docs/integrations/file-storage/agentfs.md +1 -1
- package/.docs/integrations/file-storage/amazon-s3.md +20 -3
- package/.docs/integrations/file-storage/archil.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/google-drive.md +1 -1
- package/.docs/integrations/file-storage/mesa.md +1 -1
- package/.docs/integrations/file-storage/neon.md +210 -0
- package/.docs/integrations/file-storage/vercel-files.md +5 -1
- package/.docs/integrations/frameworks/express.md +0 -64
- package/.docs/integrations/observability/langfuse.md +1 -1
- package/.docs/integrations/observability/langsmith.md +2 -2
- package/.docs/integrations/observability/opentelemetry.md +5 -5
- package/.docs/integrations/sandboxes/apple-container.md +1 -1
- package/.docs/integrations/sandboxes/blaxel.md +1 -1
- package/.docs/integrations/sandboxes/daytona.md +1 -1
- package/.docs/integrations/sandboxes/docker.md +1 -1
- package/.docs/integrations/sandboxes/e2b-desktop.md +1 -1
- package/.docs/integrations/sandboxes/e2b.md +4 -2
- package/.docs/integrations/sandboxes/modal.md +1 -1
- package/.docs/integrations/sandboxes/railway.md +1 -1
- package/.docs/integrations/sandboxes/sprites.md +1 -1
- package/.docs/integrations/sandboxes/vercel.md +2 -2
- package/.docs/integrations/tools/brightdata.md +1 -1
- package/.docs/integrations/tools/firecrawl.md +1 -1
- package/.docs/integrations/tools/parallel.md +1 -1
- package/.docs/integrations/tools/perplexity.md +1 -1
- package/.docs/integrations/tools/tavily.md +1 -1
- package/.docs/integrations/voice/livekit.md +2 -2
- package/.docs/integrations.md +1 -0
- package/.docs/models/environment-variables.md +0 -2
- package/.docs/models/gateways/custom-gateways.md +3 -3
- package/.docs/models/gateways/merge-gateway.md +2 -14
- package/.docs/models/gateways/netlify.md +2 -1
- package/.docs/models/gateways/openrouter.md +3 -2
- package/.docs/models/gateways/vercel.md +3 -9
- package/.docs/models/index.md +13 -15
- package/.docs/models/providers/302ai.md +3 -3
- package/.docs/models/providers/abacus.md +70 -110
- package/.docs/models/providers/aimlapi.md +171 -171
- package/.docs/models/providers/aki-io.md +5 -6
- package/.docs/models/providers/alibaba-cn.md +2 -2
- package/.docs/models/providers/alibaba.md +2 -2
- package/.docs/models/providers/ambient.md +1 -1
- package/.docs/models/providers/auriko.md +2 -2
- package/.docs/models/providers/baseten.md +4 -4
- package/.docs/models/providers/berget.md +3 -4
- package/.docs/models/providers/bothub.md +4 -4
- package/.docs/models/providers/boundless.md +0 -4
- package/.docs/models/providers/cline-pass.md +2 -8
- package/.docs/models/providers/commandcode.md +0 -1
- package/.docs/models/providers/coralbricks.md +1 -1
- package/.docs/models/providers/cortecs.md +3 -3
- package/.docs/models/providers/crossmodel.md +1 -3
- package/.docs/models/providers/crusoe.md +1 -7
- package/.docs/models/providers/daoxe.md +1 -1
- package/.docs/models/providers/deepinfra.md +2 -2
- package/.docs/models/providers/digitalocean.md +6 -10
- package/.docs/models/providers/dinference.md +0 -3
- package/.docs/models/providers/edenai.md +12 -2
- package/.docs/models/providers/empiriolabs.md +0 -1
- package/.docs/models/providers/engy.md +2 -2
- package/.docs/models/providers/evroc.md +2 -2
- package/.docs/models/providers/fastrouter.md +41 -50
- package/.docs/models/providers/fireworks-ai.md +28 -23
- package/.docs/models/providers/friendli.md +4 -5
- package/.docs/models/providers/frogbot.md +2 -7
- package/.docs/models/providers/google.md +2 -5
- package/.docs/models/providers/greenpt.md +14 -20
- package/.docs/models/providers/groq.md +1 -1
- package/.docs/models/providers/huggingface.md +3 -1
- package/.docs/models/providers/iflowcn.md +2 -18
- package/.docs/models/providers/impossibl.md +2 -9
- package/.docs/models/providers/inceptron.md +8 -6
- package/.docs/models/providers/inco.md +1 -1
- package/.docs/models/providers/inference.md +5 -11
- package/.docs/models/providers/infomaniak.md +10 -12
- package/.docs/models/providers/io-net.md +11 -17
- package/.docs/models/providers/iteracompute.md +3 -3
- package/.docs/models/providers/jalapeno.md +14 -19
- package/.docs/models/providers/jiekou.md +53 -63
- package/.docs/models/providers/kenari.md +34 -53
- package/.docs/models/providers/kilo.md +12 -11
- package/.docs/models/providers/lilac.md +2 -8
- package/.docs/models/providers/llama.md +2 -11
- package/.docs/models/providers/llmgateway-providers.md +8 -16
- package/.docs/models/providers/llmgateway.md +9 -8
- package/.docs/models/providers/llmtr.md +1 -6
- package/.docs/models/providers/lowrouter.md +1 -1
- package/.docs/models/providers/lucidquery.md +2 -2
- package/.docs/models/providers/meganova.md +6 -7
- package/.docs/models/providers/melious.md +2 -7
- package/.docs/models/providers/mistral.md +4 -3
- package/.docs/models/providers/moark.md +0 -2
- package/.docs/models/providers/nan.md +1 -1
- package/.docs/models/providers/nano-gpt.md +16 -8
- package/.docs/models/providers/nearai.md +2 -1
- package/.docs/models/providers/neuralwatt.md +1 -4
- package/.docs/models/providers/novita-ai.md +2 -1
- package/.docs/models/providers/nvidia.md +15 -35
- package/.docs/models/providers/oci.md +0 -1
- package/.docs/models/providers/ofox.md +1 -1
- package/.docs/models/providers/ollama-cloud.md +2 -2
- package/.docs/models/providers/opencode-go.md +2 -3
- package/.docs/models/providers/opencode.md +85 -88
- package/.docs/models/providers/opper.md +1 -4
- package/.docs/models/providers/orcarouter.md +14 -16
- package/.docs/models/providers/pareto.md +1 -1
- package/.docs/models/providers/perplexity-agent.md +2 -12
- package/.docs/models/providers/pioneer.md +7 -7
- package/.docs/models/providers/poe.md +16 -70
- package/.docs/models/providers/prime.md +2 -1
- package/.docs/models/providers/qihang-ai.md +7 -11
- package/.docs/models/providers/qiniu-ai.md +9 -94
- package/.docs/models/providers/regolo-ai.md +5 -7
- package/.docs/models/providers/runinfra.md +1 -4
- package/.docs/models/providers/sarvam.md +1 -2
- package/.docs/models/providers/scaleway.md +12 -11
- package/.docs/models/providers/siliconflow-cn.md +35 -41
- package/.docs/models/providers/siliconflow.md +3 -6
- package/.docs/models/providers/stackit.md +2 -4
- package/.docs/models/providers/stepfun-ai.md +4 -4
- package/.docs/models/providers/stepfun.md +4 -4
- package/.docs/models/providers/submodel.md +1 -1
- package/.docs/models/providers/synthetic.md +0 -4
- package/.docs/models/providers/tempr.md +1 -4
- package/.docs/models/providers/tencent-coding-plan.md +3 -10
- package/.docs/models/providers/tensorx.md +0 -13
- package/.docs/models/providers/the-grid-ai.md +2 -1
- package/.docs/models/providers/tokengo.md +1 -1
- package/.docs/models/providers/umans-ai-coding-plan.md +12 -11
- package/.docs/models/providers/umans-ai.md +11 -10
- package/.docs/models/providers/unorouter.md +0 -13
- package/.docs/models/providers/vancine.md +0 -1
- package/.docs/models/providers/vivgrid.md +3 -3
- package/.docs/models/providers/volcengine-coding-plan.md +8 -12
- package/.docs/models/providers/volcengine.md +12 -18
- package/.docs/models/providers/vultr.md +0 -2
- package/.docs/models/providers/wafer.ai.md +3 -7
- package/.docs/models/providers/xai.md +19 -3
- package/.docs/models/providers/xiaomi-token-plan-ams.md +4 -4
- package/.docs/models/providers/xiaomi-token-plan-cn.md +4 -4
- package/.docs/models/providers/xiaomi-token-plan-sgp.md +4 -4
- package/.docs/models/providers/xiaomi.md +4 -4
- package/.docs/models/providers/xpersona.md +0 -1
- package/.docs/models/providers/zenmux.md +105 -125
- package/.docs/models/providers.md +0 -2
- package/.docs/reference/acp/acp-agent.md +4 -4
- package/.docs/reference/acp/create-acp-tool.md +1 -1
- package/.docs/reference/agent-controller/agent-controller-class.md +2 -2
- package/.docs/reference/agent-controller/session.md +10 -10
- package/.docs/reference/agents/agent.md +23 -47
- package/.docs/reference/agents/channels.md +13 -11
- package/.docs/reference/agents/durable-agent.md +13 -13
- package/.docs/reference/agents/generate.md +57 -3
- package/.docs/reference/agents/generateLegacy.md +2 -2
- package/.docs/reference/agents/getLLM.md +2 -2
- package/.docs/reference/agents/getMetadata.md +2 -2
- package/.docs/reference/agents/inngest-agent.md +1 -1
- package/.docs/reference/agents/network.md +1 -1
- package/.docs/reference/browser/agent-browser.md +1 -1
- package/.docs/reference/browser/browser-viewer.md +1 -1
- 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 +4 -4
- package/.docs/reference/channels/slack-provider.md +3 -0
- package/.docs/reference/cli/mastra.md +26 -0
- package/.docs/reference/client-js/agent-controller.md +2 -2
- package/.docs/reference/client-js/agents.md +18 -2
- package/.docs/reference/client-js/datasets.md +1 -1
- package/.docs/reference/client-js/observability.md +26 -1
- package/.docs/reference/coding-agent/build-base-prompt.md +1 -1
- package/.docs/reference/coding-agent/create-coding-agent.md +8 -8
- package/.docs/reference/configuration.md +4 -4
- package/.docs/reference/connect/channels.md +1 -1
- package/.docs/reference/connect/credential.md +1 -1
- package/.docs/reference/connect/tools.md +8 -10
- package/.docs/reference/core/getAgentById.md +1 -1
- package/.docs/reference/core/mastra-class.md +3 -3
- package/.docs/reference/core/mastra-model-gateway.md +1 -1
- package/.docs/reference/datasets/startExperiment.md +15 -0
- package/.docs/reference/editor/mastra-editor.md +2 -2
- package/.docs/reference/evals/answer-relevancy.md +1 -1
- package/.docs/reference/evals/answer-similarity.md +1 -1
- package/.docs/reference/evals/bias.md +1 -1
- package/.docs/reference/evals/checks.md +1 -1
- package/.docs/reference/evals/context-precision.md +3 -3
- package/.docs/reference/evals/context-recall.md +3 -3
- package/.docs/reference/evals/context-relevance.md +11 -11
- package/.docs/reference/evals/faithfulness.md +1 -1
- package/.docs/reference/evals/hallucination.md +5 -5
- package/.docs/reference/evals/multi-turn-judge.md +2 -2
- package/.docs/reference/evals/noise-sensitivity.md +12 -12
- package/.docs/reference/evals/not-scorable.md +1 -1
- package/.docs/reference/evals/prompt-alignment.md +16 -16
- package/.docs/reference/evals/rubric.md +6 -6
- package/.docs/reference/evals/run-evals.md +1 -1
- package/.docs/reference/evals/summarization.md +4 -4
- package/.docs/reference/evals/tool-call-accuracy.md +4 -4
- package/.docs/reference/evals/toxicity.md +1 -1
- package/.docs/reference/file-based-agents/config.md +3 -3
- package/.docs/reference/file-based-agents/schedules.md +1 -1
- package/.docs/reference/file-based-agents/subagents.md +4 -4
- package/.docs/reference/file-based-agents/workspace.md +1 -1
- package/.docs/reference/index.md +2 -1
- package/.docs/reference/manual-install.md +2 -2
- package/.docs/reference/memory/memory-class.md +3 -3
- package/.docs/reference/memory/observational-memory.md +16 -16
- package/.docs/reference/memory/summarizeConversation.md +3 -3
- package/.docs/reference/memory/summarizeThread.md +3 -3
- package/.docs/reference/migrations/agentnetwork.md +4 -4
- package/.docs/reference/migrations/mcp-v2.md +1 -1
- package/.docs/reference/migrations/upgrade-to-v1/agent.md +1 -1
- package/.docs/reference/migrations/vnext-to-standard-apis.md +2 -2
- package/.docs/reference/observability/tracing/advanced-queries.md +92 -11
- package/.docs/reference/observability/tracing/bridges/otel.md +1 -1
- package/.docs/reference/observability/tracing/exporters/langfuse.md +1 -1
- package/.docs/reference/observability/tracing/interfaces.md +2 -0
- package/.docs/reference/processors/batch-parts-processor.md +1 -1
- package/.docs/reference/processors/classifier-processor.md +2 -2
- package/.docs/reference/processors/cyber-refusal-handler.md +1 -1
- package/.docs/reference/processors/file-upload-processor.md +5 -5
- package/.docs/reference/processors/language-detector.md +1 -1
- package/.docs/reference/processors/message-history-processor.md +2 -2
- package/.docs/reference/processors/model-selection-processor.md +7 -7
- package/.docs/reference/processors/moderation-processor.md +3 -3
- package/.docs/reference/processors/pii-detector.md +2 -2
- package/.docs/reference/processors/prefill-error-handler.md +2 -2
- package/.docs/reference/processors/processor-interface.md +66 -10
- package/.docs/reference/processors/prompt-injection-detector.md +1 -1
- package/.docs/reference/processors/provider-history-compat.md +2 -2
- package/.docs/reference/processors/regex-filter-processor.md +1 -1
- package/.docs/reference/processors/response-cache.md +1 -1
- package/.docs/reference/processors/semantic-recall-processor.md +2 -2
- package/.docs/reference/processors/skill-search-processor.md +1 -1
- package/.docs/reference/processors/stream-error-retry-processor.md +3 -3
- package/.docs/reference/processors/system-prompt-scrubber.md +2 -2
- package/.docs/reference/processors/token-cost-control.md +1 -1
- package/.docs/reference/processors/token-limiter-processor.md +4 -4
- package/.docs/reference/processors/tool-call-filter.md +3 -3
- package/.docs/reference/processors/tool-search-processor.md +4 -4
- package/.docs/reference/processors/unicode-normalizer.md +1 -1
- package/.docs/reference/processors/working-memory-processor.md +2 -2
- package/.docs/reference/pubsub/lease-provider.md +2 -2
- package/.docs/reference/pubsub/redis-streams.md +11 -1
- package/.docs/reference/pubsub/unix-socket-pubsub.md +1 -1
- package/.docs/reference/rag/chunking-and-embedding.md +1 -1
- package/.docs/reference/rag/graph-rag-guide.md +2 -2
- package/.docs/reference/rag/metadata-filters.md +1 -1
- package/.docs/reference/rag/rerank.md +1 -1
- package/.docs/reference/rag/retrieval.md +13 -13
- package/.docs/reference/server/nestjs-adapter.md +1 -1
- package/.docs/reference/signals/create-notification-inbox-tool.md +4 -4
- package/.docs/reference/signals/notifications.md +249 -0
- package/.docs/reference/signals/task-signal-provider.md +2 -2
- package/.docs/reference/signals/thread-events.md +69 -0
- package/.docs/reference/storage/retention.md +1 -1
- package/.docs/reference/streaming/ChunkType.md +68 -0
- package/.docs/reference/streaming/agents/stream.md +4 -4
- package/.docs/reference/tools/create-code-mode.md +1 -1
- package/.docs/reference/tools/create-tool.md +19 -2
- package/.docs/reference/tools/mcp-client.md +202 -11
- package/.docs/reference/tools/mcp-server.md +7 -5
- package/.docs/reference/tools/task-tools.md +1 -1
- package/.docs/reference/tools/vector-query-tool.md +1 -1
- package/.docs/reference/vectors/libsql.md +1 -1
- package/.docs/reference/vectors/mongodb.md +2 -2
- package/.docs/reference/vectors/oracledb.md +2 -2
- package/.docs/reference/vectors/pg.md +1 -1
- package/.docs/reference/vectors/turbopuffer.md +1 -1
- package/.docs/reference/vectors/upstash.md +1 -1
- package/.docs/reference/voice/overview.md +24 -24
- package/.docs/reference/voice/speech-to-speech.md +6 -6
- package/.docs/reference/voice/speech-to-text.md +1 -1
- package/.docs/reference/voice/text-to-speech.md +1 -1
- package/.docs/reference/voice/voice.addInstructions.md +1 -1
- package/.docs/reference/workflows/run-methods/timeTravel.md +1 -1
- package/.docs/reference/workspace/local-filesystem.md +1 -1
- package/.docs/reference/workspace/local-sandbox.md +1 -1
- package/.docs/reference/workspace/platform-filesystem.md +1 -1
- package/.docs/reference/workspace/platform-sandbox.md +21 -2
- package/.docs/reference/workspace/process-manager.md +13 -2
- package/.docs/reference/workspace/sandbox.md +1 -1
- package/.docs/reference/workspace/workspace-class.md +12 -12
- package/package.json +11 -11
- package/.docs/docs/guides/mcp-events.md +0 -306
- package/.docs/docs/harness/signal-providers.md +0 -212
- package/.docs/docs/harness/signals.md +0 -546
- package/.docs/docs/mastra-platform/connect/end-user-connections.md +0 -116
- package/.docs/reference/connect/user-connect-routes.md +0 -68
|
@@ -18,18 +18,18 @@ import { typeSafeAi } from '@ai-sdk/typesafe-ai'
|
|
|
18
18
|
export const agent = new Agent({
|
|
19
19
|
name: 'support-agent',
|
|
20
20
|
instructions: 'Answer the user concisely.',
|
|
21
|
-
model: 'openai/gpt-
|
|
21
|
+
model: 'openai/gpt-6.1-sol',
|
|
22
22
|
inputProcessors: [
|
|
23
23
|
new ModelSelectionProcessor({
|
|
24
24
|
model: typeSafeAi.decisionModel('jev-latest'),
|
|
25
25
|
choices: [
|
|
26
26
|
{
|
|
27
|
-
model: 'openai/gpt-
|
|
27
|
+
model: 'openai/gpt-6-luna',
|
|
28
28
|
criteria:
|
|
29
29
|
'Answerable in one or two sentences from general knowledge, with no reasoning steps',
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
|
-
model: 'openai/gpt-
|
|
32
|
+
model: 'openai/gpt-6.1-sol',
|
|
33
33
|
criteria:
|
|
34
34
|
'Requires multi-step reasoning, planning, weighing trade-offs, or careful judgment',
|
|
35
35
|
},
|
|
@@ -87,8 +87,8 @@ const logger = new PinoLogger({ name: 'model-selection' })
|
|
|
87
87
|
new ModelSelectionProcessor({
|
|
88
88
|
model: typeSafeAi.decisionModel('jev-latest'),
|
|
89
89
|
choices: [
|
|
90
|
-
{ model: 'openai/gpt-
|
|
91
|
-
{ model: 'openai/gpt-
|
|
90
|
+
{ model: 'openai/gpt-6-luna', criteria: 'Simple lookups' },
|
|
91
|
+
{ model: 'openai/gpt-6.1-sol', criteria: 'Multi-step reasoning' },
|
|
92
92
|
],
|
|
93
93
|
onDecision: decision => {
|
|
94
94
|
logger.info('model routing', decision)
|
|
@@ -131,7 +131,7 @@ const triage = new Classifier({
|
|
|
131
131
|
new ModelSelectionProcessor({
|
|
132
132
|
classifier: triage,
|
|
133
133
|
select: ({ complexity }) =>
|
|
134
|
-
complexity.choice === 'trivial' ? 'openai/gpt-
|
|
134
|
+
complexity.choice === 'trivial' ? 'openai/gpt-6-luna' : undefined,
|
|
135
135
|
})
|
|
136
136
|
```
|
|
137
137
|
|
|
@@ -182,7 +182,7 @@ new ModelSelectionProcessor({
|
|
|
182
182
|
select: ({ complexity, sensitive }) => {
|
|
183
183
|
// Never downgrade a sensitive request, however simple it looks.
|
|
184
184
|
if (sensitive.probability >= 0.3) return undefined
|
|
185
|
-
return complexity.choice === 'trivial' ? 'openai/gpt-
|
|
185
|
+
return complexity.choice === 'trivial' ? 'openai/gpt-6-luna' : undefined
|
|
186
186
|
},
|
|
187
187
|
})
|
|
188
188
|
```
|
|
@@ -68,7 +68,7 @@ export const agent = new Agent({
|
|
|
68
68
|
id: 'moderated-agent',
|
|
69
69
|
name: 'moderated-agent',
|
|
70
70
|
instructions: 'You are a helpful assistant',
|
|
71
|
-
model: 'openai/gpt-
|
|
71
|
+
model: 'openai/gpt-6.1-sol',
|
|
72
72
|
inputProcessors: [
|
|
73
73
|
new ModerationProcessor({
|
|
74
74
|
model: 'openrouter/openai/gpt-oss-safeguard-20b',
|
|
@@ -84,7 +84,7 @@ export const agent = new Agent({
|
|
|
84
84
|
|
|
85
85
|
### Output processing with batching
|
|
86
86
|
|
|
87
|
-
For production streaming, set `bufferSize` (for example `bufferSize: 200`) so `ModerationProcessor` makes one moderation call per sentence instead of one per chunk. Buffering also catches content that
|
|
87
|
+
For production streaming, set `bufferSize` (for example `bufferSize: 200`) so `ModerationProcessor` makes one moderation call per sentence instead of one per chunk. Buffering also catches content that's split across chunks. Text then reaches the client in sentence-sized pieces.
|
|
88
88
|
|
|
89
89
|
When using `ModerationProcessor` as an output processor, it's recommended to combine it with `BatchPartsProcessor` to optimize performance. The `BatchPartsProcessor` batches stream chunks together before passing them to the moderator, reducing the number of LLM calls required for moderation.
|
|
90
90
|
|
|
@@ -96,7 +96,7 @@ export const agent = new Agent({
|
|
|
96
96
|
id: 'output-moderated-agent',
|
|
97
97
|
name: 'output-moderated-agent',
|
|
98
98
|
instructions: 'You are a helpful assistant',
|
|
99
|
-
model: 'openai/gpt-
|
|
99
|
+
model: 'openai/gpt-6.1-sol',
|
|
100
100
|
outputProcessors: [
|
|
101
101
|
// Batch stream parts first to reduce LLM calls
|
|
102
102
|
new BatchPartsProcessor({
|
|
@@ -70,7 +70,7 @@ export const agent = new Agent({
|
|
|
70
70
|
id: 'private-agent',
|
|
71
71
|
name: 'private-agent',
|
|
72
72
|
instructions: 'You are a helpful assistant',
|
|
73
|
-
model: 'openai/gpt-
|
|
73
|
+
model: 'openai/gpt-6.1-sol',
|
|
74
74
|
inputProcessors: [
|
|
75
75
|
new PIIDetector({
|
|
76
76
|
model: 'openrouter/openai/gpt-oss-safeguard-20b',
|
|
@@ -99,7 +99,7 @@ export const agent = new Agent({
|
|
|
99
99
|
id: 'output-pii-agent',
|
|
100
100
|
name: 'output-pii-agent',
|
|
101
101
|
instructions: 'You are a helpful assistant',
|
|
102
|
-
model: 'openai/gpt-
|
|
102
|
+
model: 'openai/gpt-6.1-sol',
|
|
103
103
|
outputProcessors: [
|
|
104
104
|
// Batch stream parts first to reduce LLM calls
|
|
105
105
|
new BatchPartsProcessor({
|
|
@@ -31,7 +31,7 @@ export const agent = new Agent({
|
|
|
31
31
|
id: 'my-agent',
|
|
32
32
|
name: 'my-agent',
|
|
33
33
|
instructions: 'You are a helpful assistant.',
|
|
34
|
-
model: 'anthropic/claude-opus-
|
|
34
|
+
model: 'anthropic/claude-opus-5-5',
|
|
35
35
|
errorProcessors: [new PrefillErrorHandler()],
|
|
36
36
|
})
|
|
37
37
|
```
|
|
@@ -53,7 +53,7 @@ export const agent = new Agent({
|
|
|
53
53
|
id: 'my-agent',
|
|
54
54
|
name: 'my-agent',
|
|
55
55
|
instructions: 'You are a helpful assistant.',
|
|
56
|
-
model: 'anthropic/claude-opus-
|
|
56
|
+
model: 'anthropic/claude-opus-5-5',
|
|
57
57
|
errorProcessors: [customErrorHandler],
|
|
58
58
|
})
|
|
59
59
|
```
|
|
@@ -68,6 +68,13 @@ interface Processor<TId extends string = string, TTripwireMetadata = unknown> {
|
|
|
68
68
|
| void
|
|
69
69
|
| undefined
|
|
70
70
|
|
|
71
|
+
/** State lane id for `computeStateSignal`. Defaults to the processor id. */
|
|
72
|
+
stateId?: string
|
|
73
|
+
|
|
74
|
+
computeStateSignal?(
|
|
75
|
+
args: ComputeStateSignalArgs<TTripwireMetadata>,
|
|
76
|
+
): Promise<ComputeStateSignalResult> | ComputeStateSignalResult
|
|
77
|
+
|
|
71
78
|
processLLMRequest?(
|
|
72
79
|
args: ProcessLLMRequestArgs<TTripwireMetadata>,
|
|
73
80
|
): Promise<ProcessLLMRequestResult> | ProcessLLMRequestResult
|
|
@@ -267,13 +274,14 @@ processInputStep?<TTripwireMetadata = unknown>(
|
|
|
267
274
|
1. `processInput` (once at start)
|
|
268
275
|
2. `processInputStep` from inputProcessors (at each step, before LLM call)
|
|
269
276
|
3. `prepareStep` callback (runs as part of the processInputStep pipeline, after inputProcessors)
|
|
270
|
-
4. `
|
|
271
|
-
5.
|
|
272
|
-
6.
|
|
273
|
-
7. `
|
|
274
|
-
8. `
|
|
275
|
-
9.
|
|
276
|
-
10.
|
|
277
|
+
4. `computeStateSignal` from inputProcessors (after `processInputStep`, before the LLM request)
|
|
278
|
+
5. `processLLMRequest` from inputProcessors (after prompt conversion, before the provider call)
|
|
279
|
+
6. LLM execution
|
|
280
|
+
7. `processOutputStream` from outputProcessors (on each streaming chunk)
|
|
281
|
+
8. `processLLMResponse` from inputProcessors (after stream completes, pairs with `processLLMRequest`)
|
|
282
|
+
9. `processOutputStep` from outputProcessors (after LLM response, before tool execution)
|
|
283
|
+
10. Tool execution (if needed)
|
|
284
|
+
11. Repeat from step 2 if tools were called
|
|
277
285
|
|
|
278
286
|
#### `ProcessInputStepArgs`
|
|
279
287
|
|
|
@@ -369,6 +377,54 @@ System messages are **reset to their original values** at the start of each step
|
|
|
369
377
|
|
|
370
378
|
***
|
|
371
379
|
|
|
380
|
+
### `computeStateSignal`
|
|
381
|
+
|
|
382
|
+
Computes a thread-scoped state signal once per model input step, after `processInputStep()` and before the LLM request is finalized. This method requires an agent with memory and an active `resourceId` and `threadId`.
|
|
383
|
+
|
|
384
|
+
```typescript
|
|
385
|
+
computeStateSignal?(
|
|
386
|
+
args: ComputeStateSignalArgs,
|
|
387
|
+
): Promise<ProcessorStateSignal | undefined | void> | ProcessorStateSignal | undefined | void;
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
Return a state signal to store it, or `undefined` or `void` when nothing changed. The returned `id` defaults to the processor's `stateId`, which itself defaults to the processor `id`. `mode` defaults to `snapshot`.
|
|
391
|
+
|
|
392
|
+
#### `ComputeStateSignalArgs`
|
|
393
|
+
|
|
394
|
+
**stepNumber** (`number`): Current step number (0-indexed).
|
|
395
|
+
|
|
396
|
+
**steps** (`StepResult[]`): Results from previous steps.
|
|
397
|
+
|
|
398
|
+
**state** (`Record<string, unknown>`): Per-processor state that persists across method calls within the request.
|
|
399
|
+
|
|
400
|
+
**resourceId** (`string`): Memory resource ID for the active thread.
|
|
401
|
+
|
|
402
|
+
**threadId** (`string`): Memory thread ID that scopes the state lane.
|
|
403
|
+
|
|
404
|
+
**activeStateSignals** (`ProcessorActiveStateSignal[]`): Active state signals for this processor and thread that the runtime currently knows about.
|
|
405
|
+
|
|
406
|
+
**contextWindow** (`{ hasSnapshot: boolean }`): Whether the active message window already contains a snapshot for this lane.
|
|
407
|
+
|
|
408
|
+
**lastSnapshot** (`ProcessorActiveStateSignal | undefined`): Latest snapshot for this lane, resolved from message history when the current message list does not contain it.
|
|
409
|
+
|
|
410
|
+
**deltasSinceSnapshot** (`ProcessorActiveStateSignal[]`): Delta signals accepted after the latest snapshot.
|
|
411
|
+
|
|
412
|
+
**tracking** (`ProcessorStateSignalTracking | undefined`): Last persisted tracking metadata for this lane, including the current cache key, mode, version, and active copies.
|
|
413
|
+
|
|
414
|
+
**sendStateSignal** (`(signal: AgentStateSignalInput) => Promise<CreatedAgentSignal | ApplyStateSignalResult>`): Adds another state signal from inside the method. Returns a skip result when the same cache key and mode are already current.
|
|
415
|
+
|
|
416
|
+
#### Deduplication
|
|
417
|
+
|
|
418
|
+
Mastra stores tracking metadata under `metadata.mastra.stateSignals[stateId]` on the thread. When a returned state signal has the same `cacheKey` and mode as the current state and a copy is still in the active message window, Mastra skips it instead of storing a duplicate. If the matching copy has left the active window, Mastra stores it again so the model keeps seeing the state. State signals can't be transient because this tracking is rebuilt from persisted history.
|
|
419
|
+
|
|
420
|
+
#### Use cases
|
|
421
|
+
|
|
422
|
+
- Sync browser, editor, or background-watcher state into a lane the model can see
|
|
423
|
+
- Emit a fresh snapshot after older state messages leave the context window
|
|
424
|
+
- Keep working memory or goal state outside the system prompt
|
|
425
|
+
|
|
426
|
+
***
|
|
427
|
+
|
|
372
428
|
### `processLLMRequest`
|
|
373
429
|
|
|
374
430
|
Processes the final LLM request after Mastra converts the `MessageList` into `LanguageModelV2Prompt` and before the provider call. Use this method for transient, model-aware rewrites that should affect only the current outbound request.
|
|
@@ -894,12 +950,12 @@ export class DynamicModelProcessor implements Processor {
|
|
|
894
950
|
}: ProcessInputStepArgs): Promise<ProcessInputStepResult> {
|
|
895
951
|
// Use a fast model for initial response
|
|
896
952
|
if (stepNumber === 0) {
|
|
897
|
-
return { model: 'openai/gpt-
|
|
953
|
+
return { model: 'openai/gpt-6-luna' }
|
|
898
954
|
}
|
|
899
955
|
|
|
900
956
|
// Switch to powerful model after tool calls
|
|
901
957
|
if (steps.length > 0 && steps[steps.length - 1].toolCalls?.length) {
|
|
902
|
-
return { model: 'openai/gpt-
|
|
958
|
+
return { model: 'openai/gpt-6.1-sol' }
|
|
903
959
|
}
|
|
904
960
|
|
|
905
961
|
// Disable tools after 5 steps to force completion
|
|
@@ -1120,7 +1176,7 @@ import { PrefillErrorHandler } from '@mastra/core/processors'
|
|
|
1120
1176
|
const agent = new Agent({
|
|
1121
1177
|
id: 'support-agent',
|
|
1122
1178
|
name: 'support-agent',
|
|
1123
|
-
model: 'openai/gpt-5',
|
|
1179
|
+
model: 'openai/gpt-5.6',
|
|
1124
1180
|
instructions: '...',
|
|
1125
1181
|
inputProcessors: [new ContentFilter(['secret'])],
|
|
1126
1182
|
outputProcessors: [new WordCounter()],
|
|
@@ -62,7 +62,7 @@ export const agent = new Agent({
|
|
|
62
62
|
id: 'secure-agent',
|
|
63
63
|
name: 'secure-agent',
|
|
64
64
|
instructions: 'You are a helpful assistant',
|
|
65
|
-
model: 'openai/gpt-
|
|
65
|
+
model: 'openai/gpt-6.1-sol',
|
|
66
66
|
inputProcessors: [
|
|
67
67
|
new PromptInjectionDetector({
|
|
68
68
|
model: 'openrouter/openai/gpt-oss-safeguard-20b',
|
|
@@ -61,10 +61,10 @@ Registering in `errorProcessors` alone, as the example above does, covers both h
|
|
|
61
61
|
| `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. |
|
|
62
62
|
| `anthropic-strip-empty-signed-reasoning-content` | Anthropic | Preemptive prompt rewrite | Removes assistant `reasoning` parts that carry an Anthropic signature but have empty text, which legacy records can contain. Anthropic signs the exact thinking text, so the mismatched pair would be rejected. |
|
|
63
63
|
| `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. |
|
|
64
|
-
| `anthropic-strip-foreign-signed-reasoning` | Anthropic-compatible | Preemptive prompt rewrite | Drops signed thinking from the outbound prompt when its origin turn was stamped with a different provider (for example Kimi For Coding ↔ `anthropic/claude-sonnet-
|
|
64
|
+
| `anthropic-strip-foreign-signed-reasoning` | Anthropic-compatible | Preemptive prompt rewrite | Drops signed thinking from the outbound prompt when its origin turn was stamped with a different provider (for example Kimi For Coding ↔ `anthropic/claude-sonnet-5-5`), since the receiving provider can't verify another provider's signature. Turns emptied of all content by the drop are removed from the prompt. Unstamped history is left untouched. |
|
|
65
65
|
| `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. |
|
|
66
66
|
| `openai-orphan-item-id` | OpenAI, Azure OpenAI (Responses) | Reactive API error recovery | Recovers history that OpenAI rejects with `Item 'msg_…' of type 'message' was provided without its required 'reasoning' item`. Drops the Responses `itemId` from every item-bearing part of an assistant message that carries one but has no `reasoning` part, and retries. The message then replays by value instead of as an unsatisfiable `item_reference`. The repair is applied to the in-memory list for the current turn. |
|
|
67
|
-
| `anthropic-orphaned-thinking-step` | Anthropic | Reactive API error recovery | Recovers history that Anthropic rejects because `thinking` or `redacted_thinking` blocks in the latest assistant message
|
|
67
|
+
| `anthropic-orphaned-thinking-step` | Anthropic | Reactive API error recovery | Recovers history that Anthropic rejects because `thinking` or `redacted_thinking` blocks in the latest assistant message can't be modified. Removes steps that contain only reasoning when more assistant content follows them, and retries. Covers history saved by older `@mastra/memory` releases ([#22798](https://github.com/mastra-ai/mastra/issues/22798)). |
|
|
68
68
|
| `ensure-user-first-turn` | Amazon Bedrock, Google/Vertex Gemini | Preemptive prompt rewrite | Inserts a minimal user turn (`.`) before a leading assistant turn, because these providers reject conversations whose first non-system turn is the assistant's. This happens when an agent greets first or `lastMessages` cuts into a thread. Runs last, so it sees the prompt after other rules have dropped emptied turns. |
|
|
69
69
|
|
|
70
70
|
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. Persisted history is never changed, so the IDs and content in memory and in the Studio stay exactly as written.
|
|
@@ -72,7 +72,7 @@ import { RegexFilterProcessor } from '@mastra/core/processors'
|
|
|
72
72
|
const agent = new Agent({
|
|
73
73
|
id: 'my-agent',
|
|
74
74
|
name: 'my-agent',
|
|
75
|
-
model: 'openai/gpt-
|
|
75
|
+
model: 'openai/gpt-6-luna',
|
|
76
76
|
inputProcessors: [
|
|
77
77
|
new RegexFilterProcessor({
|
|
78
78
|
presets: ['pii', 'secrets'],
|
|
@@ -30,7 +30,7 @@ const processor = new SemanticRecall({
|
|
|
30
30
|
|
|
31
31
|
**options.vector** (`MastraVector`): Vector store for semantic search
|
|
32
32
|
|
|
33
|
-
**options.embedder** (`MastraEmbeddingModel<string>`): Embedder for generating query embeddings
|
|
33
|
+
**options.embedder** (`MastraEmbeddingModel<string>`): Embedder for generating query embeddings. Required unless the vector store embeds text itself (self-embedding)
|
|
34
34
|
|
|
35
35
|
**options.topK** (`number`): Number of most similar messages to retrieve
|
|
36
36
|
|
|
@@ -86,7 +86,7 @@ export const agent = new Agent({
|
|
|
86
86
|
id: 'semantic-memory-agent',
|
|
87
87
|
name: 'semantic-memory-agent',
|
|
88
88
|
instructions: 'You are a helpful assistant with semantic memory recall',
|
|
89
|
-
model: 'openai/gpt-
|
|
89
|
+
model: 'openai/gpt-6.1-sol',
|
|
90
90
|
inputProcessors: [semanticRecall, new MessageHistory({ storage, lastMessages: 50 })],
|
|
91
91
|
outputProcessors: [semanticRecall, new MessageHistory({ storage })],
|
|
92
92
|
})
|
|
@@ -81,7 +81,7 @@ const agent = new Agent({
|
|
|
81
81
|
name: 'skill-agent',
|
|
82
82
|
instructions:
|
|
83
83
|
'You are a helpful assistant. Use search_skills to find relevant skills, then load_skill to load their instructions.',
|
|
84
|
-
model: 'openai/gpt-
|
|
84
|
+
model: 'openai/gpt-6.1-sol',
|
|
85
85
|
workspace,
|
|
86
86
|
inputProcessors: [skillSearch],
|
|
87
87
|
})
|
|
@@ -20,7 +20,7 @@ export const agent = new Agent({
|
|
|
20
20
|
id: 'openai-agent',
|
|
21
21
|
name: 'openai-agent',
|
|
22
22
|
instructions: 'You are a helpful assistant.',
|
|
23
|
-
model: 'openai/gpt-5',
|
|
23
|
+
model: 'openai/gpt-5.6',
|
|
24
24
|
errorProcessors: [new StreamErrorRetryProcessor({ maxRetries: 5 })],
|
|
25
25
|
maxProcessorRetries: 5,
|
|
26
26
|
})
|
|
@@ -66,7 +66,7 @@ export const agent = new Agent({
|
|
|
66
66
|
id: 'resilient-agent',
|
|
67
67
|
name: 'Resilient agent',
|
|
68
68
|
instructions: 'You are a helpful assistant.',
|
|
69
|
-
model: 'openai/gpt-5',
|
|
69
|
+
model: 'openai/gpt-5.6',
|
|
70
70
|
errorProcessors: [
|
|
71
71
|
new StreamErrorRetryProcessor({
|
|
72
72
|
retryUnknownErrors: true,
|
|
@@ -99,7 +99,7 @@ export const agent = new Agent({
|
|
|
99
99
|
id: 'resilient-agent',
|
|
100
100
|
name: 'resilient-agent',
|
|
101
101
|
instructions: 'You are a helpful assistant.',
|
|
102
|
-
model: 'openai/gpt-5',
|
|
102
|
+
model: 'openai/gpt-5.6',
|
|
103
103
|
errorProcessors: [
|
|
104
104
|
new StreamErrorRetryProcessor({
|
|
105
105
|
maxRetries: 2,
|
|
@@ -56,7 +56,7 @@ const processor = new SystemPromptScrubber({
|
|
|
56
56
|
|
|
57
57
|
## Extended usage example
|
|
58
58
|
|
|
59
|
-
For production streaming, set `bufferSize` (for example `bufferSize: 200`) so `SystemPromptScrubber` makes one detection call per sentence instead of one per chunk. Buffering also catches content that
|
|
59
|
+
For production streaming, set `bufferSize` (for example `bufferSize: 200`) so `SystemPromptScrubber` makes one detection call per sentence instead of one per chunk. Buffering also catches content that's split across chunks. Text then reaches the client in sentence-sized pieces.
|
|
60
60
|
|
|
61
61
|
When using `SystemPromptScrubber` as an output processor, it's recommended to combine it with `BatchPartsProcessor` to optimize performance. The `BatchPartsProcessor` batches stream chunks together before passing them to the scrubber, reducing the number of LLM calls required for detection.
|
|
62
62
|
|
|
@@ -68,7 +68,7 @@ export const agent = new Agent({
|
|
|
68
68
|
id: 'scrubbed-agent',
|
|
69
69
|
name: 'scrubbed-agent',
|
|
70
70
|
instructions: 'You are a helpful assistant',
|
|
71
|
-
model: 'openai/gpt-
|
|
71
|
+
model: 'openai/gpt-6.1-sol',
|
|
72
72
|
outputProcessors: [
|
|
73
73
|
// Batch stream parts first to reduce LLM calls
|
|
74
74
|
new BatchPartsProcessor({
|
|
@@ -107,7 +107,7 @@ export const agent = new Agent({
|
|
|
107
107
|
id: 'context-limited-agent',
|
|
108
108
|
name: 'context-limited-agent',
|
|
109
109
|
instructions: 'You are a helpful assistant',
|
|
110
|
-
model: 'openai/gpt-
|
|
110
|
+
model: 'openai/gpt-6.1-sol',
|
|
111
111
|
memory: new Memory({/* ... */}),
|
|
112
112
|
inputProcessors: [
|
|
113
113
|
new TokenLimiterProcessor({ limit: 4000 }), // Limits historical messages to ~4000 tokens
|
|
@@ -117,7 +117,7 @@ export const agent = new Agent({
|
|
|
117
117
|
|
|
118
118
|
### As a per-step processor (limit multi-step token growth)
|
|
119
119
|
|
|
120
|
-
When an agent uses tools across multiple steps (e.g. `maxSteps > 1`), each step accumulates conversation history from all previous steps. `TokenLimiterProcessor` applies its limit at every step, measuring the prompt that's about to be sent after any earlier prompt processors have run.
|
|
120
|
+
When an agent uses tools across multiple steps (e.g. `maxSteps > 1`), each step accumulates conversation history from all previous steps. `TokenLimiterProcessor` applies its limit at every step, measuring the prompt that's about to be sent after any earlier prompt processors have run. To count the prompt the model actually receives, register the limiter after prompt-shrinking processors such as `ToolCallFilter`:
|
|
121
121
|
|
|
122
122
|
```typescript
|
|
123
123
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -127,7 +127,7 @@ export const agent = new Agent({
|
|
|
127
127
|
id: 'multi-step-agent',
|
|
128
128
|
name: 'multi-step-agent',
|
|
129
129
|
instructions: 'You are a helpful research assistant with access to tools',
|
|
130
|
-
model: 'openai/gpt-
|
|
130
|
+
model: 'openai/gpt-6.1-sol',
|
|
131
131
|
inputProcessors: [
|
|
132
132
|
new TokenLimiterProcessor({ limit: 8000 }), // Applied at every step
|
|
133
133
|
],
|
|
@@ -153,7 +153,7 @@ export const agent = new Agent({
|
|
|
153
153
|
id: 'response-limited-agent',
|
|
154
154
|
name: 'response-limited-agent',
|
|
155
155
|
instructions: 'You are a helpful assistant',
|
|
156
|
-
model: 'openai/gpt-
|
|
156
|
+
model: 'openai/gpt-6.1-sol',
|
|
157
157
|
outputProcessors: [
|
|
158
158
|
new TokenLimiterProcessor({
|
|
159
159
|
limit: 1000,
|
|
@@ -66,7 +66,7 @@ const filter = new ToolCallFilter({
|
|
|
66
66
|
|
|
67
67
|
## Preserve compact model output
|
|
68
68
|
|
|
69
|
-
Set `preserveModelOutput: true` to retain compact `toModelOutput` history for tool results that the filter removes.
|
|
69
|
+
Set `preserveModelOutput: true` to retain compact `toModelOutput` history for tool results that the filter removes. Replacing the removed tool call and result with a single text part in the prompt lets the model see the output without the raw tool arguments.
|
|
70
70
|
|
|
71
71
|
Tool results without model output that can be represented as text are removed entirely.
|
|
72
72
|
|
|
@@ -95,7 +95,7 @@ export const agent = new Agent({
|
|
|
95
95
|
id: 'filtered-agent',
|
|
96
96
|
name: 'filtered-agent',
|
|
97
97
|
instructions: 'You are a helpful assistant',
|
|
98
|
-
model: 'openai/gpt-
|
|
98
|
+
model: 'openai/gpt-6.1-sol',
|
|
99
99
|
tools: {
|
|
100
100
|
searchDatabase,
|
|
101
101
|
sendEmail,
|
|
@@ -121,7 +121,7 @@ export const agent = new Agent({
|
|
|
121
121
|
id: 'no-tools-context-agent',
|
|
122
122
|
name: 'no-tools-context-agent',
|
|
123
123
|
instructions: 'You are a helpful assistant',
|
|
124
|
-
model: 'openai/gpt-
|
|
124
|
+
model: 'openai/gpt-6.1-sol',
|
|
125
125
|
tools: {
|
|
126
126
|
searchDatabase,
|
|
127
127
|
sendEmail,
|
|
@@ -145,7 +145,7 @@ const agent = new Agent({
|
|
|
145
145
|
id: 'mcp-agent',
|
|
146
146
|
name: 'mcp-agent',
|
|
147
147
|
instructions: 'Search for a tool when you need a capability you do not have.',
|
|
148
|
-
model: 'openai/gpt-
|
|
148
|
+
model: 'openai/gpt-6.1-sol',
|
|
149
149
|
// Resolved per request, then searchable alongside staticTools
|
|
150
150
|
tools: async ({ requestContext }) => mcpClient.getTools(requestContext.get('userToken')),
|
|
151
151
|
inputProcessors: [toolSearch],
|
|
@@ -184,7 +184,7 @@ const agent = new Agent({
|
|
|
184
184
|
name: 'dynamic-tools-agent',
|
|
185
185
|
instructions:
|
|
186
186
|
'You are a helpful assistant with access to many tools. Use search_tools to find relevant tools, then load_tool to make them available.',
|
|
187
|
-
model: 'openai/gpt-
|
|
187
|
+
model: 'openai/gpt-6.1-sol',
|
|
188
188
|
inputProcessors: [toolSearch],
|
|
189
189
|
})
|
|
190
190
|
```
|
|
@@ -238,7 +238,7 @@ Use `clearState`, `clearAllState`, `getStateStats`, and `cleanupNow` to inspect
|
|
|
238
238
|
|
|
239
239
|
Loaded state is derived from the conversation messages: a tool is loaded while a `search_tools` or `load_tool` result naming it remains in the messages. This mode:
|
|
240
240
|
|
|
241
|
-
- Works without memory configuration. Without memory, loaded tools are kept for the current process only, and only for requests with a real thread ID
|
|
241
|
+
- Works without memory configuration. Without memory, loaded tools are kept for the current process only, and only for requests with a real thread ID. Anonymous requests require the caller to resend the relevant messages to retain loaded tools between calls.
|
|
242
242
|
- Survives a restart whenever the messages are available again: from memory with message history, or because the caller resends the conversation. Without memory, a restart restores only what's in the messages the caller sends.
|
|
243
243
|
- De-loads a tool automatically once that result is no longer present in the messages.
|
|
244
244
|
|
|
@@ -264,7 +264,7 @@ import { ToolSearchProcessor, TokenLimiter } from '@mastra/core/processors'
|
|
|
264
264
|
const agent = new Agent({
|
|
265
265
|
id: 'my-agent',
|
|
266
266
|
name: 'my-agent',
|
|
267
|
-
model: 'openai/gpt-
|
|
267
|
+
model: 'openai/gpt-6.1-sol',
|
|
268
268
|
inputProcessors: [
|
|
269
269
|
new ToolSearchProcessor({
|
|
270
270
|
tools: allTools,
|
|
@@ -47,7 +47,7 @@ export const agent = new Agent({
|
|
|
47
47
|
id: 'normalized-agent',
|
|
48
48
|
name: 'normalized-agent',
|
|
49
49
|
instructions: 'You are a helpful assistant',
|
|
50
|
-
model: 'openai/gpt-
|
|
50
|
+
model: 'openai/gpt-6.1-sol',
|
|
51
51
|
inputProcessors: [
|
|
52
52
|
new UnicodeNormalizer({
|
|
53
53
|
stripControlChars: true,
|
|
@@ -35,7 +35,7 @@ const processor = new WorkingMemory({
|
|
|
35
35
|
|
|
36
36
|
**options.template.format** (`'markdown' | 'json'`): Format of the working memory content
|
|
37
37
|
|
|
38
|
-
**options.template.content** (`string
|
|
38
|
+
**options.template.content** (`string | Record<string, unknown>`): Template content defining the structure of working memory data. The object form is only valid when format is json
|
|
39
39
|
|
|
40
40
|
**options.scope** (`'thread' | 'resource'`): Scope of working memory. 'thread' scopes to current thread, 'resource' shares across all threads for the resource
|
|
41
41
|
|
|
@@ -73,7 +73,7 @@ export const agent = new Agent({
|
|
|
73
73
|
id: 'personalized-agent',
|
|
74
74
|
name: 'personalized-agent',
|
|
75
75
|
instructions: 'You are a helpful assistant that remembers user preferences',
|
|
76
|
-
model: 'openai/gpt-
|
|
76
|
+
model: 'openai/gpt-6.1-sol',
|
|
77
77
|
inputProcessors: [
|
|
78
78
|
new WorkingMemory({
|
|
79
79
|
storage,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# LeaseProvider
|
|
6
6
|
|
|
7
|
-
`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/
|
|
7
|
+
`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/signals/overview) 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.
|
|
8
8
|
|
|
9
9
|
[Durable agents](https://mastra.ai/docs/harness/durable-agents) also claim each run through a lease when the workflows store doesn't support run fencing, so crash recovery can tell whether another process still drives the run.
|
|
10
10
|
|
|
@@ -133,5 +133,5 @@ When the configured pub/sub backend doesn't implement `LeaseProvider`, the runti
|
|
|
133
133
|
|
|
134
134
|
- [PubSub](https://mastra.ai/reference/pubsub/base): The event delivery contract, separate from leasing
|
|
135
135
|
- [RedisStreamsPubSub](https://mastra.ai/reference/pubsub/redis-streams): The built-in backend that implements `LeaseProvider`
|
|
136
|
-
- [Signals](https://mastra.ai/docs/
|
|
136
|
+
- [Signals](https://mastra.ai/docs/signals/overview): The runtime that uses leasing to coordinate thread execution across processes
|
|
137
137
|
- [Channels](https://mastra.ai/docs/channels): Uses leasing to coordinate agent runs in serverless and multi-instance deployments
|
|
@@ -181,9 +181,19 @@ When a subscriber calls `nack`, the event is republished with an incremented `de
|
|
|
181
181
|
|
|
182
182
|
A subscription never reclaims an event its own handler is still processing, so a slow handler isn't invoked twice for the same event. If a handler hangs, a different consumer in the group reclaims the event once it has been idle for `reclaimIdleMs`. In a single-consumer group there's no sibling to do that, so set `inFlightTimeoutMs` to have the subscription nack the event itself after that long.
|
|
183
183
|
|
|
184
|
+
### Evented agent worker takeover
|
|
185
|
+
|
|
186
|
+
With Postgres storage, distributed evented agents publish worker orchestration events through Redis. If a worker exits before acknowledging an event, another worker can reclaim it and finish the run while the original API process stays alive. Configure the API process with `MASTRA_WORKERS=false` and worker processes with `MASTRA_WORKERS=orchestration`. All processes must share the same Postgres database, Redis connection settings, and `keyPrefix`.
|
|
187
|
+
|
|
188
|
+
Keep `reclaimIdleMs` above 30 seconds (the default is 60 seconds). A lower value can reclaim an event while the stopped worker's step lease is still held, causing the event to be acknowledged without running.
|
|
189
|
+
|
|
190
|
+
Runs started on older versions can finish after upgrading, but don't have guaranteed crash recovery. Saved steps without occurrence identifiers keep their existing unguarded behavior. Other storage adapters keep distributed internal orchestration on the worker process.
|
|
191
|
+
|
|
192
|
+
An interrupted step can execute again, so make external side effects idempotent. Completed step occurrences are protected against stale redeliveries, and a completed loop iteration reuses its saved result and loop decision. Guarded execution persists the records needed for recovery even when `shouldPersistSnapshot` returns `false`. Resume, time travel, restart races, and individual `foreach` items aren't covered by these occurrence guards.
|
|
193
|
+
|
|
184
194
|
## Distributed leasing
|
|
185
195
|
|
|
186
|
-
`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/
|
|
196
|
+
`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/signals/overview) 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.
|
|
187
197
|
|
|
188
198
|
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.
|
|
189
199
|
|
|
@@ -53,7 +53,7 @@ await pubsub.close()
|
|
|
53
53
|
|
|
54
54
|
## Broker election
|
|
55
55
|
|
|
56
|
-
The broker is the first process to link its socket into place at the shared path. It routes events between all connected clients, and other processes connect to it as clients. Each candidate binds a socket at a private name and hard-links it to the shared path. The link fails if a socket is already there,
|
|
56
|
+
The broker is the first process to link its socket into place at the shared path. It routes events between all connected clients, and other processes connect to it as clients. Each candidate binds a socket at a private name and hard-links it to the shared path. The link fails if a socket is already there, preventing a candidate from accidentally replacing a live broker.
|
|
57
57
|
|
|
58
58
|
When the broker exits cleanly, it removes the shared path. Clients then reconnect, and the first to link its socket into place becomes the new broker. The remaining clients resubscribe to it.
|
|
59
59
|
|
|
@@ -79,7 +79,7 @@ const ragAgent = new Agent({
|
|
|
79
79
|
instructions: `You are a helpful assistant that answers questions based on the provided context.
|
|
80
80
|
When answering questions, use the graph query tool to find relevant information and relationships.
|
|
81
81
|
Base your answers on the context provided by the tool, and clearly state if the context doesn't contain enough information.`,
|
|
82
|
-
model: 'openai/gpt-
|
|
82
|
+
model: 'openai/gpt-6.1-sol',
|
|
83
83
|
tools: {
|
|
84
84
|
graphQueryTool,
|
|
85
85
|
},
|
|
@@ -201,7 +201,7 @@ const agent = new Agent({
|
|
|
201
201
|
name: 'RAG Agent',
|
|
202
202
|
instructions: `Use vector search for simple fact-finding queries.
|
|
203
203
|
Use graph search when you need to understand relationships or find connected information.`,
|
|
204
|
-
model: 'openai/gpt-
|
|
204
|
+
model: 'openai/gpt-6.1-sol',
|
|
205
205
|
tools: {
|
|
206
206
|
vectorQueryTool,
|
|
207
207
|
graphQueryTool,
|
|
@@ -36,7 +36,7 @@ const results = await store.query({
|
|
|
36
36
|
|
|
37
37
|
### Array Operators
|
|
38
38
|
|
|
39
|
-
`$in`Matches any value in array{ category: { $in: \["A", "B"] } }Supported by: All except Couchbase`$nin`Matches none of the values{ status: { $nin: \["deleted", "archived"] } }Supported by: All except Couchbase`$all`Matches arrays containing all elements{ tags: { $all: \["urgent", "high"] } }Supported by: Astra, Pinecone, Upstash, MongoDB, OracleDB`$elemMatch`Matches array elements meeting criteria{ scores: { $elemMatch: { $gt: 80 } } }Supported by: libSQL, PgVector, MongoDB, OracleDB
|
|
39
|
+
`$in`Matches any value in array{ category: { $in: \["A", "B"] } }Supported by: All except Couchbase`$nin`Matches none of the values{ status: { $nin: \["deleted", "archived"] } }Supported by: All except Couchbase`$all`Matches arrays containing all elements{ tags: { $all: \["urgent", "high"] } }Supported by: Astra, Pinecone, Qdrant, Upstash, MongoDB, OracleDB`$elemMatch`Matches array elements meeting criteria{ scores: { $elemMatch: { $gt: 80 } } }Supported by: libSQL, PgVector, MongoDB, OracleDB
|
|
40
40
|
|
|
41
41
|
### Logical Operators
|
|
42
42
|
|
|
@@ -21,7 +21,7 @@ function rerank(
|
|
|
21
21
|
import { ModelRouterLanguageModel } from '@mastra/core/llm'
|
|
22
22
|
import { rerank } from '@mastra/rag'
|
|
23
23
|
|
|
24
|
-
const model = new ModelRouterLanguageModel('openai/gpt-
|
|
24
|
+
const model = new ModelRouterLanguageModel('openai/gpt-6.1-sol')
|
|
25
25
|
|
|
26
26
|
const rerankedResults = await rerank(vectorSearchResults, 'How do I deploy to production?', model, {
|
|
27
27
|
weights: {
|