@mastra/core 1.2.1-alpha.0 → 1.3.0-alpha.1
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/CHANGELOG.md +335 -0
- package/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +2093 -262
- package/dist/agent/agent-legacy.d.ts.map +1 -1
- package/dist/agent/agent.d.ts +12 -3
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +13 -13
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/index.cjs +18 -18
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/message-list/message-list.d.ts.map +1 -1
- package/dist/agent/types.d.ts +6 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +3 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts +3 -1
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts.map +1 -1
- package/dist/base.cjs +2 -2
- package/dist/base.d.ts +13 -1
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +1 -1
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.js +1 -1
- package/dist/cache/index.cjs +3 -3
- package/dist/cache/index.js +1 -1
- package/dist/{chunk-ENCTSDWC.js → chunk-2GWTJFVM.js} +2410 -1402
- package/dist/chunk-2GWTJFVM.js.map +1 -0
- package/dist/{chunk-OB4V67IX.cjs → chunk-2K5PNW2U.cjs} +4 -4
- package/dist/{chunk-OB4V67IX.cjs.map → chunk-2K5PNW2U.cjs.map} +1 -1
- package/dist/{chunk-VZXYBFCX.cjs → chunk-2P6DD7M5.cjs} +10 -10
- package/dist/{chunk-VZXYBFCX.cjs.map → chunk-2P6DD7M5.cjs.map} +1 -1
- package/dist/{chunk-Q2D7LERO.cjs → chunk-2VD5OGOT.cjs} +4 -4
- package/dist/{chunk-Q2D7LERO.cjs.map → chunk-2VD5OGOT.cjs.map} +1 -1
- package/dist/{chunk-GVLPTDJA.cjs → chunk-5VMWMXSI.cjs} +236 -63
- package/dist/chunk-5VMWMXSI.cjs.map +1 -0
- package/dist/{chunk-4NG7CKEG.js → chunk-6VGCVSP4.js} +3 -3
- package/dist/{chunk-4NG7CKEG.js.map → chunk-6VGCVSP4.js.map} +1 -1
- package/dist/{chunk-IIZF4W7B.cjs → chunk-7UWHFWST.cjs} +52 -5
- package/dist/chunk-7UWHFWST.cjs.map +1 -0
- package/dist/{chunk-WFUNLRQX.js → chunk-AFF24QUP.js} +366 -134
- package/dist/chunk-AFF24QUP.js.map +1 -0
- package/dist/{chunk-VW7YQWDW.cjs → chunk-BFIOQFGF.cjs} +28 -2
- package/dist/chunk-BFIOQFGF.cjs.map +1 -0
- package/dist/{chunk-HMCXNOF6.cjs → chunk-CGPH7CMG.cjs} +2431 -1417
- package/dist/chunk-CGPH7CMG.cjs.map +1 -0
- package/dist/{chunk-HN2MSTR6.cjs → chunk-D5B5ON7A.cjs} +269 -42
- package/dist/chunk-D5B5ON7A.cjs.map +1 -0
- package/dist/{chunk-2DMSFLJY.cjs → chunk-DD7377YA.cjs} +8 -8
- package/dist/chunk-DD7377YA.cjs.map +1 -0
- package/dist/{chunk-A5QFWX67.cjs → chunk-DULE2DRR.cjs} +79 -59
- package/dist/chunk-DULE2DRR.cjs.map +1 -0
- package/dist/{chunk-ZWM2CAIM.js → chunk-ELBCIHOB.js} +4 -4
- package/dist/{chunk-ZWM2CAIM.js.map → chunk-ELBCIHOB.js.map} +1 -1
- package/dist/{chunk-W3AQUG66.js → chunk-GIY5BINT.js} +4 -4
- package/dist/{chunk-W3AQUG66.js.map → chunk-GIY5BINT.js.map} +1 -1
- package/dist/{chunk-M6VFJX5A.js → chunk-GMSAGYTB.js} +3 -3
- package/dist/{chunk-M6VFJX5A.js.map → chunk-GMSAGYTB.js.map} +1 -1
- package/dist/{chunk-E3VFKTIA.js → chunk-GMSEZYLZ.js} +2245 -179
- package/dist/chunk-GMSEZYLZ.js.map +1 -0
- package/dist/{chunk-JRJJ5VQE.cjs → chunk-GZD6443M.cjs} +99 -55
- package/dist/chunk-GZD6443M.cjs.map +1 -0
- package/dist/{chunk-Z6NRYYOH.js → chunk-ILQXPZCD.js} +9 -4
- package/dist/chunk-ILQXPZCD.js.map +1 -0
- package/dist/{chunk-MQB7XFXP.js → chunk-LHRHOPUC.js} +3 -3
- package/dist/{chunk-MQB7XFXP.js.map → chunk-LHRHOPUC.js.map} +1 -1
- package/dist/{chunk-5YVR7B4R.js → chunk-LULKG6NF.js} +29 -9
- package/dist/chunk-LULKG6NF.js.map +1 -0
- package/dist/{chunk-MSWXEOZC.js → chunk-MAX37NGP.js} +5 -5
- package/dist/chunk-MAX37NGP.js.map +1 -0
- package/dist/{chunk-HU2ONA2W.cjs → chunk-ON2KVIUJ.cjs} +17 -17
- package/dist/{chunk-HU2ONA2W.cjs.map → chunk-ON2KVIUJ.cjs.map} +1 -1
- package/dist/{chunk-I66TMZJ3.cjs → chunk-OOCEAC6U.cjs} +21 -18
- package/dist/chunk-OOCEAC6U.cjs.map +1 -0
- package/dist/{chunk-MNWW2R3U.js → chunk-OV7OOUUR.js} +90 -54
- package/dist/chunk-OV7OOUUR.js.map +1 -0
- package/dist/{chunk-C4WWWQHT.cjs → chunk-RO47SMI7.cjs} +23 -3
- package/dist/chunk-RO47SMI7.cjs.map +1 -0
- package/dist/{chunk-6FG6FU5Y.cjs → chunk-RQ56ZSIR.cjs} +4 -4
- package/dist/{chunk-6FG6FU5Y.cjs.map → chunk-RQ56ZSIR.cjs.map} +1 -1
- package/dist/{chunk-IW3BNL7A.js → chunk-RS6CZXGA.js} +50 -3
- package/dist/chunk-RS6CZXGA.js.map +1 -0
- package/dist/{chunk-AIJLACR2.js → chunk-S53FKKVL.js} +27 -3
- package/dist/chunk-S53FKKVL.js.map +1 -0
- package/dist/{chunk-G6E3QNJC.js → chunk-SBPPGJL6.js} +4078 -4333
- package/dist/chunk-SBPPGJL6.js.map +1 -0
- package/dist/{chunk-UZL4H5P2.cjs → chunk-SH4PCZ3X.cjs} +5375 -5648
- package/dist/chunk-SH4PCZ3X.cjs.map +1 -0
- package/dist/{chunk-QOFI2WBM.cjs → chunk-SZH2YH74.cjs} +985 -223
- package/dist/chunk-SZH2YH74.cjs.map +1 -0
- package/dist/{chunk-XCPEEIHI.cjs → chunk-U4EG3D6G.cjs} +3012 -927
- package/dist/chunk-U4EG3D6G.cjs.map +1 -0
- package/dist/{chunk-7MDVYPWX.cjs → chunk-UE2G2LRP.cjs} +9 -4
- package/dist/chunk-UE2G2LRP.cjs.map +1 -0
- package/dist/{chunk-P62OJXQ4.js → chunk-VHAFCFYP.js} +268 -41
- package/dist/chunk-VHAFCFYP.js.map +1 -0
- package/dist/{chunk-VX7UA3SO.js → chunk-VJDLIS2E.js} +968 -211
- package/dist/chunk-VJDLIS2E.js.map +1 -0
- package/dist/{chunk-AUF6U2BL.js → chunk-VM25PDSW.js} +5 -5
- package/dist/{chunk-AUF6U2BL.js.map → chunk-VM25PDSW.js.map} +1 -1
- package/dist/{chunk-JIT2OY3X.js → chunk-WCAFTXGK.js} +23 -3
- package/dist/chunk-WCAFTXGK.js.map +1 -0
- package/dist/{chunk-YLODOPYM.cjs → chunk-XDD5V446.cjs} +4163 -5352
- package/dist/chunk-XDD5V446.cjs.map +1 -0
- package/dist/{chunk-RXD5EGQF.js → chunk-YMXQDOSQ.js} +228 -55
- package/dist/chunk-YMXQDOSQ.js.map +1 -0
- package/dist/{chunk-BP2TSCBW.js → chunk-ZATLLPIH.js} +4391 -5561
- package/dist/chunk-ZATLLPIH.js.map +1 -0
- package/dist/{chunk-5SOS47PH.cjs → chunk-ZC6IHDHX.cjs} +454 -222
- package/dist/chunk-ZC6IHDHX.cjs.map +1 -0
- package/dist/{chunk-T6PRRKMW.js → chunk-ZHFM7HCQ.js} +9 -6
- package/dist/chunk-ZHFM7HCQ.js.map +1 -0
- package/dist/{chunk-B4M33FCS.cjs → chunk-ZIWDJWC3.cjs} +7 -7
- package/dist/{chunk-B4M33FCS.cjs.map → chunk-ZIWDJWC3.cjs.map} +1 -1
- package/dist/deployer/index.cjs +2 -2
- package/dist/deployer/index.js +1 -1
- package/dist/docs/SKILL.md +2 -9
- package/dist/docs/assets/SOURCE_MAP.json +399 -342
- package/dist/docs/references/docs-agents-agent-memory.md +45 -1
- package/dist/docs/references/docs-agents-network-approval.md +1 -1
- package/dist/docs/references/docs-agents-networks.md +3 -3
- package/dist/docs/references/docs-agents-overview.md +8 -0
- package/dist/docs/references/docs-agents-using-tools.md +82 -72
- package/dist/docs/references/docs-memory-observational-memory.md +89 -17
- package/dist/docs/references/docs-observability-overview.md +1 -1
- package/dist/docs/references/docs-observability-tracing-exporters-langsmith.md +70 -0
- package/dist/docs/references/docs-observability-tracing-overview.md +1 -1
- package/dist/docs/references/docs-server-middleware.md +0 -2
- package/dist/docs/references/docs-server-request-context.md +17 -0
- package/dist/docs/references/docs-workflows-agents-and-tools.md +2 -2
- package/dist/docs/references/docs-workflows-overview.md +1 -1
- package/dist/docs/references/docs-workspace-filesystem.md +2 -0
- package/dist/docs/references/docs-workspace-overview.md +3 -1
- package/dist/docs/references/docs-workspace-sandbox.md +2 -0
- package/dist/docs/references/docs-workspace-search.md +2 -0
- package/dist/docs/references/docs-workspace-skills.md +3 -1
- package/dist/docs/references/reference-agents-getTools.md +1 -6
- package/dist/docs/references/reference-agents-listAgents.md +1 -1
- package/dist/docs/references/reference-agents-network.md +0 -2
- package/dist/docs/references/reference-cli-mastra.md +29 -4
- package/dist/docs/references/reference-client-js-agents.md +1 -1
- package/dist/docs/references/reference-configuration.md +1 -1
- package/dist/docs/references/reference-core-getStoredAgentById.md +2 -2
- package/dist/docs/references/reference-core-listStoredAgents.md +1 -1
- package/dist/docs/references/reference-memory-observational-memory.md +318 -7
- package/dist/docs/references/reference-tools-mcp-client.md +0 -2
- package/dist/docs/references/reference-workflows-step.md +2 -0
- package/dist/docs/references/reference-workflows-workflow-methods-map.md +2 -2
- package/dist/docs/references/reference-workspace-filesystem.md +2 -0
- package/dist/docs/references/reference-workspace-local-filesystem.md +2 -0
- package/dist/docs/references/reference-workspace-local-sandbox.md +2 -0
- package/dist/docs/references/reference-workspace-sandbox.md +2 -0
- package/dist/docs/references/reference-workspace-workspace-class.md +2 -0
- package/dist/docs/references/reference.md +7 -2
- package/dist/editor/index.d.ts +1 -1
- package/dist/editor/index.d.ts.map +1 -1
- package/dist/editor/types.d.ts +53 -48
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/evals/base.d.ts +15 -0
- package/dist/evals/base.d.ts.map +1 -1
- package/dist/evals/index.cjs +20 -20
- package/dist/evals/index.js +3 -3
- package/dist/evals/run/index.d.ts +3 -3
- package/dist/evals/run/index.d.ts.map +1 -1
- package/dist/evals/scoreTraces/index.cjs +5 -5
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/features/index.cjs +1 -1
- package/dist/features/index.cjs.map +1 -1
- package/dist/features/index.d.ts.map +1 -1
- package/dist/features/index.js +1 -1
- package/dist/features/index.js.map +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/integration/index.cjs +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +16 -16
- package/dist/llm/index.js +5 -5
- package/dist/llm/model/gateways/constants.d.ts.map +1 -1
- package/dist/llm/model/gateways/models-dev.d.ts.map +1 -1
- package/dist/llm/model/model.loop.d.ts +1 -1
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +122 -13
- package/dist/llm/model/resolve-model.d.ts.map +1 -1
- package/dist/loop/index.cjs +12 -12
- package/dist/loop/index.js +1 -1
- package/dist/loop/network/index.d.ts +3 -3
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/loop/network/run-command-tool.d.ts +1 -1
- package/dist/loop/types.d.ts +13 -0
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +9 -9
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +7 -7
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +3 -3
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +9 -9
- package/dist/loop/workflows/schema.d.ts +12 -12
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +91 -5
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/mcp/index.cjs +2 -2
- package/dist/mcp/index.js +1 -1
- package/dist/memory/index.cjs +14 -14
- package/dist/memory/index.js +1 -1
- package/dist/memory/mock.d.ts.map +1 -1
- package/dist/memory/types.d.ts +128 -0
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/models-dev-FQVUTQ7L.js +3 -0
- package/dist/{models-dev-Z45JSLWD.js.map → models-dev-FQVUTQ7L.js.map} +1 -1
- package/dist/models-dev-PPIXUUCU.cjs +12 -0
- package/dist/{models-dev-OQKVMEIT.cjs.map → models-dev-PPIXUUCU.cjs.map} +1 -1
- package/dist/netlify-4RIKF7Y3.js +3 -0
- package/dist/{netlify-SSWMYSAX.js.map → netlify-4RIKF7Y3.js.map} +1 -1
- package/dist/netlify-V5F7JEJH.cjs +12 -0
- package/dist/{netlify-TXZZCT6N.cjs.map → netlify-V5F7JEJH.cjs.map} +1 -1
- package/dist/processors/index.cjs +41 -41
- package/dist/processors/index.js +1 -1
- package/dist/processors/step-schema.d.ts +44 -44
- package/dist/provider-registry-BJJRUX4P.cjs +40 -0
- package/dist/{provider-registry-NR7FXV2Q.cjs.map → provider-registry-BJJRUX4P.cjs.map} +1 -1
- package/dist/provider-registry-VZYB342T.js +3 -0
- package/dist/{provider-registry-RPOTQNHI.js.map → provider-registry-VZYB342T.js.map} +1 -1
- package/dist/provider-registry.json +264 -37
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/server/index.cjs +3 -3
- package/dist/server/index.js +1 -1
- package/dist/storage/base.d.ts +3 -1
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/constants.cjs +51 -19
- package/dist/storage/constants.d.ts +10 -2
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/agents/base.d.ts +13 -164
- package/dist/storage/domains/agents/base.d.ts.map +1 -1
- package/dist/storage/domains/agents/index.d.ts +0 -1
- package/dist/storage/domains/agents/index.d.ts.map +1 -1
- package/dist/storage/domains/agents/inmemory.d.ts +6 -10
- package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/index.d.ts +3 -0
- package/dist/storage/domains/index.d.ts.map +1 -1
- package/dist/storage/domains/inmemory-db.d.ts +7 -1
- package/dist/storage/domains/inmemory-db.d.ts.map +1 -1
- package/dist/storage/domains/memory/base.d.ts +41 -1
- package/dist/storage/domains/memory/base.d.ts.map +1 -1
- package/dist/storage/domains/memory/inmemory.d.ts +6 -6
- package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/observability/types.d.ts +62 -62
- package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/prompt-blocks/base.d.ts +47 -0
- package/dist/storage/domains/prompt-blocks/base.d.ts.map +1 -0
- package/dist/storage/domains/prompt-blocks/index.d.ts +3 -0
- package/dist/storage/domains/prompt-blocks/index.d.ts.map +1 -0
- package/dist/storage/domains/prompt-blocks/inmemory.d.ts +31 -0
- package/dist/storage/domains/prompt-blocks/inmemory.d.ts.map +1 -0
- package/dist/storage/domains/scorer-definitions/base.d.ts +47 -0
- package/dist/storage/domains/scorer-definitions/base.d.ts.map +1 -0
- package/dist/storage/domains/scorer-definitions/index.d.ts +3 -0
- package/dist/storage/domains/scorer-definitions/index.d.ts.map +1 -0
- package/dist/storage/domains/scorer-definitions/inmemory.d.ts +31 -0
- package/dist/storage/domains/scorer-definitions/inmemory.d.ts.map +1 -0
- package/dist/storage/domains/versioned.d.ts +136 -0
- package/dist/storage/domains/versioned.d.ts.map +1 -0
- package/dist/storage/index.cjs +156 -104
- package/dist/storage/index.js +2 -2
- package/dist/storage/mock.d.ts.map +1 -1
- package/dist/storage/types.d.ts +481 -27
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/MastraAgentNetworkStream.d.ts +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts +1 -1
- package/dist/stream/RunOutput.d.ts +1 -1
- package/dist/stream/RunOutput.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts +4 -0
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +11 -11
- package/dist/stream/index.js +2 -2
- package/dist/test-utils/llm-mock.cjs +4 -4
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.js +1 -1
- package/dist/tools/is-vercel-tool.cjs +2 -2
- package/dist/tools/is-vercel-tool.js +1 -1
- package/dist/tools/tool-builder/builder.d.ts.map +1 -1
- package/dist/tools/types.d.ts +15 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/validation.d.ts.map +1 -1
- package/dist/tts/index.cjs +2 -2
- package/dist/tts/index.js +1 -1
- package/dist/types/zod-compat.d.ts +2 -2
- package/dist/types/zod-compat.d.ts.map +1 -1
- package/dist/utils/zod-utils.d.ts +19 -0
- package/dist/utils/zod-utils.d.ts.map +1 -1
- package/dist/utils.cjs +28 -28
- package/dist/utils.d.ts +7 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -2
- package/dist/vector/index.cjs +9 -9
- package/dist/vector/index.js +2 -2
- package/dist/voice/index.cjs +6 -6
- package/dist/voice/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/evented/workflow.d.ts +3 -1
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/execution-engine.d.ts.map +1 -1
- package/dist/workflows/index.cjs +25 -25
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/step.d.ts +4 -3
- package/dist/workflows/step.d.ts.map +1 -1
- package/dist/workflows/types.d.ts +2 -1
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +12 -4
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/dist/workspace/errors.d.ts +6 -0
- package/dist/workspace/errors.d.ts.map +1 -1
- package/dist/workspace/filesystem/composite-filesystem.d.ts +93 -0
- package/dist/workspace/filesystem/composite-filesystem.d.ts.map +1 -0
- package/dist/workspace/filesystem/filesystem.d.ts +35 -0
- package/dist/workspace/filesystem/filesystem.d.ts.map +1 -1
- package/dist/workspace/filesystem/index.d.ts +2 -0
- package/dist/workspace/filesystem/index.d.ts.map +1 -1
- package/dist/workspace/filesystem/local-filesystem.d.ts +9 -1
- package/dist/workspace/filesystem/local-filesystem.d.ts.map +1 -1
- package/dist/workspace/filesystem/mastra-filesystem.d.ts +92 -3
- package/dist/workspace/filesystem/mastra-filesystem.d.ts.map +1 -1
- package/dist/workspace/filesystem/mount.d.ts +34 -0
- package/dist/workspace/filesystem/mount.d.ts.map +1 -0
- package/dist/workspace/index.cjs +62 -34
- package/dist/workspace/index.d.ts +6 -2
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/lifecycle.d.ts +29 -0
- package/dist/workspace/lifecycle.d.ts.map +1 -1
- package/dist/workspace/sandbox/errors.d.ts +50 -0
- package/dist/workspace/sandbox/errors.d.ts.map +1 -0
- package/dist/workspace/sandbox/index.d.ts +3 -0
- package/dist/workspace/sandbox/index.d.ts.map +1 -1
- package/dist/workspace/sandbox/local-sandbox.d.ts +17 -2
- package/dist/workspace/sandbox/local-sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/mastra-sandbox.d.ts +153 -6
- package/dist/workspace/sandbox/mastra-sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/mount-manager.d.ts +195 -0
- package/dist/workspace/sandbox/mount-manager.d.ts.map +1 -0
- package/dist/workspace/sandbox/sandbox.d.ts +37 -84
- package/dist/workspace/sandbox/sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/types.d.ts +92 -0
- package/dist/workspace/sandbox/types.d.ts.map +1 -0
- package/dist/workspace/tools/tools.d.ts.map +1 -1
- package/dist/workspace/tools/tree-formatter.d.ts.map +1 -1
- package/dist/workspace/workspace.d.ts +73 -3
- package/dist/workspace/workspace.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/llm/model/provider-types.generated.d.ts +122 -13
- package/dist/chunk-2DMSFLJY.cjs.map +0 -1
- package/dist/chunk-5SOS47PH.cjs.map +0 -1
- package/dist/chunk-5YVR7B4R.js.map +0 -1
- package/dist/chunk-7MDVYPWX.cjs.map +0 -1
- package/dist/chunk-A5QFWX67.cjs.map +0 -1
- package/dist/chunk-AIJLACR2.js.map +0 -1
- package/dist/chunk-BP2TSCBW.js.map +0 -1
- package/dist/chunk-C4WWWQHT.cjs.map +0 -1
- package/dist/chunk-E3VFKTIA.js.map +0 -1
- package/dist/chunk-ENCTSDWC.js.map +0 -1
- package/dist/chunk-G6E3QNJC.js.map +0 -1
- package/dist/chunk-GVLPTDJA.cjs.map +0 -1
- package/dist/chunk-HMCXNOF6.cjs.map +0 -1
- package/dist/chunk-HN2MSTR6.cjs.map +0 -1
- package/dist/chunk-I66TMZJ3.cjs.map +0 -1
- package/dist/chunk-IIZF4W7B.cjs.map +0 -1
- package/dist/chunk-IW3BNL7A.js.map +0 -1
- package/dist/chunk-JIT2OY3X.js.map +0 -1
- package/dist/chunk-JRJJ5VQE.cjs.map +0 -1
- package/dist/chunk-MNWW2R3U.js.map +0 -1
- package/dist/chunk-MSWXEOZC.js.map +0 -1
- package/dist/chunk-P62OJXQ4.js.map +0 -1
- package/dist/chunk-QOFI2WBM.cjs.map +0 -1
- package/dist/chunk-RXD5EGQF.js.map +0 -1
- package/dist/chunk-T6PRRKMW.js.map +0 -1
- package/dist/chunk-UZL4H5P2.cjs.map +0 -1
- package/dist/chunk-VW7YQWDW.cjs.map +0 -1
- package/dist/chunk-VX7UA3SO.js.map +0 -1
- package/dist/chunk-WFUNLRQX.js.map +0 -1
- package/dist/chunk-XCPEEIHI.cjs.map +0 -1
- package/dist/chunk-YLODOPYM.cjs.map +0 -1
- package/dist/chunk-Z6NRYYOH.js.map +0 -1
- package/dist/docs/references/docs-tools-mcp-advanced-usage.md +0 -143
- package/dist/docs/references/docs-tools-mcp-mcp-overview.md +0 -383
- package/dist/docs/references/docs-tools-mcp-overview.md +0 -78
- package/dist/docs/references/docs-workflows-input-data-mapping.md +0 -102
- package/dist/docs/references/reference-deployer-netlify.md +0 -14
- package/dist/docs/references/reference-deployer-vercel.md +0 -39
- package/dist/docs/references/reference-tools-client.md +0 -228
- package/dist/models-dev-OQKVMEIT.cjs +0 -12
- package/dist/models-dev-Z45JSLWD.js +0 -3
- package/dist/netlify-SSWMYSAX.js +0 -3
- package/dist/netlify-TXZZCT6N.cjs +0 -12
- package/dist/provider-registry-NR7FXV2Q.cjs +0 -40
- package/dist/provider-registry-RPOTQNHI.js +0 -3
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Agents use memory to maintain context across interactions. LLMs are stateless and don't retain information between calls, so agents need memory to track message history and recall relevant information.
|
|
4
4
|
|
|
5
|
-
Mastra agents can be configured to store message history, with optional [working memory](https://mastra.ai/docs/memory/working-memory) to maintain recent context
|
|
5
|
+
Mastra agents can be configured to store message history, with optional [working memory](https://mastra.ai/docs/memory/working-memory) to maintain recent context, [semantic recall](https://mastra.ai/docs/memory/semantic-recall) to retrieve past messages based on meaning, or [observational memory](https://mastra.ai/docs/memory/observational-memory) for automatic long-term memory that compresses conversations as they grow.
|
|
6
6
|
|
|
7
7
|
## When to use memory
|
|
8
8
|
|
|
@@ -134,6 +134,49 @@ const response = await memoryAgent.generate("What's my favorite color?", {
|
|
|
134
134
|
|
|
135
135
|
To learn more about memory see the [Memory](https://mastra.ai/docs/memory/overview) documentation.
|
|
136
136
|
|
|
137
|
+
## Observational Memory
|
|
138
|
+
|
|
139
|
+
For long-running conversations, raw message history grows until it fills the context window, degrading agent performance. [Observational Memory](https://mastra.ai/docs/memory/observational-memory) solves this by running background agents that compress old messages into dense observations, keeping the context window small while preserving long-term memory.
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
import { Agent } from "@mastra/core/agent";
|
|
143
|
+
import { Memory } from "@mastra/memory";
|
|
144
|
+
|
|
145
|
+
export const memoryAgent = new Agent({
|
|
146
|
+
id: 'memory-agent',
|
|
147
|
+
name: 'Memory Agent',
|
|
148
|
+
memory: new Memory({
|
|
149
|
+
options: {
|
|
150
|
+
observationalMemory: true,
|
|
151
|
+
},
|
|
152
|
+
}),
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Setting `observationalMemory: true` uses `google/gemini-2.5-flash` as the default model for the Observer and Reflector. To use a different model or customize thresholds, pass a config object:
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
import { Agent } from "@mastra/core/agent";
|
|
160
|
+
import { Memory } from "@mastra/memory";
|
|
161
|
+
|
|
162
|
+
export const memoryAgent = new Agent({
|
|
163
|
+
id: 'memory-agent',
|
|
164
|
+
name: 'Memory Agent',
|
|
165
|
+
memory: new Memory({
|
|
166
|
+
options: {
|
|
167
|
+
observationalMemory: {
|
|
168
|
+
model: "deepseek/deepseek-reasoner",
|
|
169
|
+
observation: {
|
|
170
|
+
messageTokens: 20_000,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
}),
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
> **Info:** See [Observational Memory](https://mastra.ai/docs/memory/observational-memory) for details on how observations and reflections work, and [the reference](https://mastra.ai/reference/memory/observational-memory) for all configuration options.
|
|
179
|
+
|
|
137
180
|
## Using `RequestContext`
|
|
138
181
|
|
|
139
182
|
Use [RequestContext](https://mastra.ai/docs/server/request-context) to access request-specific values. This lets you conditionally select different memory or storage configurations based on the context of the request.
|
|
@@ -162,6 +205,7 @@ export const memoryAgent = new Agent({
|
|
|
162
205
|
|
|
163
206
|
## Related
|
|
164
207
|
|
|
208
|
+
- [Observational Memory](https://mastra.ai/docs/memory/observational-memory)
|
|
165
209
|
- [Working Memory](https://mastra.ai/docs/memory/working-memory)
|
|
166
210
|
- [Semantic Recall](https://mastra.ai/docs/memory/semantic-recall)
|
|
167
211
|
- [Storage](https://mastra.ai/docs/memory/storage)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Network Approval
|
|
2
2
|
|
|
3
|
-
Agent networks can require the same [human-in-the-loop](https://mastra.ai/docs/workflows/human-in-the-loop) oversight used in individual agents and workflows. When a tool,
|
|
3
|
+
Agent networks can require the same [human-in-the-loop](https://mastra.ai/docs/workflows/human-in-the-loop) oversight used in individual agents and workflows. When a tool, subagent, or workflow within a network requires approval or suspends execution, the network pauses and emits events that allow your application to collect user input before resuming.
|
|
4
4
|
|
|
5
5
|
## Storage
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Agent Networks
|
|
2
2
|
|
|
3
|
-
Agent networks in Mastra coordinate multiple agents, workflows, and tools to handle tasks that aren't clearly defined upfront but can be inferred from the user's message or context. A top-level **routing agent** (a Mastra agent with other agents, workflows, and tools configured) uses an LLM to interpret the request and decide which primitives (
|
|
3
|
+
Agent networks in Mastra coordinate multiple agents, workflows, and tools to handle tasks that aren't clearly defined upfront but can be inferred from the user's message or context. A top-level **routing agent** (a Mastra agent with other agents, workflows, and tools configured) uses an LLM to interpret the request and decide which primitives (subagents, workflows, or tools) to call, in what order, and with what data.
|
|
4
4
|
|
|
5
5
|
## When to use networks
|
|
6
6
|
|
|
@@ -16,7 +16,7 @@ Mastra agent networks operate using these principles:
|
|
|
16
16
|
|
|
17
17
|
## Creating an agent network
|
|
18
18
|
|
|
19
|
-
An agent network is built around a top-level routing agent that delegates tasks to
|
|
19
|
+
An agent network is built around a top-level routing agent that delegates tasks to subagents, workflows, and tools defined in its configuration. Memory is configured on the routing agent using the `memory` option, and `instructions` define the agent's routing behavior.
|
|
20
20
|
|
|
21
21
|
```typescript
|
|
22
22
|
import { Agent } from "@mastra/core/agent";
|
|
@@ -64,7 +64,7 @@ When configuring a Mastra agent network, each primitive (agent, workflow, or too
|
|
|
64
64
|
|
|
65
65
|
#### Agent descriptions
|
|
66
66
|
|
|
67
|
-
Each
|
|
67
|
+
Each subagent in a network should include a clear `description` that explains what the agent does.
|
|
68
68
|
|
|
69
69
|
```typescript
|
|
70
70
|
export const researchAgent = new Agent({
|
|
@@ -119,6 +119,14 @@ export const mastra = new Mastra({
|
|
|
119
119
|
});
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
+
### Registering subagents
|
|
123
|
+
|
|
124
|
+
You can register subagents within an agent. They'll be executed as tools from the parent agent. Read the [using agents as tools](https://mastra.ai/docs/agents/using-tools) documentation to learn more.
|
|
125
|
+
|
|
126
|
+
### Registering subworkflows
|
|
127
|
+
|
|
128
|
+
You can register subworkflows within an agent. They'll be executed as tools from the parent agent. Read the [using workflows as tools](https://mastra.ai/docs/agents/using-tools) documentation to learn more.
|
|
129
|
+
|
|
122
130
|
## Referencing an agent
|
|
123
131
|
|
|
124
132
|
You can call agents from workflow steps, tools, the Mastra Client, or the command line. Get a reference by calling `.getAgent()` on your `mastra` or `mastraClient` instance, depending on your setup:
|
|
@@ -57,84 +57,49 @@ export const weatherAgent = new Agent({
|
|
|
57
57
|
});
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
##
|
|
60
|
+
## Using multiple tools
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
When multiple tools are available, the agent may choose to use one, several, or none, depending on what's needed to answer the query.
|
|
63
63
|
|
|
64
64
|
```typescript
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
id: "weather-tool",
|
|
68
|
-
// ...
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// Using the variable name as the key
|
|
72
|
-
tools: { weatherTool }
|
|
73
|
-
// Stream returns: toolName: "weatherTool"
|
|
74
|
-
|
|
75
|
-
// Using the tool's id as the key
|
|
76
|
-
tools: { [weatherTool.id]: weatherTool }
|
|
77
|
-
// Stream returns: toolName: "weather-tool"
|
|
65
|
+
import { weatherTool } from "../tools/weather-tool";
|
|
66
|
+
import { activitiesTool } from "../tools/activities-tool";
|
|
78
67
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
68
|
+
export const weatherAgent = new Agent({
|
|
69
|
+
id: "weather-agent",
|
|
70
|
+
name: "Weather Agent",
|
|
71
|
+
tools: { weatherTool, activitiesTool },
|
|
72
|
+
});
|
|
82
73
|
```
|
|
83
74
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
### Sub-agents and workflows as tools
|
|
87
|
-
|
|
88
|
-
Sub-agents and workflows follow the same pattern. They are converted to tools with a prefix followed by your object key:
|
|
75
|
+
## Using agents as tools
|
|
89
76
|
|
|
90
|
-
|
|
91
|
-
| ----------- | ----------- | ----------- | ------------------- |
|
|
92
|
-
| `agents` | `agent-` | `weather` | `agent-weather` |
|
|
93
|
-
| `workflows` | `workflow-` | `research` | `workflow-research` |
|
|
77
|
+
Agents can be added to other agents through the `agents` configuration. When you add a subagent, Mastra automatically converts it to a tool that the parent agent can call. The generated tool is named `agent-<agentName>`.
|
|
94
78
|
|
|
95
79
|
```typescript
|
|
96
|
-
|
|
97
|
-
|
|
80
|
+
import { Agent } from "@mastra/core/agent";
|
|
81
|
+
|
|
82
|
+
export const parentAgent = new Agent({
|
|
83
|
+
id: "parent-agent",
|
|
84
|
+
name: "Parent Agent",
|
|
85
|
+
description: "Take care in writing a good description here",
|
|
86
|
+
instructions: `Instructions`,
|
|
87
|
+
model: "openai/gpt-5.1",
|
|
98
88
|
agents: {
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
-
workflows: {
|
|
102
|
-
research: researchWorkflow, // toolName: "workflow-research"
|
|
89
|
+
subAgent,
|
|
103
90
|
},
|
|
104
91
|
});
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
Note that for sub-agents, you'll see two different identifiers in stream responses:
|
|
108
92
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
```typescript
|
|
117
|
-
import { mastra } from "./mastra";
|
|
118
|
-
|
|
119
|
-
const agent = mastra.getAgent("weatherAgent");
|
|
120
|
-
|
|
121
|
-
const result = await agent.generate("What's the weather in London?");
|
|
93
|
+
const subAgent = new Agent({
|
|
94
|
+
id: "sub-agent",
|
|
95
|
+
name: "Sub Agent",
|
|
96
|
+
description: "Take care in writing a good description here",
|
|
97
|
+
instructions: `Instructions`,
|
|
98
|
+
model: "openai/gpt-5.1",
|
|
99
|
+
})
|
|
122
100
|
```
|
|
123
101
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
When multiple tools are available, the agent may choose to use one, several, or none, depending on what's needed to answer the query.
|
|
127
|
-
|
|
128
|
-
```typescript
|
|
129
|
-
import { weatherTool } from "../tools/weather-tool";
|
|
130
|
-
import { activitiesTool } from "../tools/activities-tool";
|
|
131
|
-
|
|
132
|
-
export const weatherAgent = new Agent({
|
|
133
|
-
id: "weather-agent",
|
|
134
|
-
name: "Weather Agent",
|
|
135
|
-
tools: { weatherTool, activitiesTool },
|
|
136
|
-
});
|
|
137
|
-
```
|
|
102
|
+
The subagent should include a `description` to help the parent agent understand when to use it. See the [`toolName` docs](#subagents-and-workflows-as-tools) to learn more about the tool naming scheme.
|
|
138
103
|
|
|
139
104
|
## Using workflows as tools
|
|
140
105
|
|
|
@@ -169,16 +134,8 @@ import { z } from "zod";
|
|
|
169
134
|
export const researchWorkflow = createWorkflow({
|
|
170
135
|
id: "research-workflow",
|
|
171
136
|
description: "Gathers information on a topic and compiles a summary report.",
|
|
172
|
-
|
|
173
|
-
topic: z.string(),
|
|
174
|
-
}),
|
|
175
|
-
outputSchema: z.object({
|
|
176
|
-
summary: z.string(),
|
|
177
|
-
sources: z.array(z.string()),
|
|
178
|
-
}),
|
|
137
|
+
// Rest of the workflow...
|
|
179
138
|
})
|
|
180
|
-
.then(gatherSourcesStep)
|
|
181
|
-
.then(compileReportStep)
|
|
182
139
|
.commit();
|
|
183
140
|
```
|
|
184
141
|
|
|
@@ -191,6 +148,59 @@ When the agent calls the workflow tool, it receives a response containing the wo
|
|
|
191
148
|
}
|
|
192
149
|
```
|
|
193
150
|
|
|
151
|
+
See the [`toolName` docs](#subagents-and-workflows-as-tools) to learn more about the tool naming scheme.
|
|
152
|
+
|
|
153
|
+
## Controlling `toolName` in stream responses
|
|
154
|
+
|
|
155
|
+
The `toolName` in stream responses is determined by the **object key** you use, not the `id` property of the tool, agent, or workflow.
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
// Tool defined with id: "weather-tool"
|
|
159
|
+
export const weatherTool = createTool({
|
|
160
|
+
id: "weather-tool",
|
|
161
|
+
// ...
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// Using the variable name as the key
|
|
165
|
+
tools: { weatherTool }
|
|
166
|
+
// Stream returns: toolName: "weatherTool"
|
|
167
|
+
|
|
168
|
+
// Using the tool's id as the key
|
|
169
|
+
tools: { [weatherTool.id]: weatherTool }
|
|
170
|
+
// Stream returns: toolName: "weather-tool"
|
|
171
|
+
|
|
172
|
+
// Using a custom key
|
|
173
|
+
tools: { "my-custom-name": weatherTool }
|
|
174
|
+
// Stream returns: toolName: "my-custom-name"
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
This lets you specify how tools are identified in the stream. If you want the `toolName` to match the tool's `id`, use the tool's `id` as the object key.
|
|
178
|
+
|
|
179
|
+
### Subagents and workflows as tools
|
|
180
|
+
|
|
181
|
+
Subagents and workflows follow the same pattern. They are converted to tools with a prefix followed by your object key:
|
|
182
|
+
|
|
183
|
+
| Property | Prefix | Example key | `toolName` |
|
|
184
|
+
| ----------- | ----------- | ----------- | ------------------- |
|
|
185
|
+
| `agents` | `agent-` | `weather` | `agent-weather` |
|
|
186
|
+
| `workflows` | `workflow-` | `research` | `workflow-research` |
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
const orchestrator = new Agent({
|
|
190
|
+
agents: {
|
|
191
|
+
weather: weatherAgent, // toolName: "agent-weather"
|
|
192
|
+
},
|
|
193
|
+
workflows: {
|
|
194
|
+
research: researchWorkflow, // toolName: "workflow-research"
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Note that for subagents, you'll see two different identifiers in stream responses:
|
|
200
|
+
|
|
201
|
+
- `toolName: "agent-weather"` in tool call events — the generated tool wrapper name
|
|
202
|
+
- `id: "weather-agent"` in `data-tool-agent` chunks — the subagent's actual `id` property
|
|
203
|
+
|
|
194
204
|
## Tools with structured output
|
|
195
205
|
|
|
196
206
|
When using tools with [structured output](https://mastra.ai/docs/agents/structured-output), some models don't support combining both features in the same API call. If your tools aren't being called when structured output is enabled, or you receive errors about incompatible options, see [Combining tools and structured output](https://mastra.ai/docs/agents/structured-output) for model compatibility information and workarounds.
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
# Observational Memory
|
|
2
2
|
|
|
3
|
+
**Added in:** `@mastra/memory@1.1.0`
|
|
4
|
+
|
|
3
5
|
Observational Memory (OM) is Mastra's memory system for long-context agentic memory. Two background agents — an **Observer** and a **Reflector** — watch your agent's conversations and maintain a dense observation log that replaces raw message history as it grows.
|
|
4
6
|
|
|
5
7
|
## Quick Start
|
|
6
8
|
|
|
9
|
+
Enable `observationalMemory` in the memory options when creating your agent:
|
|
10
|
+
|
|
7
11
|
```typescript
|
|
8
12
|
import { Memory } from "@mastra/memory";
|
|
9
13
|
import { Agent } from "@mastra/core/agent";
|
|
@@ -20,11 +24,21 @@ export const agent = new Agent({
|
|
|
20
24
|
});
|
|
21
25
|
```
|
|
22
26
|
|
|
23
|
-
That's it. The agent now has humanlike long-term memory that persists across conversations.
|
|
27
|
+
That's it. The agent now has humanlike long-term memory that persists across conversations. Setting `observationalMemory: true` uses `google/gemini-2.5-flash` by default. To use a different model or customize thresholds, pass a config object instead:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
const memory = new Memory({
|
|
31
|
+
options: {
|
|
32
|
+
observationalMemory: {
|
|
33
|
+
model: "deepseek/deepseek-reasoner",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
```
|
|
24
38
|
|
|
25
39
|
See [configuration options](https://mastra.ai/reference/memory/observational-memory) for full API details.
|
|
26
40
|
|
|
27
|
-
> **Note:** OM currently only supports `@mastra/pg`, `@mastra/libsql`, and `@mastra/mongodb` storage adapters. It
|
|
41
|
+
> **Note:** OM currently only supports `@mastra/pg`, `@mastra/libsql`, and `@mastra/mongodb` storage adapters. It uses background agents for managing memory. When using `observationalMemory: true`, the default model is `google/gemini-2.5-flash`. When passing a config object, a `model` must be explicitly set.
|
|
28
42
|
|
|
29
43
|
## Benefits
|
|
30
44
|
|
|
@@ -65,15 +79,17 @@ When observations exceed their threshold (default: 40,000 tokens), the Reflector
|
|
|
65
79
|
|
|
66
80
|
The result is a three-tier system:
|
|
67
81
|
|
|
68
|
-
1. **Recent messages
|
|
69
|
-
2. **Observations
|
|
70
|
-
3. **Reflections
|
|
82
|
+
1. **Recent messages**: Exact conversation history for the current task
|
|
83
|
+
2. **Observations**: A log of what the Observer has seen
|
|
84
|
+
3. **Reflections**: Condensed observations when memory becomes too long
|
|
71
85
|
|
|
72
86
|
## Models
|
|
73
87
|
|
|
74
88
|
The Observer and Reflector run in the background. Any model that works with Mastra's model routing (e.g. `openai/...`, `google/...`, `deepseek/...`) can be used.
|
|
75
89
|
|
|
76
|
-
|
|
90
|
+
When using `observationalMemory: true`, the default model is `google/gemini-2.5-flash`. When passing a config object, a `model` must be explicitly set.
|
|
91
|
+
|
|
92
|
+
We recommend `google/gemini-2.5-flash` — it works well for both observation and reflection, and its 1M token context window gives the Reflector headroom.
|
|
77
93
|
|
|
78
94
|
We've also tested `deepseek`, `qwen3`, and `glm-4.7` for the Observer. For the Reflector, make sure the model's context window can fit all observations. Note that Claude 4.5 models currently don't work well as observer or reflector.
|
|
79
95
|
|
|
@@ -96,9 +112,14 @@ See [model configuration](https://mastra.ai/reference/memory/observational-memor
|
|
|
96
112
|
Each thread has its own observations.
|
|
97
113
|
|
|
98
114
|
```typescript
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
115
|
+
const memory = new Memory({
|
|
116
|
+
options: {
|
|
117
|
+
observationalMemory: {
|
|
118
|
+
model: "google/gemini-2.5-flash",
|
|
119
|
+
scope: "thread",
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
});
|
|
102
123
|
```
|
|
103
124
|
|
|
104
125
|
### Resource scope
|
|
@@ -106,9 +127,14 @@ observationalMemory: {
|
|
|
106
127
|
Observations are shared across all threads for a resource (typically a user). Enables cross-conversation memory.
|
|
107
128
|
|
|
108
129
|
```typescript
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
130
|
+
const memory = new Memory({
|
|
131
|
+
options: {
|
|
132
|
+
observationalMemory: {
|
|
133
|
+
model: "google/gemini-2.5-flash",
|
|
134
|
+
scope: "resource",
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
});
|
|
112
138
|
```
|
|
113
139
|
|
|
114
140
|
> **Warning:** In resource scope, unobserved messages across _all_ threads are processed together. For users with many existing threads, this can be slow. Use thread scope for existing apps.
|
|
@@ -121,6 +147,7 @@ OM uses token thresholds to decide when to observe and reflect. See [token budge
|
|
|
121
147
|
const memory = new Memory({
|
|
122
148
|
options: {
|
|
123
149
|
observationalMemory: {
|
|
150
|
+
model: "google/gemini-2.5-flash",
|
|
124
151
|
observation: {
|
|
125
152
|
// when to run the Observer (default: 30,000)
|
|
126
153
|
messageTokens: 30_000,
|
|
@@ -130,12 +157,58 @@ const memory = new Memory({
|
|
|
130
157
|
observationTokens: 40_000,
|
|
131
158
|
},
|
|
132
159
|
// let message history borrow from observation budget
|
|
160
|
+
// requires bufferTokens: false (temporary limitation)
|
|
133
161
|
shareTokenBudget: false,
|
|
134
162
|
},
|
|
135
163
|
},
|
|
136
164
|
});
|
|
137
165
|
```
|
|
138
166
|
|
|
167
|
+
## Async Buffering
|
|
168
|
+
|
|
169
|
+
Without async buffering, the Observer runs synchronously when the message threshold is reached — the agent pauses mid-conversation while the Observer LLM call completes. With async buffering (enabled by default), observations are pre-computed in the background as the conversation grows. When the threshold is hit, buffered observations activate instantly with no pause.
|
|
170
|
+
|
|
171
|
+
### How it works
|
|
172
|
+
|
|
173
|
+
As the agent converses, message tokens accumulate. At regular intervals (`bufferTokens`), a background Observer call runs without blocking the agent. Each call produces a "chunk" of observations that's stored in a buffer.
|
|
174
|
+
|
|
175
|
+
When message tokens reach the `messageTokens` threshold, buffered chunks activate: their observations move into the active observation log, and the corresponding raw messages are removed from the context window. The agent never pauses.
|
|
176
|
+
|
|
177
|
+
If the agent produces messages faster than the Observer can process them, a `blockAfter` safety threshold forces a synchronous observation as a last resort.
|
|
178
|
+
|
|
179
|
+
Reflection works similarly — the Reflector runs in the background when observations reach a fraction of the reflection threshold.
|
|
180
|
+
|
|
181
|
+
### Settings
|
|
182
|
+
|
|
183
|
+
| Setting | Default | What it controls |
|
|
184
|
+
| ------------------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
185
|
+
| `observation.bufferTokens` | `0.2` | How often to buffer. `0.2` means every 20% of `messageTokens` — with the default 30k threshold, that's roughly every 6k tokens. Can also be an absolute token count (e.g. `5000`). |
|
|
186
|
+
| `observation.bufferActivation` | `0.8` | How aggressively to clear the message window on activation. `0.8` means remove enough messages to keep only 20% of `messageTokens` remaining. Lower values keep more message history. |
|
|
187
|
+
| `observation.blockAfter` | `1.2` | Safety threshold as a multiplier of `messageTokens`. At `1.2`, synchronous observation is forced at 36k tokens (1.2 × 30k). Only matters if buffering can't keep up. |
|
|
188
|
+
| `reflection.bufferActivation` | `0.5` | When to start background reflection. `0.5` means reflection begins when observations reach 50% of the `observationTokens` threshold. |
|
|
189
|
+
| `reflection.blockAfter` | `1.2` | Safety threshold for reflection, same logic as observation. |
|
|
190
|
+
|
|
191
|
+
### Disabling
|
|
192
|
+
|
|
193
|
+
To disable async buffering and use synchronous observation/reflection instead:
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
const memory = new Memory({
|
|
197
|
+
options: {
|
|
198
|
+
observationalMemory: {
|
|
199
|
+
model: "google/gemini-2.5-flash",
|
|
200
|
+
observation: {
|
|
201
|
+
bufferTokens: false,
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Setting `bufferTokens: false` disables both observation and reflection async buffering. See [async buffering configuration](https://mastra.ai/reference/memory/observational-memory) for the full API.
|
|
209
|
+
|
|
210
|
+
> **Note:** Async buffering is not supported with `scope: 'resource'`. It is automatically disabled in resource scope.
|
|
211
|
+
|
|
139
212
|
## Migrating existing threads
|
|
140
213
|
|
|
141
214
|
No manual migration needed. OM reads existing messages and observes them lazily when thresholds are exceeded.
|
|
@@ -149,10 +222,9 @@ Mastra Studio shows OM status in real time in the memory tab: token usage, which
|
|
|
149
222
|
|
|
150
223
|
## Comparing OM with other memory features
|
|
151
224
|
|
|
152
|
-
- **[Message history](https://mastra.ai/docs/memory/message-history)
|
|
153
|
-
- **[Working memory](https://mastra.ai/docs/memory/working-memory)
|
|
154
|
-
- **[Semantic Recall](https://mastra.ai/docs/memory/semantic-recall)
|
|
155
|
-
- **Observational Memory** — long-context agentic memory that compresses extended sessions
|
|
225
|
+
- **[Message history](https://mastra.ai/docs/memory/message-history)**: High-fidelity record of the current conversation
|
|
226
|
+
- **[Working memory](https://mastra.ai/docs/memory/working-memory)**: Small, structured state (JSON or markdown) for user preferences, names, goals
|
|
227
|
+
- **[Semantic Recall](https://mastra.ai/docs/memory/semantic-recall)**: RAG-based retrieval of relevant past messages
|
|
156
228
|
|
|
157
229
|
If you're using working memory to store conversation summaries or ongoing state that grows over time, OM is a better fit. Working memory is for small, structured data; OM is for long-running event logs. OM also manages message history automatically—the `messageTokens` setting controls how much raw history remains before observation runs.
|
|
158
230
|
|
|
@@ -160,7 +232,7 @@ In practical terms, OM replaces both working memory and message history, and has
|
|
|
160
232
|
|
|
161
233
|
## Related
|
|
162
234
|
|
|
163
|
-
- [Observational Memory Reference](https://mastra.ai/reference/memory/observational-memory)
|
|
235
|
+
- [Observational Memory Reference](https://mastra.ai/reference/memory/observational-memory)
|
|
164
236
|
- [Memory Overview](https://mastra.ai/docs/memory/overview)
|
|
165
237
|
- [Message History](https://mastra.ai/docs/memory/message-history)
|
|
166
238
|
- [Memory Processors](https://mastra.ai/docs/memory/memory-processors)
|
|
@@ -57,7 +57,7 @@ export const mastra = new Mastra({
|
|
|
57
57
|
});
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
> **Serverless environments:** The `file:./mastra.db` storage URL uses the local filesystem, which doesn't work in serverless environments like Vercel, AWS Lambda, or Cloudflare Workers. For serverless deployments, use external storage. See the [Vercel deployment guide](https://mastra.ai/guides/deployment/vercel
|
|
60
|
+
> **Serverless environments:** The `file:./mastra.db` storage URL uses the local filesystem, which doesn't work in serverless environments like Vercel, AWS Lambda, or Cloudflare Workers. For serverless deployments, use external storage. See the [Vercel deployment guide](https://mastra.ai/guides/deployment/vercel) for a complete example.
|
|
61
61
|
|
|
62
62
|
With this basic setup, you will see Traces and Logs in both Studio and in Mastra Cloud.
|
|
63
63
|
|
|
@@ -126,6 +126,76 @@ new LangSmithExporter({
|
|
|
126
126
|
|
|
127
127
|
The `projectName` config option takes precedence over the `LANGCHAIN_PROJECT` environment variable, allowing you to programmatically route traces to different projects.
|
|
128
128
|
|
|
129
|
+
## Dynamic Configuration
|
|
130
|
+
|
|
131
|
+
You can dynamically override LangSmith settings per-span using `withLangsmithMetadata`. This is useful for routing traces to different projects based on runtime conditions (e.g., customer, environment, or feature).
|
|
132
|
+
|
|
133
|
+
### Using the Helper
|
|
134
|
+
|
|
135
|
+
Use `withLangsmithMetadata` with `buildTracingOptions` to set LangSmith-specific options:
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
import { Agent } from "@mastra/core/agent";
|
|
139
|
+
import { buildTracingOptions } from "@mastra/observability";
|
|
140
|
+
import { withLangsmithMetadata } from "@mastra/langsmith";
|
|
141
|
+
|
|
142
|
+
export const supportAgent = new Agent({
|
|
143
|
+
id: "support-agent",
|
|
144
|
+
name: "support-agent",
|
|
145
|
+
instructions: "You are a helpful support agent.",
|
|
146
|
+
model: "openai/gpt-4o",
|
|
147
|
+
defaultOptions: {
|
|
148
|
+
tracingOptions: buildTracingOptions(
|
|
149
|
+
withLangsmithMetadata({ projectName: "customer-support" }),
|
|
150
|
+
),
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Dynamic Project Routing
|
|
156
|
+
|
|
157
|
+
Use `requestContext` to route traces to different projects based on runtime conditions.
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import { Agent } from "@mastra/core/agent";
|
|
161
|
+
import { buildTracingOptions } from "@mastra/observability";
|
|
162
|
+
import { withLangsmithMetadata } from "@mastra/langsmith";
|
|
163
|
+
|
|
164
|
+
export const supportAgent = new Agent({
|
|
165
|
+
id: "support-agent",
|
|
166
|
+
name: "support-agent",
|
|
167
|
+
instructions: "You are a helpful support agent.",
|
|
168
|
+
model: "openai/gpt-4o",
|
|
169
|
+
defaultOptions: ({ requestContext }) => {
|
|
170
|
+
const userTier = requestContext?.get("user-tier") as string;
|
|
171
|
+
const userId = requestContext?.get("user-id") as string;
|
|
172
|
+
|
|
173
|
+
return {
|
|
174
|
+
tracingOptions: buildTracingOptions(
|
|
175
|
+
withLangsmithMetadata({
|
|
176
|
+
projectName: userTier === "enterprise"
|
|
177
|
+
? "enterprise-traces"
|
|
178
|
+
: "standard-traces",
|
|
179
|
+
sessionId: userId,
|
|
180
|
+
}),
|
|
181
|
+
),
|
|
182
|
+
};
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Available Fields
|
|
188
|
+
|
|
189
|
+
The `withLangsmithMetadata` helper accepts these fields:
|
|
190
|
+
|
|
191
|
+
| Field | Type | Description |
|
|
192
|
+
| ------------- | ------ | ----------------------------------- |
|
|
193
|
+
| `projectName` | string | Override the project for this trace |
|
|
194
|
+
| `sessionId` | string | Group related traces by session |
|
|
195
|
+
| `sessionName` | string | Display name for the session |
|
|
196
|
+
|
|
197
|
+
All fields are optional. The helper merges with any existing metadata, so you can call it multiple times or combine with other tracing options.
|
|
198
|
+
|
|
129
199
|
## Related
|
|
130
200
|
|
|
131
201
|
- [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
|
|
@@ -1023,7 +1023,7 @@ This creates a single distributed trace that includes both the HTTP request hand
|
|
|
1023
1023
|
|
|
1024
1024
|
In serverless environments like Vercel's fluid compute, AWS Lambda, or Cloudflare Workers, runtime instances can be reused across multiple requests. The `flush()` method allows you to ensure all buffered spans are exported before the runtime terminates, without shutting down the exporter (which would prevent future exports).
|
|
1025
1025
|
|
|
1026
|
-
> **Storage requirements:** Serverless environments have ephemeral filesystems. Use external storage instead of local file storage (`file:./mastra.db`). See the [Vercel deployment guide](https://mastra.ai/guides/deployment/vercel
|
|
1026
|
+
> **Storage requirements:** Serverless environments have ephemeral filesystems. Use external storage instead of local file storage (`file:./mastra.db`). See the [Vercel deployment guide](https://mastra.ai/guides/deployment/vercel) for a complete setup example.
|
|
1027
1027
|
|
|
1028
1028
|
### Using flush()
|
|
1029
1029
|
|
|
@@ -453,6 +453,23 @@ requestContextSchema: z.object({
|
|
|
453
453
|
|
|
454
454
|
**Handle tool validation errors**: Since tools return error objects instead of throwing, check for errors in your agent or workflow logic when tool execution is critical.
|
|
455
455
|
|
|
456
|
+
## Testing with Studio presets
|
|
457
|
+
|
|
458
|
+
When developing locally, you can define named presets in a JSON file and load them into Studio with the [`--request-context-presets`](https://mastra.ai/reference/cli/mastra) CLI flag. This adds a dropdown to the request context editor in Studio so you can quickly switch between configurations without manually editing JSON each time.
|
|
459
|
+
|
|
460
|
+
```bash
|
|
461
|
+
mastra dev --request-context-presets ./presets.json
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
```json
|
|
465
|
+
{
|
|
466
|
+
"development": { "userId": "dev-user", "env": "development" },
|
|
467
|
+
"production": { "userId": "prod-user", "env": "production" }
|
|
468
|
+
}
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
When you select a preset from the dropdown, the JSON editor populates with that preset's values. Editing the JSON manually switches the dropdown back to "Custom".
|
|
472
|
+
|
|
456
473
|
## Related
|
|
457
474
|
|
|
458
475
|
- [Agent Request Context](https://mastra.ai/docs/agents/overview)
|
|
@@ -57,7 +57,7 @@ export const testWorkflow = createWorkflow({
|
|
|
57
57
|
.commit();
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
> **Info:** Visit [Input Data Mapping](https://mastra.ai/docs/workflows/
|
|
60
|
+
> **Info:** Visit [Input Data Mapping](https://mastra.ai/docs/workflows/control-flow) for more information.
|
|
61
61
|
|
|
62
62
|
When no `structuredOutput` option is provided, Mastra agents use a default schema that expects a `prompt` string as input and returns a `text` string as output:
|
|
63
63
|
|
|
@@ -162,7 +162,7 @@ export const testWorkflow = createWorkflow({})
|
|
|
162
162
|
.commit();
|
|
163
163
|
```
|
|
164
164
|
|
|
165
|
-
> **Info:** Visit [Input Data Mapping](https://mastra.ai/docs/workflows/
|
|
165
|
+
> **Info:** Visit [Input Data Mapping](https://mastra.ai/docs/workflows/control-flow) for more information.
|
|
166
166
|
|
|
167
167
|
## Related
|
|
168
168
|
|
|
@@ -8,7 +8,7 @@ Workflows let you define complex sequences of tasks using clear, structured step
|
|
|
8
8
|
|
|
9
9
|
Use workflows for tasks that are clearly defined upfront and involve multiple steps with a specific execution order. They give you fine-grained control over how data flows and transforms between steps, and which primitives are called at each stage.
|
|
10
10
|
|
|
11
|
-
>
|
|
11
|
+
> **Watch an introduction:** An introduction to workflows, and how they compare to agents [YouTube (7 minutes)](https://youtu.be/0jg2g3sNvgw)
|
|
12
12
|
|
|
13
13
|
## Core principles
|
|
14
14
|
|