@mastra/mcp-docs-server 1.2.5-alpha.1 → 1.2.5-alpha.5
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/agent-builder/deploying.md +1 -1
- package/.docs/docs/agent-controller/overview.md +1 -1
- package/.docs/docs/agent-controller/session.md +1 -1
- package/.docs/docs/agents/overview.md +1 -1
- package/.docs/docs/agents/processors.md +1 -1
- package/.docs/docs/agents/supervisor-agents.md +3 -3
- package/.docs/docs/agents/using-tools.md +1 -1
- package/.docs/docs/{agents → long-running-agents}/background-tasks.md +2 -2
- package/.docs/docs/{agents → long-running-agents}/durable-agents.md +2 -2
- package/.docs/docs/{agents → long-running-agents}/goals.md +1 -1
- package/.docs/docs/{agents → long-running-agents}/heartbeats.md +5 -5
- package/.docs/docs/{agents → long-running-agents}/signal-providers.md +4 -4
- package/.docs/docs/memory/working-memory.md +1 -1
- package/.docs/docs/observability/config.md +1 -2
- package/.docs/docs/server/pubsub.md +2 -2
- package/.docs/docs/voice/overview.md +3 -3
- package/.docs/docs/voice/speech-to-speech.md +81 -1
- package/.docs/docs/voice/speech-to-text.md +19 -1
- package/.docs/docs/voice/text-to-speech.md +21 -1
- package/.docs/docs/workflows/control-flow.md +1 -1
- package/.docs/docs/workflows/error-handling.md +1 -1
- package/.docs/docs/workflows/human-in-the-loop.md +1 -1
- package/.docs/docs/workflows/overview.md +1 -1
- package/.docs/docs/workflows/snapshots.md +1 -1
- package/.docs/docs/workflows/suspend-and-resume.md +1 -1
- package/.docs/docs/workflows/time-travel.md +1 -1
- package/.docs/docs/workflows/workflow-state.md +1 -1
- package/.docs/guides/build-your-ui/copilotkit/channels.md +76 -0
- package/.docs/guides/build-your-ui/copilotkit/generative-ui.md +174 -0
- package/.docs/guides/build-your-ui/copilotkit/overview.md +411 -0
- package/.docs/guides/concepts/streaming.md +1 -1
- package/.docs/guides/deployment/vercel.md +1 -2
- package/.docs/guides/guide/signal-provider.md +5 -5
- package/.docs/models/environment-variables.md +1 -0
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/alibaba-cn.md +2 -1
- package/.docs/models/providers/friendli.md +1 -2
- package/.docs/models/providers/nvidia.md +3 -2
- package/.docs/models/providers/tencent-token-plan.md +7 -7
- package/.docs/models/providers/tencent-tokenhub.md +5 -4
- package/.docs/models/providers.md +1 -0
- package/.docs/reference/acp/acp-agent.md +5 -5
- package/.docs/reference/acp/create-acp-tool.md +5 -5
- package/.docs/reference/agent-controller/agent-controller-class.md +27 -27
- package/.docs/reference/agents/agent.md +34 -34
- package/.docs/reference/agents/channels.md +19 -19
- package/.docs/reference/agents/createSkill.md +2 -2
- package/.docs/reference/agents/durable-agent.md +22 -22
- package/.docs/reference/agents/generate.md +10 -10
- package/.docs/reference/agents/generateLegacy.md +12 -12
- package/.docs/reference/agents/getMetadata.md +1 -1
- package/.docs/reference/agents/getVoice.md +1 -1
- package/.docs/reference/agents/inngest-agent.md +9 -9
- package/.docs/reference/agents/network.md +1 -1
- package/.docs/reference/ai-sdk/chat-route.md +4 -4
- package/.docs/reference/ai-sdk/handle-chat-stream.md +6 -6
- package/.docs/reference/ai-sdk/handle-network-stream.md +3 -3
- package/.docs/reference/ai-sdk/handle-workflow-stream.md +1 -1
- package/.docs/reference/ai-sdk/network-route.md +4 -4
- 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/with-mastra.md +2 -2
- package/.docs/reference/ai-sdk/workflow-route.md +2 -2
- package/.docs/reference/ai-sdk/workflow-snapshot-to-stream.md +1 -1
- package/.docs/reference/auth/google.md +10 -10
- package/.docs/reference/auth/okta.md +11 -11
- package/.docs/reference/auth/workos.md +3 -3
- package/.docs/reference/channels/slack-provider.md +15 -15
- package/.docs/reference/cli/mastra.md +145 -0
- package/.docs/reference/client-js/agents.md +9 -9
- package/.docs/reference/client-js/mastra-client.md +5 -5
- package/.docs/reference/client-js/responses.md +3 -3
- package/.docs/reference/configuration.md +1 -1
- package/.docs/reference/core/getAgentById.md +3 -3
- package/.docs/reference/core/getWorkflow.md +1 -1
- package/.docs/reference/core/listWorkflows.md +1 -1
- package/.docs/reference/core/mastra-class.md +3 -3
- package/.docs/reference/core/removeWorkspace.md +2 -2
- package/.docs/reference/datasets/compareExperiments.md +1 -1
- package/.docs/reference/datasets/getItemHistory.md +1 -1
- package/.docs/reference/datasets/list.md +5 -5
- package/.docs/reference/datasets/listExperimentResults.md +4 -4
- package/.docs/reference/datasets/listExperiments.md +4 -4
- package/.docs/reference/datasets/listItems.md +5 -5
- package/.docs/reference/datasets/listVersions.md +3 -3
- package/.docs/reference/datasets/startExperiment.md +8 -8
- package/.docs/reference/datasets/startExperimentAsync.md +1 -1
- package/.docs/reference/editor/agent-builder/agent-builder-options.md +4 -4
- package/.docs/reference/editor/agent-builder/builder-agent-defaults.md +7 -7
- package/.docs/reference/editor/agent-builder/builder-models.md +4 -4
- package/.docs/reference/editor/blob-store-provider.md +2 -2
- package/.docs/reference/editor/browser-provider.md +2 -2
- package/.docs/reference/editor/filesystem-provider.md +2 -2
- package/.docs/reference/editor/mastra-editor.md +2 -2
- package/.docs/reference/editor/processor-provider.md +4 -4
- package/.docs/reference/editor/sandbox-provider.md +2 -2
- package/.docs/reference/editor/storage-browser-ref.md +2 -2
- package/.docs/reference/editor/storage-workspace-ref.md +7 -7
- package/.docs/reference/evals/create-scorer.md +8 -8
- package/.docs/reference/evals/rubric.md +1 -1
- package/.docs/reference/evals/run-evals.md +7 -7
- package/.docs/reference/evals/trajectory-accuracy.md +1 -1
- package/.docs/reference/index.md +2 -2
- package/.docs/reference/logging/pino-logger.md +4 -4
- package/.docs/reference/memory/cloneThread.md +35 -4
- package/.docs/reference/memory/memory-class.md +5 -5
- package/.docs/reference/memory/observational-memory.md +43 -43
- package/.docs/reference/memory/recall.md +4 -4
- package/.docs/reference/memory/serialized-memory-config.md +6 -6
- package/.docs/reference/observability/tracing/configuration.md +4 -4
- package/.docs/reference/processors/language-detector.md +1 -1
- package/.docs/reference/processors/moderation-processor.md +1 -1
- package/.docs/reference/processors/pii-detector.md +1 -1
- package/.docs/reference/processors/processor-interface.md +20 -20
- package/.docs/reference/processors/prompt-injection-detector.md +1 -1
- package/.docs/reference/processors/response-cache.md +6 -6
- package/.docs/reference/processors/unicode-normalizer.md +1 -1
- package/.docs/reference/pubsub/base.md +7 -7
- package/.docs/reference/pubsub/caching-pubsub.md +1 -1
- package/.docs/reference/pubsub/event-emitter.md +2 -2
- package/.docs/reference/pubsub/google-cloud-pubsub.md +1 -1
- package/.docs/reference/pubsub/lease-provider.md +3 -3
- package/.docs/reference/pubsub/redis-streams.md +6 -6
- package/.docs/reference/pubsub/unix-socket-pubsub.md +1 -1
- package/.docs/reference/rag/chunk.md +2 -2
- package/.docs/reference/server/create-route.md +3 -3
- package/.docs/reference/server/express-adapter.md +4 -4
- package/.docs/reference/server/fastify-adapter.md +4 -4
- package/.docs/reference/server/hono-adapter.md +4 -4
- package/.docs/reference/server/koa-adapter.md +4 -4
- package/.docs/reference/server/mastra-server.md +1 -1
- package/.docs/reference/server/nestjs-adapter.md +3 -3
- package/.docs/reference/server/register-api-route.md +3 -3
- package/.docs/reference/signals/create-notification-inbox-tool.md +3 -3
- package/.docs/reference/signals/signal-provider.md +7 -7
- package/.docs/reference/signals/webhook-signal-provider.md +2 -2
- package/.docs/reference/storage/clickhouse.md +7 -7
- package/.docs/reference/storage/composite.md +2 -2
- package/.docs/reference/storage/duckdb.md +1 -1
- package/.docs/reference/storage/dynamodb.md +1 -1
- package/.docs/reference/storage/libsql.md +1 -1
- package/.docs/reference/storage/postgresql.md +2 -2
- package/.docs/reference/storage/redis.md +2 -2
- package/.docs/reference/storage/retention.md +5 -5
- package/.docs/reference/storage/spanner.md +6 -6
- package/.docs/reference/streaming/ChunkType.md +3 -3
- package/.docs/reference/streaming/agents/stream.md +14 -14
- package/.docs/reference/streaming/agents/streamLegacy.md +10 -10
- package/.docs/reference/streaming/agents/streamUntilIdle.md +1 -1
- package/.docs/reference/streaming/workflows/resumeStream.md +1 -1
- package/.docs/reference/templates/overview.md +1 -140
- package/.docs/reference/tools/brightdata.md +4 -4
- package/.docs/reference/tools/create-code-mode.md +5 -5
- package/.docs/reference/tools/create-tool.md +15 -15
- package/.docs/reference/tools/graph-rag-tool.md +1 -1
- package/.docs/reference/tools/mcp-client.md +2 -2
- package/.docs/reference/tools/mcp-server.md +12 -12
- package/.docs/reference/tools/perplexity.md +3 -3
- package/.docs/reference/tools/tavily.md +1 -1
- package/.docs/reference/tools/vector-query-tool.md +1 -1
- package/.docs/reference/vectors/chroma.md +1 -1
- package/.docs/reference/vectors/mongodb.md +1 -1
- package/.docs/reference/vectors/pg.md +1 -1
- package/.docs/reference/vectors/s3vectors.md +4 -4
- package/.docs/reference/voice/google-gemini-live.md +3 -3
- package/.docs/reference/voice/inworld-realtime.md +12 -12
- package/.docs/reference/voice/inworld.md +2 -2
- package/.docs/reference/voice/voice.on.md +1 -1
- package/.docs/reference/workflows/run-methods/resume.md +1 -1
- package/.docs/reference/workflows/run-methods/timeTravel.md +1 -1
- package/.docs/reference/workspace/agentcore-runtime-sandbox.md +4 -4
- package/.docs/reference/workspace/agentfs-filesystem.md +1 -1
- package/.docs/reference/workspace/apple-container-sandbox.md +5 -5
- package/.docs/reference/workspace/archil-filesystem.md +5 -5
- package/.docs/reference/workspace/blaxel-sandbox.md +1 -1
- package/.docs/reference/workspace/daytona-sandbox.md +1 -1
- package/.docs/reference/workspace/docker-sandbox.md +2 -2
- package/.docs/reference/workspace/e2b-sandbox.md +2 -2
- package/.docs/reference/workspace/files-sdk-filesystem.md +1 -1
- package/.docs/reference/workspace/filesystem.md +1 -1
- package/.docs/reference/workspace/local-filesystem.md +3 -3
- package/.docs/reference/workspace/local-sandbox.md +1 -1
- package/.docs/reference/workspace/mesa-filesystem.md +3 -3
- package/.docs/reference/workspace/modal-sandbox.md +1 -1
- package/.docs/reference/workspace/railway-sandbox.md +1 -1
- package/.docs/reference/workspace/s3-filesystem.md +4 -4
- package/.docs/reference/workspace/sandbox.md +1 -1
- package/.docs/reference/workspace/{vercel-microvm-sandbox.md → vercel-sandbox.md} +21 -15
- package/.docs/reference/workspace/{vercel.md → vercel-serverless.md} +21 -14
- package/.docs/reference/workspace/workspace-class.md +15 -15
- package/CHANGELOG.md +15 -0
- package/package.json +4 -4
- package/.docs/docs/agents/adding-voice.md +0 -383
- package/.docs/docs/community/contributing-templates.md +0 -5
- package/.docs/docs/community/discord.md +0 -11
- package/.docs/guides/build-your-ui/copilotkit.md +0 -291
- package/LICENSE.md +0 -30
- /package/.docs/docs/{community/licensing.md → license.md} +0 -0
- /package/.docs/docs/{agents → long-running-agents}/signals.md +0 -0
|
@@ -39,9 +39,9 @@ const scorer = createScorer({
|
|
|
39
39
|
|
|
40
40
|
## `createScorer` options
|
|
41
41
|
|
|
42
|
-
**id** (`string`): Unique identifier for the scorer. Used as the name if
|
|
42
|
+
**id** (`string`): Unique identifier for the scorer. Used as the name if name is not provided.
|
|
43
43
|
|
|
44
|
-
**name** (`string`): Name of the scorer. Defaults to
|
|
44
|
+
**name** (`string`): Name of the scorer. Defaults to id if not provided.
|
|
45
45
|
|
|
46
46
|
**description** (`string`): Description of what the scorer does.
|
|
47
47
|
|
|
@@ -51,11 +51,11 @@ const scorer = createScorer({
|
|
|
51
51
|
|
|
52
52
|
**judge.instructions** (`string`): System prompt/instructions for the LLM.
|
|
53
53
|
|
|
54
|
-
**judge.jsonPromptInjection** (`boolean`): When true, inject the JSON schema into the prompt instead of using the provider's native
|
|
54
|
+
**judge.jsonPromptInjection** (`boolean`): When true, inject the JSON schema into the prompt instead of using the provider's native response\_format API. Set this for models that don't support native structured output (e.g. some Groq Llama models) to avoid a wasted 400 call.
|
|
55
55
|
|
|
56
56
|
**type** (`string`): Type specification for input/output. Use 'agent' for automatic agent types. For custom types, use the generic approach instead.
|
|
57
57
|
|
|
58
|
-
**prepareRun** (`(run: ScorerRun) => ScorerRun | Promise<ScorerRun>`): Transform the scorer run data before the pipeline executes. Use this to filter messages, limit context size, or drop fields the scorer doesn't need. The
|
|
58
|
+
**prepareRun** (`(run: ScorerRun) => ScorerRun | Promise<ScorerRun>`): Transform the scorer run data before the pipeline executes. Use this to filter messages, limit context size, or drop fields the scorer doesn't need. The \`filterRun()\` utility creates this function from declarative options. Can be async.
|
|
59
59
|
|
|
60
60
|
This function returns a scorer builder that you can chain step methods onto. See the [MastraScorer reference](https://mastra.ai/reference/evals/mastra-scorer) for details on the `.run()` method and its input/output.
|
|
61
61
|
|
|
@@ -153,7 +153,7 @@ Optional preprocessing step that can extract or transform data before analysis.
|
|
|
153
153
|
|
|
154
154
|
**Function Mode:** Function: `({ run, results }) => any`
|
|
155
155
|
|
|
156
|
-
**run.input** (`any`): Input records provided to the scorer. If the scorer is added to an agent, this will be an array of user messages, e.g.
|
|
156
|
+
**run.input** (`any`): Input records provided to the scorer. If the scorer is added to an agent, this will be an array of user messages, e.g. \[{ role: 'user', content: 'hello world' }]. If the scorer is used in a workflow, this will be the input of the workflow.
|
|
157
157
|
|
|
158
158
|
**run.output** (`any`): Output record provided to the scorer. For agents, this is usually the agent's response. For workflows, this is the workflow's output.
|
|
159
159
|
|
|
@@ -182,7 +182,7 @@ Optional analysis step that processes the input/output and any preprocessed data
|
|
|
182
182
|
|
|
183
183
|
**Function Mode:** Function: `({ run, results }) => any`
|
|
184
184
|
|
|
185
|
-
**run.input** (`any`): Input records provided to the scorer. If the scorer is added to an agent, this will be an array of user messages, e.g.
|
|
185
|
+
**run.input** (`any`): Input records provided to the scorer. If the scorer is added to an agent, this will be an array of user messages, e.g. \[{ role: 'user', content: 'hello world' }]. If the scorer is used in a workflow, this will be the input of the workflow.
|
|
186
186
|
|
|
187
187
|
**run.output** (`any`): Output record provided to the scorer. For agents, this is usually the agent's response. For workflows, this is the workflow's output.
|
|
188
188
|
|
|
@@ -211,7 +211,7 @@ The method can return any value. The returned value will be available to subsequ
|
|
|
211
211
|
|
|
212
212
|
**Function Mode:** Function: `({ run, results }) => number`
|
|
213
213
|
|
|
214
|
-
**run.input** (`any`): Input records provided to the scorer. If the scorer is added to an agent, this will be an array of user messages, e.g.
|
|
214
|
+
**run.input** (`any`): Input records provided to the scorer. If the scorer is added to an agent, this will be an array of user messages, e.g. \[{ role: 'user', content: 'hello world' }]. If the scorer is used in a workflow, this will be the input of the workflow.
|
|
215
215
|
|
|
216
216
|
**run.output** (`any`): Output record provided to the scorer. For agents, this is usually the agent's response. For workflows, this is the workflow's output.
|
|
217
217
|
|
|
@@ -246,7 +246,7 @@ Optional step that provides an explanation for the score.
|
|
|
246
246
|
|
|
247
247
|
**Function Mode:** Function: `({ run, results, score }) => string`
|
|
248
248
|
|
|
249
|
-
**run.input** (`any`): Input records provided to the scorer. If the scorer is added to an agent, this will be an array of user messages, e.g.
|
|
249
|
+
**run.input** (`any`): Input records provided to the scorer. If the scorer is added to an agent, this will be an array of user messages, e.g. \[{ role: 'user', content: 'hello world' }]. If the scorer is used in a workflow, this will be the input of the workflow.
|
|
250
250
|
|
|
251
251
|
**run.output** (`any`): Output record provided to the scorer. For agents, this is usually the agent's response. For workflows, this is the workflow's output.
|
|
252
252
|
|
|
@@ -12,7 +12,7 @@ This scorer is designed to drop into [`isTaskComplete`](https://mastra.ai/refere
|
|
|
12
12
|
|
|
13
13
|
**model** (`MastraModelConfig`): The language model used to grade the output against the rubric. A smaller, cheaper model is usually sufficient for grading.
|
|
14
14
|
|
|
15
|
-
**criteria** (`RubricCriterion[] | string`): The rubric to grade against. A string is treated as a newline-delimited checklist (each line becomes a required criterion). If omitted, the rubric is read at run time from a
|
|
15
|
+
**criteria** (`RubricCriterion[] | string`): The rubric to grade against. A string is treated as a newline-delimited checklist (each line becomes a required criterion). If omitted, the rubric is read at run time from a rubric value on request/additional context; if none resolves, the scorer is a no-op and returns 1.
|
|
16
16
|
|
|
17
17
|
**options** (`RubricScorerOptions`): Configuration options for the scorer
|
|
18
18
|
|
|
@@ -56,9 +56,9 @@ result.thresholdResults // [{ id, passed, averageScore, threshold }]
|
|
|
56
56
|
|
|
57
57
|
**data** (`RunEvalsDataItem[]`): Array of test cases with input data and optional ground truth.
|
|
58
58
|
|
|
59
|
-
**scorers** (`ScorerEntry[] | AgentScorerConfig | WorkflowScorerConfig`): Scorers to use. Each entry is either a bare
|
|
59
|
+
**scorers** (`ScorerEntry[] | AgentScorerConfig | WorkflowScorerConfig`): Scorers to use. Each entry is either a bare MastraScorer or { scorer, threshold } for threshold tracking. An AgentScorerConfig object separates agent-level and trajectory scorers. A WorkflowScorerConfig object specifies scorers for the workflow, individual steps, and trajectory.
|
|
60
60
|
|
|
61
|
-
**gates** (`MastraScorer[]`): Scorers that must score 1.0 for the run to pass. If any gate averages below 1.0 across data items, the verdict is
|
|
61
|
+
**gates** (`MastraScorer[]`): Scorers that must score 1.0 for the run to pass. If any gate averages below 1.0 across data items, the verdict is failed. Gates run before regular scorers on each data item.
|
|
62
62
|
|
|
63
63
|
**targetOptions** (`AgentExecutionOptions | WorkflowRunOptions`): Options forwarded to the target during execution. For agents: options passed to agent.generate() (e.g. maxSteps, modelSettings, instructions). For workflows: options passed to run.start() (e.g. perStep, outputOptions, initialState).
|
|
64
64
|
|
|
@@ -72,7 +72,7 @@ result.thresholdResults // [{ id, passed, averageScore, threshold }]
|
|
|
72
72
|
|
|
73
73
|
**groundTruth** (`any`): Expected or reference output for comparison during scoring.
|
|
74
74
|
|
|
75
|
-
**expectedTrajectory** (`TrajectoryExpectation`): Expected trajectory configuration for trajectory scoring. Includes expected steps, ordering, efficiency budgets, blacklists, and tool failure tolerance. Passed to trajectory scorers as
|
|
75
|
+
**expectedTrajectory** (`TrajectoryExpectation`): Expected trajectory configuration for trajectory scoring. Includes expected steps, ordering, efficiency budgets, blacklists, and tool failure tolerance. Passed to trajectory scorers as run.expectedTrajectory. Overrides the static defaults in scorer constructors.
|
|
76
76
|
|
|
77
77
|
**requestContext** (`RequestContext`): Request Context to pass to the target during execution.
|
|
78
78
|
|
|
@@ -106,11 +106,11 @@ For workflows, use `WorkflowScorerConfig` to specify scorers at different levels
|
|
|
106
106
|
|
|
107
107
|
**summary.totalItems** (`number`): Total number of test cases processed.
|
|
108
108
|
|
|
109
|
-
**verdict** (`'passed' | 'scored' | 'failed'`): Present when
|
|
109
|
+
**verdict** (`'passed' | 'scored' | 'failed'`): Present when gates or threshold-bearing scorers are provided. passed = all gates and thresholds met. scored = gates passed but a threshold was missed. failed = at least one gate did not score 1.0.
|
|
110
110
|
|
|
111
|
-
**gateResults** (`GateResult[]`): Per-gate results averaged across all data items. Each entry has
|
|
111
|
+
**gateResults** (`GateResult[]`): Per-gate results averaged across all data items. Each entry has id, passed (boolean), and score (0–1).
|
|
112
112
|
|
|
113
|
-
**thresholdResults** (`ThresholdResult[]`): Per-threshold-scorer results averaged across all data items. Each entry has
|
|
113
|
+
**thresholdResults** (`ThresholdResult[]`): Per-threshold-scorer results averaged across all data items. Each entry has id, passed, averageScore, and threshold.
|
|
114
114
|
|
|
115
115
|
## ScorerEntry
|
|
116
116
|
|
|
@@ -118,7 +118,7 @@ A scorer entry in the `scorers` array can be either a bare scorer or a scorer wi
|
|
|
118
118
|
|
|
119
119
|
**scorer** (`MastraScorer`): The scorer instance.
|
|
120
120
|
|
|
121
|
-
**threshold** (`number | { min?: number; max?: number }`): A number implies minimum threshold (score at or above passes). Use
|
|
121
|
+
**threshold** (`number | { min?: number; max?: number }`): A number implies minimum threshold (score at or above passes). Use { min, max } for range-based checks — e.g. { max: 0.3 } for scorers like hallucination where a high score is bad. Both min and max must be between 0 and 1.
|
|
122
122
|
|
|
123
123
|
## Examples
|
|
124
124
|
|
|
@@ -113,7 +113,7 @@ Omit `stepType` entirely to match any step by name only.
|
|
|
113
113
|
|
|
114
114
|
**stepType** (`TrajectoryStepType`): Step type discriminant. When set, enables autocomplete for that variant's fields. If omitted, matches any step type with the given name.
|
|
115
115
|
|
|
116
|
-
**(variant fields)** (`varies`): Type-specific fields from the corresponding TrajectoryStep variant. For example,
|
|
116
|
+
**(variant fields)** (`varies`): Type-specific fields from the corresponding TrajectoryStep variant. For example, toolArgs and toolResult for tool\_call, modelId for model\_generation, output for workflow\_step. All optional — only specified fields are compared.
|
|
117
117
|
|
|
118
118
|
**children** (`TrajectoryExpectation`): Nested expectation config for this step's children. Overrides the parent config for evaluating children of this step.
|
|
119
119
|
|
package/.docs/reference/index.md
CHANGED
|
@@ -368,8 +368,8 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
368
368
|
- [RailwaySandbox](https://mastra.ai/reference/workspace/railway-sandbox)
|
|
369
369
|
- [S3Filesystem](https://mastra.ai/reference/workspace/s3-filesystem)
|
|
370
370
|
- [SandboxProcessManager](https://mastra.ai/reference/workspace/process-manager)
|
|
371
|
-
- [
|
|
372
|
-
- [
|
|
371
|
+
- [VercelSandbox](https://mastra.ai/reference/workspace/vercel-sandbox)
|
|
372
|
+
- [VercelServerlessSandbox](https://mastra.ai/reference/workspace/vercel-serverless)
|
|
373
373
|
- [Workspace Class](https://mastra.ai/reference/workspace/workspace-class)
|
|
374
374
|
- [WorkspaceFilesystem](https://mastra.ai/reference/workspace/filesystem)
|
|
375
375
|
- [WorkspaceSandbox](https://mastra.ai/reference/workspace/sandbox)
|
|
@@ -30,13 +30,13 @@ export const mastra = new Mastra({
|
|
|
30
30
|
|
|
31
31
|
**formatters** (`pino.LoggerOptions['formatters']`): Custom Pino formatters for log serialization.
|
|
32
32
|
|
|
33
|
-
**redact** (`pino.LoggerOptions['redact']`): Paths or options for redacting sensitive fields from log output (Pino
|
|
33
|
+
**redact** (`pino.LoggerOptions['redact']`): Paths or options for redacting sensitive fields from log output (Pino redact).
|
|
34
34
|
|
|
35
|
-
**prettyPrint** (`boolean`): When false, disables
|
|
35
|
+
**prettyPrint** (`boolean`): When false, disables pino-pretty and writes raw JSON lines (useful for log aggregators). (Default: `true`)
|
|
36
36
|
|
|
37
|
-
**mixin** (`pino.MixinFn`): Pino mixin function merged into every log object (for example request-scoped
|
|
37
|
+
**mixin** (`pino.MixinFn`): Pino mixin function merged into every log object (for example request-scoped traceId or other shared metadata).
|
|
38
38
|
|
|
39
|
-
**customLevels** (`Record<string, number>`): Custom log levels and numeric values, forwarded to Pino. Standard severity is still logged via
|
|
39
|
+
**customLevels** (`Record<string, number>`): Custom log levels and numeric values, forwarded to Pino. Standard severity is still logged via debug, info, warn, and error; extra levels follow Pino’s custom-level behavior.
|
|
40
40
|
|
|
41
41
|
## Log enrichment with `mixin`
|
|
42
42
|
|
|
@@ -6,7 +6,16 @@ The `.cloneThread()` method creates a copy of an existing conversation thread, i
|
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
9
|
+
The following example creates a `Memory` instance and clones an existing thread.
|
|
10
|
+
|
|
9
11
|
```typescript
|
|
12
|
+
import { Memory } from '@mastra/memory'
|
|
13
|
+
import { LibSQLStore } from '@mastra/libsql'
|
|
14
|
+
|
|
15
|
+
const memory = new Memory({
|
|
16
|
+
storage: new LibSQLStore({ id: 'memory-store', url: 'file:./memory.db' }),
|
|
17
|
+
})
|
|
18
|
+
|
|
10
19
|
const { thread, clonedMessages } = await memory.cloneThread({
|
|
11
20
|
sourceThreadId: 'original-thread-123',
|
|
12
21
|
})
|
|
@@ -20,7 +29,7 @@ const { thread, clonedMessages } = await memory.cloneThread({
|
|
|
20
29
|
|
|
21
30
|
**resourceId** (`string`): Optional resource ID for the cloned thread. Defaults to the source thread's resourceId.
|
|
22
31
|
|
|
23
|
-
**title** (`string`): Optional title for the cloned thread.
|
|
32
|
+
**title** (`string`): Optional title for the cloned thread. If omitted, the clone uses Clone of ${sourceThread.title} when the source thread has a title. Otherwise, the title is empty.
|
|
24
33
|
|
|
25
34
|
**metadata** (`Record<string, unknown>`): Optional metadata to merge with the source thread's metadata. Clone metadata is automatically added.
|
|
26
35
|
|
|
@@ -44,7 +53,7 @@ const { thread, clonedMessages } = await memory.cloneThread({
|
|
|
44
53
|
|
|
45
54
|
**messageIdMap** (`Record<string, string>`): A mapping from source message IDs to their corresponding cloned message IDs.
|
|
46
55
|
|
|
47
|
-
### Clone
|
|
56
|
+
### Clone metadata
|
|
48
57
|
|
|
49
58
|
The cloned thread's metadata includes a `clone` property with:
|
|
50
59
|
|
|
@@ -93,8 +102,18 @@ const { thread: dateFilteredClone } = await memory.cloneThread({
|
|
|
93
102
|
},
|
|
94
103
|
})
|
|
95
104
|
|
|
105
|
+
// Clone specific messages
|
|
106
|
+
const { thread: selectedMessagesClone } = await memory.cloneThread({
|
|
107
|
+
sourceThreadId: 'original-thread-123',
|
|
108
|
+
options: {
|
|
109
|
+
messageFilter: {
|
|
110
|
+
messageIds: ['message-1', 'message-2'],
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
|
|
96
115
|
// Continue conversation on the cloned thread
|
|
97
|
-
const response = await agent.generate(
|
|
116
|
+
const response = await agent.generate('Try a different approach', {
|
|
98
117
|
memory: {
|
|
99
118
|
thread: fullClone.id,
|
|
100
119
|
resource: fullClone.resourceId,
|
|
@@ -102,9 +121,13 @@ const response = await agent.generate("Let's try a different approach", {
|
|
|
102
121
|
})
|
|
103
122
|
```
|
|
104
123
|
|
|
124
|
+
Pass the cloned `thread.id` and `thread.resourceId` to `agent.generate()` to continue the conversation from the cloned thread.
|
|
125
|
+
|
|
105
126
|
## Vector embeddings
|
|
106
127
|
|
|
107
|
-
When the Memory instance has semantic recall enabled
|
|
128
|
+
When the Memory instance has semantic recall enabled with a vector store and embedder configured, `cloneThread()` automatically creates vector embeddings for all cloned messages. This ensures that semantic search works correctly on the cloned thread.
|
|
129
|
+
|
|
130
|
+
In this example, `embeddingModel` is the embedding model configured for the project.
|
|
108
131
|
|
|
109
132
|
```typescript
|
|
110
133
|
import { Memory } from '@mastra/memory'
|
|
@@ -131,6 +154,14 @@ const results = await memory.recall({
|
|
|
131
154
|
})
|
|
132
155
|
```
|
|
133
156
|
|
|
157
|
+
## Working memory
|
|
158
|
+
|
|
159
|
+
When working memory is enabled, `cloneThread()` copies or shares working memory based on the working-memory scope and the clone's `resourceId`:
|
|
160
|
+
|
|
161
|
+
- **Thread-scoped working memory**: The working memory is copied to the cloned thread.
|
|
162
|
+
- **Resource-scoped working memory with the same `resourceId`**: The working memory is shared because the source and cloned threads belong to the same resource.
|
|
163
|
+
- **Resource-scoped working memory with a different `resourceId`**: The working memory is copied to the cloned thread's resource.
|
|
164
|
+
|
|
134
165
|
## Observational Memory
|
|
135
166
|
|
|
136
167
|
When [Observational Memory](https://mastra.ai/docs/memory/observational-memory) is enabled, `cloneThread()` automatically clones the OM records associated with the source thread. The behavior depends on the OM scope:
|
|
@@ -29,23 +29,23 @@ export const agent = new Agent({
|
|
|
29
29
|
|
|
30
30
|
## Constructor parameters
|
|
31
31
|
|
|
32
|
-
**storage** (`MastraCompositeStore`): Storage implementation for persisting memory data. Defaults to
|
|
32
|
+
**storage** (`MastraCompositeStore`): Storage implementation for persisting memory data. Defaults to new DefaultStorage({ config: { url: "file:memory.db" } }) if not provided.
|
|
33
33
|
|
|
34
|
-
**vector** (`MastraVector | false`): Vector store for semantic search capabilities. Set to
|
|
34
|
+
**vector** (`MastraVector | false`): Vector store for semantic search capabilities. Set to false to disable vector operations.
|
|
35
35
|
|
|
36
36
|
**embedder** (`EmbeddingModel<string> | EmbeddingModelV2<string>`): Embedder instance for vector embeddings. Required when semantic recall is enabled.
|
|
37
37
|
|
|
38
38
|
**options** (`MemoryConfig`): Memory configuration options.
|
|
39
39
|
|
|
40
|
-
**options.lastMessages** (`number | false`): Number of most recent messages to include in context. Set to
|
|
40
|
+
**options.lastMessages** (`number | false`): Number of most recent messages to include in context. Set to false to disable loading conversation history into context. Use Number.MAX\_SAFE\_INTEGER to retrieve all messages with no limit. To prevent saving new messages, use the readOnly option instead.
|
|
41
41
|
|
|
42
42
|
**options.readOnly** (`boolean`): When true, prevents memory from saving new messages and provides working memory as read-only context (without the updateWorkingMemory tool). Useful for read-only operations like previews, internal routing agents, or sub agents that should reference but not modify memory.
|
|
43
43
|
|
|
44
44
|
**options.semanticRecall** (`boolean | { topK: number; messageRange: number | { before: number; after: number }; scope?: 'thread' | 'resource' }`): Enable semantic search in message history. Can be a boolean or an object with configuration options. When enabled, requires both vector store and embedder to be configured. Default topK is 4, default messageRange is {before: 1, after: 1}.
|
|
45
45
|
|
|
46
|
-
**options.workingMemory** (`WorkingMemory`): Configuration for working memory feature. Can be
|
|
46
|
+
**options.workingMemory** (`WorkingMemory`): Configuration for working memory feature. Can be { enabled: boolean; template?: string; schema?: ZodObject\<any> | JSONSchema7; scope?: 'thread' | 'resource' } or { enabled: boolean } to disable.
|
|
47
47
|
|
|
48
|
-
**options.observationalMemory** (`boolean | ObservationalMemoryOptions`): Enable Observational Memory for long-context agentic memory. Set to
|
|
48
|
+
**options.observationalMemory** (`boolean | ObservationalMemoryOptions`): Enable Observational Memory for long-context agentic memory. Set to true for defaults, or pass a config object to customize token budgets, models, and scope. See Observational Memory reference for configuration details.
|
|
49
49
|
|
|
50
50
|
**options.generateTitle** (`boolean | { model: DynamicArgument<MastraLanguageModel>; instructions?: DynamicArgument<string> }`): Controls automatic thread title generation from the user's first message. Can be a boolean or an object with custom model and instructions.
|
|
51
51
|
|
|
@@ -33,35 +33,35 @@ Observer input is multimodal-aware. OM keeps text placeholders like `[Image #1:
|
|
|
33
33
|
|
|
34
34
|
OM performs thresholding with fast local token estimation. Text uses `tokenx`, and image-like inputs use provider-aware heuristics plus deterministic fallbacks when metadata is incomplete.
|
|
35
35
|
|
|
36
|
-
**enabled** (`boolean`): Enable or disable Observational Memory. When omitted from a config object, defaults to
|
|
36
|
+
**enabled** (`boolean`): Enable or disable Observational Memory. When omitted from a config object, defaults to true. Only enabled: false explicitly disables it. (Default: `true`)
|
|
37
37
|
|
|
38
|
-
**model** (`string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for both the Observer and Reflector agents. Sets the model for both at once. Cannot be used together with
|
|
38
|
+
**model** (`string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for both the Observer and Reflector agents. Sets the model for both at once. Cannot be used together with observation.model or reflection.model — an error will be thrown if both are set. When using observationalMemory: true, defaults to google/gemini-2.5-flash. When passing a config object, this or observation.model/reflection.model must be set. Use "default" to explicitly use the default model (google/gemini-2.5-flash). (Default: `'google/gemini-2.5-flash' (when using observationalMemory: true)`)
|
|
39
39
|
|
|
40
|
-
**scope** (`'resource' | 'thread'`): Memory scope for observations.
|
|
40
|
+
**scope** (`'resource' | 'thread'`): Memory scope for observations. 'thread' keeps observations per-thread. 'resource' (experimental) shares observations across all threads for a resource, enabling cross-conversation memory. (Default: `'thread'`)
|
|
41
41
|
|
|
42
|
-
**activateAfterIdle** (`number | string | false | "auto"`): Time before buffered observations are forced to activate after inactivity, even before
|
|
42
|
+
**activateAfterIdle** (`number | string | false | "auto"`): Time before buffered observations are forced to activate after inactivity, even before observation.messageTokens is reached. Accepts a numeric millisecond value such as 300\_000, duration strings like "5m" or "1hr", "auto" for a provider-aware prompt cache TTL, or false to disable inherited observation idle activation. Reflections do not inherit this setting. Use reflection.activateAfterIdle to opt reflections into idle activation.
|
|
43
43
|
|
|
44
|
-
**activateOnProviderChange** (`boolean`): Force buffered observations to activate when the actor provider or model changes. Reflections do not inherit this setting. Use
|
|
44
|
+
**activateOnProviderChange** (`boolean`): Force buffered observations to activate when the actor provider or model changes. Reflections do not inherit this setting. Use reflection.activateOnProviderChange to opt reflections into provider-change activation. (Default: `false`)
|
|
45
45
|
|
|
46
|
-
**shareTokenBudget** (`boolean`): Share the token budget between messages and observations. When enabled, the total budget is
|
|
46
|
+
**shareTokenBudget** (`boolean`): Share the token budget between messages and observations. When enabled, the total budget is observation.messageTokens + reflection.observationTokens. Messages can use more space when observations are small, and vice versa. This maximizes context usage through flexible allocation. shareTokenBudget is not yet compatible with async buffering. You must set observation: { bufferTokens: false } when using this option (this is a temporary limitation). (Default: `false`)
|
|
47
47
|
|
|
48
48
|
**temporalMarkers** (`boolean`): Insert temporal-gap reminder markers before new user messages when the previous message in the thread is at least 10 minutes older. The marker is persisted in memory, emitted as an inline reminder event so clients can render it specially, and shown to the observer so it can anchor observations to when events occurred. (Default: `false`)
|
|
49
49
|
|
|
50
|
-
**retrieval** (`boolean | { vector?: boolean; scope?: 'thread' | 'resource' }`): Enable retrieval-mode observation groups as durable pointers to raw message history.
|
|
50
|
+
**retrieval** (`boolean | { vector?: boolean; scope?: 'thread' | 'resource' }`): Enable retrieval-mode observation groups as durable pointers to raw message history. true enables cross-thread browsing by default. { vector: true } also enables semantic search using Memory's vector store and embedder. { scope: 'thread' } restricts the recall tool to the current thread only. Default scope is 'resource'. (Default: `false`)
|
|
51
51
|
|
|
52
52
|
**observation** (`ObservationalMemoryObservationConfig`): Configuration for the observation step. Controls when the Observer agent runs and how it behaves.
|
|
53
53
|
|
|
54
|
-
**observation.model** (`string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for the Observer agent. Cannot be set if a top-level
|
|
54
|
+
**observation.model** (`string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for the Observer agent. Cannot be set if a top-level model is also provided. If neither this nor the top-level model is set, falls back to reflection.model.
|
|
55
55
|
|
|
56
56
|
**observation.instruction** (`string`): Custom instruction appended to the Observer's system prompt. Use this to customize what the Observer focuses on, such as domain-specific preferences or priorities.
|
|
57
57
|
|
|
58
|
-
**observation.threadTitle** (`boolean`): When
|
|
58
|
+
**observation.threadTitle** (`boolean`): When true, the Observer suggests short thread titles and updates the thread title when the conversation topic meaningfully changes. This is opt-in and defaults to disabled.
|
|
59
59
|
|
|
60
60
|
**observation.extract** (`Extractor[]`): Custom values to extract after observation. Schema-less extractors are requested inline in the Observer output. Schema-backed extractors run as a follow-up structured output call and are stored in thread OM metadata.
|
|
61
61
|
|
|
62
|
-
**observation.observeAttachments** (`boolean | string[]`): Controls which image/file attachments are forwarded to the Observer model alongside their placeholder text lines.
|
|
62
|
+
**observation.observeAttachments** (`boolean | string[]`): Controls which image/file attachments are forwarded to the Observer model alongside their placeholder text lines. true (default) forwards all attachments. false drops all attachments while keeping placeholders visible. An array is a case-insensitive mimeType allowlist supporting exact matches ('application/pdf'), wildcard subtypes ('image/\*'), and bare '\*' for everything. Useful when the Observer model is text-only (e.g. some DeepSeek endpoints) while the main agent uses a multimodal model. Tool-result attachments are filtered using the same rule.
|
|
63
63
|
|
|
64
|
-
**observation.messageTokens** (`number`): Token count of unobserved messages that triggers observation. When unobserved message tokens exceed this threshold, the Observer agent is called. Text is estimated locally with
|
|
64
|
+
**observation.messageTokens** (`number`): Token count of unobserved messages that triggers observation. When unobserved message tokens exceed this threshold, the Observer agent is called. Text is estimated locally with tokenx. Image parts are included with model-aware heuristics when possible, with deterministic fallbacks when image metadata is incomplete. Image-like file parts are counted the same way when uploads are normalized as files.
|
|
65
65
|
|
|
66
66
|
**observation.maxTokensPerBatch** (`number`): Maximum tokens per batch when observing multiple threads in resource scope. Threads are chunked into batches of this size and processed in parallel. Lower values mean more parallelism but more API calls.
|
|
67
67
|
|
|
@@ -71,23 +71,23 @@ OM performs thresholding with fast local token estimation. Text uses `tokenx`, a
|
|
|
71
71
|
|
|
72
72
|
**observation.modelSettings.maxOutputTokens** (`number`): Maximum output tokens. Set high to prevent truncation of observations.
|
|
73
73
|
|
|
74
|
-
**observation.bufferTokens** (`number | false`): Token interval for async background observation buffering. Can be an absolute token count (e.g.
|
|
74
|
+
**observation.bufferTokens** (`number | false`): Token interval for async background observation buffering. Can be an absolute token count (e.g. 5000) or a fraction of messageTokens (e.g. 0.25 = buffer every 25% of threshold). When set, observations run in the background at this interval, storing results in a buffer. When the main messageTokens threshold is reached, buffered observations activate instantly without a blocking LLM call. Must resolve to less than messageTokens. Set to false to explicitly disable all async buffering (both observation and reflection).
|
|
75
75
|
|
|
76
|
-
**observation.bufferOnIdle** (`boolean`): Run background observation buffering when an agent turn ends and the agent becomes idle. This is separate from
|
|
76
|
+
**observation.bufferOnIdle** (`boolean`): Run background observation buffering when an agent turn ends and the agent becomes idle. This is separate from bufferTokens, which controls step-time async buffering. Set this to true to buffer short idle turns without waiting for the next turn or the messageTokens threshold.
|
|
77
77
|
|
|
78
|
-
**observation.bufferActivation** (`number`): Controls how much of the message window to retain after activation. Accepts a ratio (0-1) or an absolute token count (≥ 1000). For example,
|
|
78
|
+
**observation.bufferActivation** (`number`): Controls how much of the message window to retain after activation. Accepts a ratio (0-1) or an absolute token count (≥ 1000). For example, 0.8 means: activate enough buffers to remove 80% of messageTokens and leave 20% as active message history. An absolute token count like 4000 targets a goal of keeping \~4k message tokens remaining after activation. Higher values remove more message history per activation when using a ratio. Higher values keep more message history when using a token count.
|
|
79
79
|
|
|
80
|
-
**observation.activateAfterIdle** (`number | string | false | "auto"`): Time before buffered observations are forced to activate after inactivity. Accepts milliseconds, a duration string,
|
|
80
|
+
**observation.activateAfterIdle** (`number | string | false | "auto"`): Time before buffered observations are forced to activate after inactivity. Accepts milliseconds, a duration string, "auto" for a provider-aware prompt cache TTL, or false. If unset, the top-level activateAfterIdle value is used for observations. Set false to disable the top-level idle setting for observations.
|
|
81
81
|
|
|
82
|
-
**observation.activateOnProviderChange** (`boolean`): Force buffered observations to activate when the actor provider or model changes. If unset, the top-level
|
|
82
|
+
**observation.activateOnProviderChange** (`boolean`): Force buffered observations to activate when the actor provider or model changes. If unset, the top-level activateOnProviderChange value is used for observations.
|
|
83
83
|
|
|
84
|
-
**observation.blockAfter** (`number`): Token threshold above which synchronous (blocking) observation is forced. Between
|
|
84
|
+
**observation.blockAfter** (`number`): Token threshold above which synchronous (blocking) observation is forced. Between messageTokens and blockAfter, only async buffering/activation is used. Above blockAfter, a synchronous observation runs as a last resort, while buffered activation still preserves a minimum remaining context (min(1000, retention floor)). Accepts a multiplier (1 < value < 2, multiplied by messageTokens) or an absolute token count (≥ 2, must be greater than messageTokens). Only relevant when bufferTokens is set. Defaults to 1.2 when async buffering is enabled.
|
|
85
85
|
|
|
86
|
-
**observation.previousObserverTokens** (`number | false`): Optional token budget for the observer's previous-observations context. When set to a number, the observations passed to the Observer agent are tail-truncated to fit within this budget while keeping the newest observations and preserving highlighted 🔴 items when possible. When a buffered reflection is pending, the already-reflected observation lines are automatically replaced with the reflection summary before truncation. Set to
|
|
86
|
+
**observation.previousObserverTokens** (`number | false`): Optional token budget for the observer's previous-observations context. When set to a number, the observations passed to the Observer agent are tail-truncated to fit within this budget while keeping the newest observations and preserving highlighted 🔴 items when possible. When a buffered reflection is pending, the already-reflected observation lines are automatically replaced with the reflection summary before truncation. Set to 0 to omit previous observations entirely, or false to disable truncation explicitly.
|
|
87
87
|
|
|
88
88
|
**reflection** (`ObservationalMemoryReflectionConfig`): Configuration for the reflection step. Controls when the Reflector agent runs and how it behaves.
|
|
89
89
|
|
|
90
|
-
**reflection.model** (`string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for the Reflector agent. Cannot be set if a top-level
|
|
90
|
+
**reflection.model** (`string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for the Reflector agent. Cannot be set if a top-level model is also provided. If neither this nor the top-level model is set, falls back to observation.model.
|
|
91
91
|
|
|
92
92
|
**reflection.instruction** (`string`): Custom instruction appended to the Reflector's system prompt. Use this to customize how the Reflector consolidates observations, such as prioritizing certain types of information.
|
|
93
93
|
|
|
@@ -101,13 +101,13 @@ OM performs thresholding with fast local token estimation. Text uses `tokenx`, a
|
|
|
101
101
|
|
|
102
102
|
**reflection.modelSettings.maxOutputTokens** (`number`): Maximum output tokens. Set high to prevent truncation of observations.
|
|
103
103
|
|
|
104
|
-
**reflection.bufferActivation** (`number`): Ratio (0-1) controlling when async reflection buffering starts. When observation tokens reach
|
|
104
|
+
**reflection.bufferActivation** (`number`): Ratio (0-1) controlling when async reflection buffering starts. When observation tokens reach observationTokens \* bufferActivation, reflection runs in the background. On activation at the full threshold, the buffered reflection replaces the observations it covers, preserving any new observations appended after that range.
|
|
105
105
|
|
|
106
|
-
**reflection.activateAfterIdle** (`number | string | false | "auto"`): Time before buffered reflections are forced to activate after inactivity. Accepts milliseconds, a duration string,
|
|
106
|
+
**reflection.activateAfterIdle** (`number | string | false | "auto"`): Time before buffered reflections are forced to activate after inactivity. Accepts milliseconds, a duration string, "auto" for a provider-aware prompt cache TTL, or false. Reflections do not inherit top-level activateAfterIdle; set this explicitly to opt reflections into idle activation.
|
|
107
107
|
|
|
108
|
-
**reflection.activateOnProviderChange** (`boolean`): Force buffered reflections to activate when the actor provider or model changes. Reflections do not inherit top-level
|
|
108
|
+
**reflection.activateOnProviderChange** (`boolean`): Force buffered reflections to activate when the actor provider or model changes. Reflections do not inherit top-level activateOnProviderChange; set this explicitly to opt reflections into provider-change activation.
|
|
109
109
|
|
|
110
|
-
**reflection.blockAfter** (`number`): Token threshold above which synchronous (blocking) reflection is forced. Between
|
|
110
|
+
**reflection.blockAfter** (`number`): Token threshold above which synchronous (blocking) reflection is forced. Between observationTokens and blockAfter, only async buffering/activation is used. Above blockAfter, a synchronous reflection runs as a last resort. Accepts a multiplier (1 < value < 2, multiplied by observationTokens) or an absolute token count (≥ 2, must be greater than observationTokens). Only relevant when bufferActivation is set. Defaults to 1.2 when async reflection is enabled.
|
|
111
111
|
|
|
112
112
|
### Token estimate metadata cache
|
|
113
113
|
|
|
@@ -156,7 +156,7 @@ const memory = new Memory({
|
|
|
156
156
|
|
|
157
157
|
**schema** (`ZodType<T> | (context) => ZodType<T> | undefined`): Optional Zod schema for structured extraction. When provided, OM runs a follow-up structured output call after the main OM operation. When omitted, the extractor is an inline string extractor emitted in the Observer or Reflector response. Use a function to derive the schema from runtime context.
|
|
158
158
|
|
|
159
|
-
**includePreviousExtraction** (`boolean`): Controls whether the previous extraction is shown to the extractor on future OM runs. Set to
|
|
159
|
+
**includePreviousExtraction** (`boolean`): Controls whether the previous extraction is shown to the extractor on future OM runs. Set to false for values that should only come from the current OM run. (Default: `true`)
|
|
160
160
|
|
|
161
161
|
**onExtracted** (`(context) => T | void | Promise<T | void>`): Optional hook called after a custom extractor returns a value and before metadata is persisted. Returning a value replaces the extracted value. Throwing records an extraction failure.
|
|
162
162
|
|
|
@@ -498,13 +498,13 @@ Emitted when the Observer or Reflector agent begins processing.
|
|
|
498
498
|
|
|
499
499
|
**threadIds** (`string[]`): All thread IDs in this batch (for resource-scoped).
|
|
500
500
|
|
|
501
|
-
**config** (`ObservationMarkerConfig`): Snapshot of
|
|
501
|
+
**config** (`ObservationMarkerConfig`): Snapshot of messageTokens, observationTokens, and scope at observation time.
|
|
502
502
|
|
|
503
503
|
### `data-om-observation-end`
|
|
504
504
|
|
|
505
505
|
Emitted when observation or reflection completes successfully.
|
|
506
506
|
|
|
507
|
-
**cycleId** (`string`): Matches the corresponding
|
|
507
|
+
**cycleId** (`string`): Matches the corresponding start marker.
|
|
508
508
|
|
|
509
509
|
**operationType** (`'observation' | 'reflection'`): Type of operation that completed.
|
|
510
510
|
|
|
@@ -534,7 +534,7 @@ Emitted when observation or reflection completes successfully.
|
|
|
534
534
|
|
|
535
535
|
Emitted when observation or reflection fails. The system falls back to synchronous processing.
|
|
536
536
|
|
|
537
|
-
**cycleId** (`string`): Matches the corresponding
|
|
537
|
+
**cycleId** (`string`): Matches the corresponding start marker.
|
|
538
538
|
|
|
539
539
|
**operationType** (`'observation' | 'reflection'`): Type of operation that failed.
|
|
540
540
|
|
|
@@ -576,7 +576,7 @@ Emitted when async buffering begins in the background. Buffering pre-computes ob
|
|
|
576
576
|
|
|
577
577
|
Emitted when async buffering completes. The content is stored but not yet activated in the main context.
|
|
578
578
|
|
|
579
|
-
**cycleId** (`string`): Matches the corresponding
|
|
579
|
+
**cycleId** (`string`): Matches the corresponding buffering-start marker.
|
|
580
580
|
|
|
581
581
|
**operationType** (`'observation' | 'reflection'`): Type of operation that was buffered.
|
|
582
582
|
|
|
@@ -602,7 +602,7 @@ Emitted when async buffering completes. The content is stored but not yet activa
|
|
|
602
602
|
|
|
603
603
|
Emitted when async buffering fails. The system falls back to synchronous processing when the threshold is reached.
|
|
604
604
|
|
|
605
|
-
**cycleId** (`string`): Matches the corresponding
|
|
605
|
+
**cycleId** (`string`): Matches the corresponding buffering-start marker.
|
|
606
606
|
|
|
607
607
|
**operationType** (`'observation' | 'reflection'`): Type of operation that failed.
|
|
608
608
|
|
|
@@ -688,7 +688,7 @@ export const agent = new Agent({
|
|
|
688
688
|
|
|
689
689
|
The standalone `ObservationalMemory` class accepts all the same options as the `observationalMemory` config object above, plus the following:
|
|
690
690
|
|
|
691
|
-
**storage** (`MemoryStorage`): Storage adapter for persisting observations. Must be a MemoryStorage instance (from
|
|
691
|
+
**storage** (`MemoryStorage`): Storage adapter for persisting observations. Must be a MemoryStorage instance (from MastraStorage.stores.memory).
|
|
692
692
|
|
|
693
693
|
**onDebugEvent** (`(event: ObservationDebugEvent) => void`): Debug callback for observation events. Called whenever observation-related events occur. Useful for debugging and understanding the observation flow.
|
|
694
694
|
|
|
@@ -700,29 +700,29 @@ When `retrieval` is set (any truthy value), a `recall` tool is registered so the
|
|
|
700
700
|
|
|
701
701
|
### Parameters
|
|
702
702
|
|
|
703
|
-
**mode** (`'messages' | 'threads' | 'search'`): What to retrieve.
|
|
703
|
+
**mode** (`'messages' | 'threads' | 'search'`): What to retrieve. "messages" (default) pages through message history. "threads" lists all threads for the current user. "search" finds messages by semantic similarity across all threads (requires vector store and embedder). (Default: `'messages'`)
|
|
704
704
|
|
|
705
|
-
**query** (`string`): Search query for
|
|
705
|
+
**query** (`string`): Search query for mode: "search". Finds messages semantically similar to this text across all threads for the current user.
|
|
706
706
|
|
|
707
|
-
**cursor** (`string`): A message ID to anchor the recall query. Required for
|
|
707
|
+
**cursor** (`string`): A message ID to anchor the recall query. Required for mode: "messages" when browsing the current thread. Extract the start or end ID from an observation group range (e.g. from \_range: \startId:endId\\\_, use either startId or endId). If a range string is passed directly, the tool returns a hint explaining how to extract the correct ID. Can be omitted when threadId is provided to start reading from the beginning of that thread.
|
|
708
708
|
|
|
709
|
-
**threadId** (`string`): Browse a different thread by its ID. Use
|
|
709
|
+
**threadId** (`string`): Browse a different thread by its ID. Use mode: "threads" first to discover thread IDs. When provided without a cursor, reading starts from the beginning of the thread.
|
|
710
710
|
|
|
711
|
-
**page** (`number`): Pagination offset. For messages: positive values page forward from cursor, negative values page backward. For threads: page number (0-indexed).
|
|
711
|
+
**page** (`number`): Pagination offset. For messages: positive values page forward from cursor, negative values page backward. For threads: page number (0-indexed). 0 is treated as 1 for messages. (Default: `1`)
|
|
712
712
|
|
|
713
713
|
**limit** (`number`): Maximum number of items to return per page. (Default: `20`)
|
|
714
714
|
|
|
715
|
-
**detail** (`'low' | 'high'`): Controls how much content is shown per message part.
|
|
715
|
+
**detail** (`'low' | 'high'`): Controls how much content is shown per message part. 'low' shows truncated text and tool names with positional indices (\[p0], \[p1]). 'high' shows full content including tool arguments and results, clamped to one part per call with continuation hints. (Default: `'low'`)
|
|
716
716
|
|
|
717
|
-
**partIndex** (`number`): Fetch a single message part at full detail by its positional index. Use this when a low-detail recall shows an interesting part at
|
|
717
|
+
**partIndex** (`number`): Fetch a single message part at full detail by its positional index. Use this when a low-detail recall shows an interesting part at \[p1] — call again with partIndex: 1 to see the full content without loading every part.
|
|
718
718
|
|
|
719
|
-
**before** (`string`): For
|
|
719
|
+
**before** (`string`): For mode: "threads" only. Filter to threads created before this date. Accepts ISO 8601 format (e.g. "2026-03-15", "2026-03-10T00:00:00Z").
|
|
720
720
|
|
|
721
|
-
**after** (`string`): For
|
|
721
|
+
**after** (`string`): For mode: "threads" only. Filter to threads created after this date. Accepts ISO 8601 format (e.g. "2026-03-01", "2026-03-10T00:00:00Z").
|
|
722
722
|
|
|
723
723
|
### Returns (messages mode)
|
|
724
724
|
|
|
725
|
-
**messages** (`string`): Formatted message content. Format depends on the
|
|
725
|
+
**messages** (`string`): Formatted message content. Format depends on the detail level.
|
|
726
726
|
|
|
727
727
|
**count** (`number`): Number of messages in this page.
|
|
728
728
|
|
|
@@ -736,13 +736,13 @@ When `retrieval` is set (any truthy value), a `recall` tool is registered so the
|
|
|
736
736
|
|
|
737
737
|
**hasPrevPage** (`boolean`): Whether more messages exist before this page.
|
|
738
738
|
|
|
739
|
-
**truncated** (`boolean`): Present and
|
|
739
|
+
**truncated** (`boolean`): Present and true when the output was capped by the token budget. The agent can paginate or use partIndex to access remaining content.
|
|
740
740
|
|
|
741
|
-
**tokenOffset** (`number`): Approximate number of tokens that were trimmed when
|
|
741
|
+
**tokenOffset** (`number`): Approximate number of tokens that were trimmed when truncated is true.
|
|
742
742
|
|
|
743
743
|
### Returns (threads mode)
|
|
744
744
|
|
|
745
|
-
**threads** (`string`): Formatted thread listing. Each thread shows its title, ID, and dates. The current thread is marked with
|
|
745
|
+
**threads** (`string`): Formatted thread listing. Each thread shows its title, ID, and dates. The current thread is marked with ← current.
|
|
746
746
|
|
|
747
747
|
**count** (`number`): Number of threads returned.
|
|
748
748
|
|
|
@@ -22,9 +22,9 @@ await memory?.recall({ threadId: 'user-123' })
|
|
|
22
22
|
|
|
23
23
|
**page** (`number`): Zero-based page number for pagination. Used with perPage to retrieve messages in batches.
|
|
24
24
|
|
|
25
|
-
**include** (`{ id: string; threadId?: string; withPreviousMessages?: number; withNextMessages?: number }[]`): Array of specific message IDs to include with optional context messages. Each item has an
|
|
25
|
+
**include** (`{ id: string; threadId?: string; withPreviousMessages?: number; withNextMessages?: number }[]`): Array of specific message IDs to include with optional context messages. Each item has an id (required), optional threadId (defaults to main threadId), withPreviousMessages (number of messages before, defaults to 2 for vector search, 0 otherwise), and withNextMessages (number of messages after, defaults to 2 for vector search, 0 otherwise).
|
|
26
26
|
|
|
27
|
-
**filter** (`{ dateRange?: { start?: Date; end?: Date; startExclusive?: boolean; endExclusive?: boolean } }`): Filter options for message retrieval. Currently supports
|
|
27
|
+
**filter** (`{ dateRange?: { start?: Date; end?: Date; startExclusive?: boolean; endExclusive?: boolean } }`): Filter options for message retrieval. Currently supports dateRange to filter messages by creation date. Use startExclusive or endExclusive to exclude boundary dates (useful for cursor-based pagination).
|
|
28
28
|
|
|
29
29
|
**orderBy** (`{ field: 'createdAt'; direction: 'ASC' | 'DESC' }`): Sort order for retrieved messages. Defaults to descending by creation date.
|
|
30
30
|
|
|
@@ -34,9 +34,9 @@ await memory?.recall({ threadId: 'user-123' })
|
|
|
34
34
|
|
|
35
35
|
**threadConfig.semanticRecall** (`boolean | { topK: number; messageRange: number | { before: number; after: number }; scope?: 'thread' | 'resource' }`): Enable semantic search in message history. Can be a boolean or an object with configuration options. When enabled, requires both vector store and embedder to be configured.
|
|
36
36
|
|
|
37
|
-
**threadConfig.workingMemory** (`WorkingMemory`): Configuration for working memory feature. Can be
|
|
37
|
+
**threadConfig.workingMemory** (`WorkingMemory`): Configuration for working memory feature. Can be { enabled: boolean; template?: string; schema?: ZodObject\<any> | JSONSchema7; scope?: 'thread' | 'resource' } or { enabled: boolean } to disable.
|
|
38
38
|
|
|
39
|
-
**threadConfig.threads** (`{ generateTitle?: boolean | { model: DynamicArgument<MastraLanguageModel>; instructions?: DynamicArgument<string> } }`): Settings related to memory thread creation.
|
|
39
|
+
**threadConfig.threads** (`{ generateTitle?: boolean | { model: DynamicArgument<MastraLanguageModel>; instructions?: DynamicArgument<string> } }`): Settings related to memory thread creation. generateTitle controls automatic thread title generation from the user's first message. Can be a boolean or an object with custom model and instructions.
|
|
40
40
|
|
|
41
41
|
## Returns
|
|
42
42
|
|
|
@@ -28,9 +28,9 @@ new MastraEditor({
|
|
|
28
28
|
|
|
29
29
|
## Properties
|
|
30
30
|
|
|
31
|
-
**vector** (`string | false`): Vector store identifier. The vector instance must be registered with the Mastra instance to resolve from this ID. Set to
|
|
31
|
+
**vector** (`string | false`): Vector store identifier. The vector instance must be registered with the Mastra instance to resolve from this ID. Set to false to disable vector search.
|
|
32
32
|
|
|
33
|
-
**embedder** (`string`): Embedding model ID in the format
|
|
33
|
+
**embedder** (`string`): Embedding model ID in the format "provider/model" (for example, "openai/text-embedding-3-small").
|
|
34
34
|
|
|
35
35
|
**embedderOptions** (`Omit<MastraEmbeddingOptions, 'telemetry'>`): Options passed to the embedder. Telemetry options are stripped.
|
|
36
36
|
|
|
@@ -38,17 +38,17 @@ new MastraEditor({
|
|
|
38
38
|
|
|
39
39
|
**options.readOnly** (`boolean`): Treat memory as read-only — no new messages are stored.
|
|
40
40
|
|
|
41
|
-
**options.lastMessages** (`number | false`): Number of recent messages to include in context, or
|
|
41
|
+
**options.lastMessages** (`number | false`): Number of recent messages to include in context, or false to disable.
|
|
42
42
|
|
|
43
43
|
**options.semanticRecall** (`boolean | SemanticRecall`): Semantic recall configuration. See the Memory class reference for the full shape.
|
|
44
44
|
|
|
45
|
-
**options.generateTitle** (`boolean | { model: ModelRouterModelId; instructions?: string }`): Title generation configuration. Pass an object with
|
|
45
|
+
**options.generateTitle** (`boolean | { model: ModelRouterModelId; instructions?: string }`): Title generation configuration. Pass an object with model (in "provider/model" form) and optional instructions.
|
|
46
46
|
|
|
47
|
-
**observationalMemory** (`boolean | SerializedObservationalMemoryConfig`): Long-lived fact extraction. Pass
|
|
47
|
+
**observationalMemory** (`boolean | SerializedObservationalMemoryConfig`): Long-lived fact extraction. Pass true to enable with defaults, or an object to override observer/reflector models, scope, and activation behavior.
|
|
48
48
|
|
|
49
49
|
## `SerializedObservationalMemoryConfig`
|
|
50
50
|
|
|
51
|
-
**model** (`string`): Model ID used by both the Observer and Reflector (for example,
|
|
51
|
+
**model** (`string`): Model ID used by both the Observer and Reflector (for example, "google/gemini-2.5-flash").
|
|
52
52
|
|
|
53
53
|
**scope** (`'resource' | 'thread'`): Whether observations are scoped to a resource or a single thread.
|
|
54
54
|
|