@mastra/core 1.0.0-beta.21 → 1.0.0-beta.22
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 +356 -0
- package/dist/action/index.d.ts +7 -7
- package/dist/action/index.d.ts.map +1 -1
- package/dist/agent/agent-legacy.d.ts.map +1 -1
- package/dist/agent/agent.d.ts +100 -18
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.types.d.ts +22 -18
- package/dist/agent/agent.types.d.ts.map +1 -1
- package/dist/agent/index.cjs +13 -13
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/adapters/AIV4Adapter.d.ts.map +1 -1
- 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 +2 -1
- package/dist/agent/message-list/message-list.d.ts.map +1 -1
- package/dist/agent/trip-wire.d.ts +1 -2
- package/dist/agent/trip-wire.d.ts.map +1 -1
- package/dist/agent/types.d.ts +9 -10
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/utils.d.ts +7 -42
- package/dist/agent/utils.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +6 -118
- package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts +7 -11
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts +4 -68
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts +3 -45
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/schema.d.ts +10 -10
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts +2 -8
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts.map +1 -1
- package/dist/{chunk-HJXEZSNI.js → chunk-3XY64RAM.js} +5 -5
- package/dist/{chunk-HJXEZSNI.js.map → chunk-3XY64RAM.js.map} +1 -1
- package/dist/{chunk-XSJNTLM7.js → chunk-453NPBJ7.js} +479 -47
- package/dist/chunk-453NPBJ7.js.map +1 -0
- package/dist/{chunk-3CZ42NBZ.js → chunk-5UVSKF5L.js} +17 -14
- package/dist/chunk-5UVSKF5L.js.map +1 -0
- package/dist/{chunk-XKDVT3ZH.cjs → chunk-67ZKOPA4.cjs} +480 -48
- package/dist/chunk-67ZKOPA4.cjs.map +1 -0
- package/dist/{chunk-YLP5IWH2.js → chunk-7IYWOBLG.js} +4 -4
- package/dist/{chunk-YLP5IWH2.js.map → chunk-7IYWOBLG.js.map} +1 -1
- package/dist/{chunk-3RCMDLCG.cjs → chunk-ALQFYWAR.cjs} +12 -12
- package/dist/{chunk-3RCMDLCG.cjs.map → chunk-ALQFYWAR.cjs.map} +1 -1
- package/dist/{chunk-PC3FBUWH.js → chunk-C4CIC3LZ.js} +2 -2
- package/dist/chunk-C4CIC3LZ.js.map +1 -0
- package/dist/{chunk-7JGQWNV5.js → chunk-CPLRD2VP.js} +3 -3
- package/dist/{chunk-7JGQWNV5.js.map → chunk-CPLRD2VP.js.map} +1 -1
- package/dist/{chunk-AHN7K3VE.js → chunk-CQ2E577C.js} +5 -5
- package/dist/chunk-CQ2E577C.js.map +1 -0
- package/dist/{chunk-A4MCHA5L.cjs → chunk-CVLIEFWM.cjs} +100 -819
- package/dist/chunk-CVLIEFWM.cjs.map +1 -0
- package/dist/{chunk-XBZWAUZ3.js → chunk-IFPQ2MLB.js} +25 -12
- package/dist/chunk-IFPQ2MLB.js.map +1 -0
- package/dist/{chunk-DVJZZAZA.cjs → chunk-IHD36QFA.cjs} +7 -7
- package/dist/{chunk-DVJZZAZA.cjs.map → chunk-IHD36QFA.cjs.map} +1 -1
- package/dist/{chunk-WMJEP45F.cjs → chunk-J4KVR4DZ.cjs} +25 -18
- package/dist/chunk-J4KVR4DZ.cjs.map +1 -0
- package/dist/{chunk-3RFSIHFR.js → chunk-K2LPTKSY.js} +4 -720
- package/dist/chunk-K2LPTKSY.js.map +1 -0
- package/dist/{chunk-FY3PYSMK.cjs → chunk-KHO4KFXW.cjs} +5 -5
- package/dist/{chunk-FY3PYSMK.cjs.map → chunk-KHO4KFXW.cjs.map} +1 -1
- package/dist/{chunk-W7R7GPNN.cjs → chunk-MGPIVG2O.cjs} +9 -9
- package/dist/chunk-MGPIVG2O.cjs.map +1 -0
- package/dist/{chunk-KGE3KAM7.js → chunk-N3PAHTKU.js} +23 -3
- package/dist/chunk-N3PAHTKU.js.map +1 -0
- package/dist/{chunk-O4H44CMA.js → chunk-N7TDP7ZE.js} +586 -117
- package/dist/chunk-N7TDP7ZE.js.map +1 -0
- package/dist/{chunk-I5GMA5UM.cjs → chunk-NPIYNC5A.cjs} +9 -9
- package/dist/{chunk-I5GMA5UM.cjs.map → chunk-NPIYNC5A.cjs.map} +1 -1
- package/dist/{chunk-AW7FISLD.cjs → chunk-OZ75PBBK.cjs} +27 -7
- package/dist/chunk-OZ75PBBK.cjs.map +1 -0
- package/dist/{chunk-JMAPJWVG.cjs → chunk-OZCUIZRA.cjs} +2021 -1426
- package/dist/chunk-OZCUIZRA.cjs.map +1 -0
- package/dist/{chunk-6OPEMI2Q.cjs → chunk-PM3UIIBK.cjs} +2 -3
- package/dist/{chunk-6OPEMI2Q.cjs.map → chunk-PM3UIIBK.cjs.map} +1 -1
- package/dist/{chunk-CISH55FP.js → chunk-PSIJ6OSV.js} +16 -9
- package/dist/chunk-PSIJ6OSV.js.map +1 -0
- package/dist/{chunk-UOZ3GJY2.cjs → chunk-PTK74KG4.cjs} +2 -2
- package/dist/chunk-PTK74KG4.cjs.map +1 -0
- package/dist/{chunk-O5IPTMEH.cjs → chunk-Q5QQDMSD.cjs} +32 -29
- package/dist/chunk-Q5QQDMSD.cjs.map +1 -0
- package/dist/{chunk-UVHSM2GU.cjs → chunk-SMM2C4KH.cjs} +6 -4
- package/dist/chunk-SMM2C4KH.cjs.map +1 -0
- package/dist/{chunk-UXLQEGIN.cjs → chunk-SVPXZEU7.cjs} +35 -22
- package/dist/chunk-SVPXZEU7.cjs.map +1 -0
- package/dist/{chunk-SOSXN7X4.cjs → chunk-TU6MNGBB.cjs} +619 -151
- package/dist/chunk-TU6MNGBB.cjs.map +1 -0
- package/dist/{chunk-EK7E4ETB.js → chunk-TX5GUG5Q.js} +3 -3
- package/dist/{chunk-EK7E4ETB.js.map → chunk-TX5GUG5Q.js.map} +1 -1
- package/dist/{chunk-SQ7T6FWC.cjs → chunk-UAH236P2.cjs} +13 -13
- package/dist/{chunk-SQ7T6FWC.cjs.map → chunk-UAH236P2.cjs.map} +1 -1
- package/dist/{chunk-AIJ6HPJG.js → chunk-UL7TJCKA.js} +4 -4
- package/dist/{chunk-AIJ6HPJG.js.map → chunk-UL7TJCKA.js.map} +1 -1
- package/dist/{chunk-IC2MIQBW.js → chunk-UVOQLIWL.js} +1922 -1326
- package/dist/chunk-UVOQLIWL.js.map +1 -0
- package/dist/{chunk-IMLORTHO.js → chunk-WANKWENG.js} +5 -5
- package/dist/{chunk-IMLORTHO.js.map → chunk-WANKWENG.js.map} +1 -1
- package/dist/{chunk-ICU4Z5MO.cjs → chunk-X7DR353F.cjs} +8 -8
- package/dist/{chunk-ICU4Z5MO.cjs.map → chunk-X7DR353F.cjs.map} +1 -1
- package/dist/{chunk-6TBWJV35.js → chunk-Y22QMA7S.js} +6 -4
- package/dist/chunk-Y22QMA7S.js.map +1 -0
- package/dist/{chunk-FT7DFPAL.js → chunk-YYNZEEOO.js} +5 -5
- package/dist/{chunk-FT7DFPAL.js.map → chunk-YYNZEEOO.js.map} +1 -1
- package/dist/di/index.cjs +4 -4
- package/dist/di/index.js +1 -1
- package/dist/docs/README.md +6 -5
- package/dist/docs/SKILL.md +6 -5
- package/dist/docs/SOURCE_MAP.json +288 -293
- package/dist/docs/agents/01-overview.md +2 -2
- package/dist/docs/agents/02-using-tools.md +5 -0
- package/dist/docs/agents/04-structured-output.md +24 -4
- package/dist/docs/agents/06-processors.md +65 -1
- package/dist/docs/agents/08-agent-approval.md +5 -6
- package/dist/docs/agents/09-network-approval.md +274 -0
- package/dist/docs/agents/{10-reference.md → 11-reference.md} +1 -1
- package/dist/docs/ai-sdk/01-reference.md +1 -1
- package/dist/docs/cli/01-reference.md +1 -1
- package/dist/docs/client-js/01-reference.md +10 -5
- package/dist/docs/configuration.mdx/01-reference.md +750 -0
- package/dist/docs/core/01-reference.md +9 -35
- package/dist/docs/deployer/01-reference.md +19 -6
- package/dist/docs/evals/01-overview.md +5 -5
- package/dist/docs/evals/02-custom-scorers.md +49 -6
- package/dist/docs/evals/04-reference.md +10 -4
- package/dist/docs/mcp/01-overview.md +26 -16
- package/dist/docs/mcp/02-publishing-mcp-server.md +2 -2
- package/dist/docs/memory/01-overview.md +2 -2
- package/dist/docs/memory/02-storage.md +59 -25
- package/dist/docs/memory/03-working-memory.md +10 -6
- package/dist/docs/memory/04-semantic-recall.md +2 -4
- package/dist/docs/memory/05-memory-processors.md +2 -3
- package/dist/docs/memory/06-reference.md +2 -4
- package/dist/docs/observability/01-overview.md +1 -1
- package/dist/docs/observability/02-logging.md +4 -5
- package/dist/docs/observability/03-overview.md +69 -13
- package/dist/docs/observability/09-datadog.md +169 -0
- package/dist/docs/observability/10-laminar.md +95 -0
- package/dist/docs/observability/{11-otel.md → 13-otel.md} +12 -7
- package/dist/docs/observability/{13-reference.md → 15-reference.md} +125 -1
- package/dist/docs/processors/01-reference.md +23 -0
- package/dist/docs/rag/01-overview.md +1 -1
- package/dist/docs/rag/02-chunking-and-embedding.md +0 -1
- package/dist/docs/rag/03-vector-databases.md +10 -5
- package/dist/docs/rag/04-retrieval.md +5 -6
- package/dist/docs/rag/06-reference.md +4 -5
- package/dist/docs/server/01-mastra-server.md +32 -49
- package/dist/docs/server/02-custom-adapters.md +5 -2
- package/dist/docs/server/04-request-context.md +50 -11
- package/dist/docs/server/05-custom-api-routes.md +1 -1
- package/dist/docs/server/06-mastra-client.md +2 -2
- package/dist/docs/storage/01-reference.md +99 -23
- package/dist/docs/streaming/04-reference.md +6 -1
- package/dist/docs/tools/01-reference.md +380 -25
- package/dist/docs/tools-mcp/01-mcp-overview.md +10 -2
- package/dist/docs/tools-mcp/02-overview.md +4 -4
- package/dist/docs/vectors/01-reference.md +24 -11
- package/dist/docs/voice/01-overview.md +2 -2
- package/dist/docs/voice/05-reference.md +2 -2
- package/dist/docs/workflows/01-overview.md +5 -5
- package/dist/docs/workflows/04-agents-and-tools.md +4 -6
- package/dist/docs/workflows/06-suspend-and-resume.md +5 -7
- package/dist/docs/workflows/11-reference.md +1 -91
- 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/scoreTraces/index.cjs +5 -5
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts +4 -67
- package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/integration/index.cjs +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +9 -9
- package/dist/llm/index.js +2 -2
- package/dist/llm/model/model.loop.d.ts +1 -2
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/model.loop.types.d.ts +1 -2
- package/dist/llm/model/model.loop.types.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +224 -18
- package/dist/loop/index.cjs +12 -12
- package/dist/loop/index.js +1 -1
- package/dist/loop/loop.d.ts +1 -2
- package/dist/loop/loop.d.ts.map +1 -1
- package/dist/loop/network/index.d.ts +21 -80
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/loop/network/run-command-tool.d.ts +14 -11
- package/dist/loop/network/run-command-tool.d.ts.map +1 -1
- package/dist/loop/network/validation.d.ts +3 -4
- package/dist/loop/network/validation.d.ts.map +1 -1
- package/dist/loop/test-utils/options.d.ts.map +1 -1
- package/dist/loop/types.d.ts +4 -5
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +31 -804
- package/dist/loop/workflows/agentic-execution/index.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +22 -539
- 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 +13 -294
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts +2 -41
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +32 -805
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
- package/dist/loop/workflows/schema.d.ts +90 -91
- package/dist/loop/workflows/schema.d.ts.map +1 -1
- package/dist/loop/workflows/stream.d.ts +1 -2
- package/dist/loop/workflows/stream.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +28 -9
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +11 -11
- package/dist/memory/index.js +1 -1
- package/dist/memory/memory.d.ts +4 -2
- package/dist/memory/memory.d.ts.map +1 -1
- package/dist/observability/index.cjs +11 -11
- package/dist/observability/index.js +1 -1
- package/dist/observability/types/tracing.d.ts +45 -7
- package/dist/observability/types/tracing.d.ts.map +1 -1
- package/dist/processors/index.cjs +38 -38
- package/dist/processors/index.d.ts +3 -3
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/memory/semantic-recall.d.ts +2 -0
- package/dist/processors/memory/semantic-recall.d.ts.map +1 -1
- package/dist/processors/processors/structured-output.d.ts +2 -2
- package/dist/processors/processors/structured-output.d.ts.map +1 -1
- package/dist/processors/processors/token-limiter.d.ts +16 -10
- package/dist/processors/processors/token-limiter.d.ts.map +1 -1
- package/dist/processors/runner.d.ts +4 -4
- package/dist/processors/runner.d.ts.map +1 -1
- package/dist/processors/step-schema.d.ts +66 -67
- package/dist/processors/step-schema.d.ts.map +1 -1
- package/dist/provider-registry-C3IAGLLU.js +3 -0
- package/dist/{provider-registry-6DWM3X3I.js.map → provider-registry-C3IAGLLU.js.map} +1 -1
- package/dist/provider-registry-YH4FCTT2.cjs +40 -0
- package/dist/{provider-registry-DCECMUCQ.cjs.map → provider-registry-YH4FCTT2.cjs.map} +1 -1
- package/dist/provider-registry.json +477 -45
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/request-context/index.cjs +4 -4
- package/dist/request-context/index.d.ts +10 -9
- package/dist/request-context/index.d.ts.map +1 -1
- package/dist/request-context/index.js +1 -1
- package/dist/server/types.d.ts +1 -1
- package/dist/storage/constants.cjs +14 -14
- package/dist/storage/constants.d.ts +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/observability/types.d.ts +90 -90
- package/dist/storage/domains/workflows/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +93 -93
- package/dist/storage/index.js +2 -2
- package/dist/stream/MastraAgentNetworkStream.d.ts +8 -12
- package/dist/stream/MastraAgentNetworkStream.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/execute.d.ts +2 -3
- package/dist/stream/aisdk/v5/execute.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/transform.d.ts +2 -3
- package/dist/stream/aisdk/v5/transform.d.ts.map +1 -1
- package/dist/stream/base/output-format-handlers.d.ts +2 -2
- package/dist/stream/base/output-format-handlers.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts +76 -50
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/base/schema.d.ts +7 -2
- package/dist/stream/base/schema.d.ts.map +1 -1
- package/dist/stream/index.cjs +11 -15
- package/dist/stream/index.d.ts +2 -2
- package/dist/stream/index.d.ts.map +1 -1
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +72 -26
- package/dist/stream/types.d.ts.map +1 -1
- 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.d.ts +1 -1
- package/dist/tool-loop-agent/index.d.ts.map +1 -1
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/tool-loop-agent/tool-loop-processor.d.ts +1 -2
- package/dist/tool-loop-agent/tool-loop-processor.d.ts.map +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/tool.d.ts +27 -14
- package/dist/tools/tool.d.ts.map +1 -1
- package/dist/tools/types.d.ts +76 -20
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/ui-types.d.ts +3 -4
- package/dist/tools/ui-types.d.ts.map +1 -1
- package/dist/tools/validation.d.ts +4 -4
- package/dist/tools/validation.d.ts.map +1 -1
- package/dist/types/dynamic-argument.d.ts +61 -1
- package/dist/types/dynamic-argument.d.ts.map +1 -1
- package/dist/types/zod-compat.d.ts +3 -11
- package/dist/types/zod-compat.d.ts.map +1 -1
- package/dist/utils.cjs +22 -22
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.js +1 -1
- package/dist/voice/index.cjs +6 -6
- package/dist/voice/index.js +1 -1
- package/dist/workflows/default.d.ts +114 -2
- package/dist/workflows/default.d.ts.map +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 +1 -1
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/utils.d.ts +1 -1
- package/dist/workflows/evented/workflow.d.ts +74 -21
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/handlers/control-flow.d.ts +2 -2
- package/dist/workflows/handlers/control-flow.d.ts.map +1 -1
- package/dist/workflows/handlers/sleep.d.ts.map +1 -1
- package/dist/workflows/handlers/step.d.ts +1 -1
- package/dist/workflows/handlers/step.d.ts.map +1 -1
- package/dist/workflows/index.cjs +23 -23
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/step.d.ts +28 -24
- package/dist/workflows/step.d.ts.map +1 -1
- package/dist/workflows/types.d.ts +91 -54
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +165 -118
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/llm/model/provider-types.generated.d.ts +224 -18
- package/dist/chunk-3CZ42NBZ.js.map +0 -1
- package/dist/chunk-3RFSIHFR.js.map +0 -1
- package/dist/chunk-6TBWJV35.js.map +0 -1
- package/dist/chunk-A4MCHA5L.cjs.map +0 -1
- package/dist/chunk-AHN7K3VE.js.map +0 -1
- package/dist/chunk-AW7FISLD.cjs.map +0 -1
- package/dist/chunk-CISH55FP.js.map +0 -1
- package/dist/chunk-IC2MIQBW.js.map +0 -1
- package/dist/chunk-JMAPJWVG.cjs.map +0 -1
- package/dist/chunk-KGE3KAM7.js.map +0 -1
- package/dist/chunk-O4H44CMA.js.map +0 -1
- package/dist/chunk-O5IPTMEH.cjs.map +0 -1
- package/dist/chunk-PC3FBUWH.js.map +0 -1
- package/dist/chunk-SOSXN7X4.cjs.map +0 -1
- package/dist/chunk-UOZ3GJY2.cjs.map +0 -1
- package/dist/chunk-UVHSM2GU.cjs.map +0 -1
- package/dist/chunk-UXLQEGIN.cjs.map +0 -1
- package/dist/chunk-W7R7GPNN.cjs.map +0 -1
- package/dist/chunk-WMJEP45F.cjs.map +0 -1
- package/dist/chunk-XBZWAUZ3.js.map +0 -1
- package/dist/chunk-XKDVT3ZH.cjs.map +0 -1
- package/dist/chunk-XSJNTLM7.js.map +0 -1
- package/dist/provider-registry-6DWM3X3I.js +0 -3
- package/dist/provider-registry-DCECMUCQ.cjs +0 -40
- package/dist/stream/aisdk/v5/output.d.ts +0 -121
- package/dist/stream/aisdk/v5/output.d.ts.map +0 -1
- /package/dist/docs/agents/{09-adding-voice.md → 10-adding-voice.md} +0 -0
- /package/dist/docs/observability/{09-langfuse.md → 11-langfuse.md} +0 -0
- /package/dist/docs/observability/{10-langsmith.md → 12-langsmith.md} +0 -0
- /package/dist/docs/observability/{12-posthog.md → 14-posthog.md} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
> Overview of agents in Mastra, detailing their capabilities and how they interact with tools, workflows, and external systems.
|
|
2
2
|
|
|
3
3
|
> **Code References:**
|
|
4
|
-
- `Agent`: dist/agent/agent.d.ts → dist/chunk-
|
|
5
|
-
- `Mastra`: dist/mastra/index.d.ts → dist/chunk-
|
|
4
|
+
- `Agent`: dist/agent/agent.d.ts → dist/chunk-UVOQLIWL.js:16630
|
|
5
|
+
- `Mastra`: dist/mastra/index.d.ts → dist/chunk-IFPQ2MLB.js:24
|
|
6
6
|
|
|
7
7
|
# Using Agents
|
|
8
8
|
|
|
@@ -141,8 +141,13 @@ When the agent calls the workflow tool, it receives a response containing the wo
|
|
|
141
141
|
}
|
|
142
142
|
```
|
|
143
143
|
|
|
144
|
+
## Tools with structured output
|
|
145
|
+
|
|
146
|
+
When using tools with [structured output](https://mastra.ai/docs/v1/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/v1/agents/structured-output#combining-tools-and-structured-output) for model compatibility information and workarounds.
|
|
147
|
+
|
|
144
148
|
## Related
|
|
145
149
|
|
|
146
150
|
- [MCP Overview](https://mastra.ai/docs/v1/mcp/overview)
|
|
151
|
+
- [Structured Output](https://mastra.ai/docs/v1/agents/structured-output)
|
|
147
152
|
- [Agent Memory](https://mastra.ai/docs/v1/agents/agent-memory)
|
|
148
153
|
- [Request Context](https://mastra.ai/docs/v1/server/request-context)
|
|
@@ -65,7 +65,7 @@ console.log(response.object);
|
|
|
65
65
|
|
|
66
66
|
> **Note:**
|
|
67
67
|
|
|
68
|
-
Visit [.generate()](https://mastra.ai/reference/v1/agents/generate
|
|
68
|
+
Visit [.generate()](https://mastra.ai/reference/v1/agents/generate) for a full list of configuration options.
|
|
69
69
|
|
|
70
70
|
### Example output
|
|
71
71
|
|
|
@@ -149,9 +149,25 @@ const response = await testAgent.generate("Analyze the TypeScript programming la
|
|
|
149
149
|
console.log(response.object);
|
|
150
150
|
```
|
|
151
151
|
|
|
152
|
-
##
|
|
152
|
+
## Combining tools and structured output
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
When an agent has both tools and structured output configured, some models may not support using both features together. This is a limitation of the underlying model APIs, not Mastra itself.
|
|
155
|
+
|
|
156
|
+
If your tools aren't being called when structured output is enabled, or you receive an error when combining both features, try one of the workarounds below.
|
|
157
|
+
|
|
158
|
+
### Workaround options
|
|
159
|
+
|
|
160
|
+
When your model doesn't support tools and structured output together, you have three options:
|
|
161
|
+
|
|
162
|
+
1. **Use `jsonPromptInjection: true`** - Injects the schema into the prompt instead of using the API's `response_format` parameter
|
|
163
|
+
2. **Use a separate structuring model** - Pass a `model` to `structuredOutput` to use a second LLM for structuring
|
|
164
|
+
3. **Use `prepareStep`** - Handle tools and structured output in separate steps
|
|
165
|
+
|
|
166
|
+
Each approach is detailed in the sections below.
|
|
167
|
+
|
|
168
|
+
## LLM structured output support
|
|
169
|
+
|
|
170
|
+
Structured output support varies across LLMs due to differences in their APIs. The sections below cover workarounds for models that don't fully support structured output or combining it with tools.
|
|
155
171
|
|
|
156
172
|
### `jsonPromptInjection`
|
|
157
173
|
|
|
@@ -179,7 +195,11 @@ console.log(response.object);
|
|
|
179
195
|
|
|
180
196
|
> **Gemini 2.5 with tools**
|
|
181
197
|
|
|
182
|
-
Gemini 2.5 models do not support combining `response_format` (structured output) with function calling (tools) in the same API call. If your agent has tools and you're using `structuredOutput` with a Gemini 2.5 model, you must set `jsonPromptInjection: true` to avoid the error
|
|
198
|
+
Gemini 2.5 models do not support combining `response_format` (structured output) with function calling (tools) in the same API call. If your agent has tools and you're using `structuredOutput` with a Gemini 2.5 model, you must set `jsonPromptInjection: true` to avoid the error:
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
Function calling with a response mime type: 'application/json' is unsupported
|
|
202
|
+
```
|
|
183
203
|
|
|
184
204
|
```typescript
|
|
185
205
|
const response = await agentWithTools.generate("Your prompt", {
|
|
@@ -277,6 +277,70 @@ export class CustomOutputProcessor implements Processor {
|
|
|
277
277
|
}
|
|
278
278
|
```
|
|
279
279
|
|
|
280
|
+
#### Adding metadata in output processors
|
|
281
|
+
|
|
282
|
+
You can add custom metadata to messages in `processOutputResult`. This metadata is accessible via the response object:
|
|
283
|
+
|
|
284
|
+
```typescript title="src/mastra/processors/metadata-processor.ts"
|
|
285
|
+
import type { Processor, MastraDBMessage } from "@mastra/core";
|
|
286
|
+
|
|
287
|
+
export class MetadataProcessor implements Processor {
|
|
288
|
+
id = "metadata-processor";
|
|
289
|
+
|
|
290
|
+
async processOutputResult({
|
|
291
|
+
messages,
|
|
292
|
+
}: {
|
|
293
|
+
messages: MastraDBMessage[];
|
|
294
|
+
}): Promise<MastraDBMessage[]> {
|
|
295
|
+
return messages.map((msg) => {
|
|
296
|
+
if (msg.role === "assistant") {
|
|
297
|
+
return {
|
|
298
|
+
...msg,
|
|
299
|
+
content: {
|
|
300
|
+
...msg.content,
|
|
301
|
+
metadata: {
|
|
302
|
+
...msg.content.metadata,
|
|
303
|
+
processedAt: new Date().toISOString(),
|
|
304
|
+
customData: "your data here",
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
return msg;
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Access the metadata with `generate()`:
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
const result = await agent.generate("Hello");
|
|
319
|
+
|
|
320
|
+
// The response includes uiMessages with processor-added metadata
|
|
321
|
+
const assistantMessage = result.response?.uiMessages?.find((m) => m.role === "assistant");
|
|
322
|
+
console.log(assistantMessage?.metadata?.customData);
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
Access the metadata when streaming:
|
|
326
|
+
|
|
327
|
+
```typescript
|
|
328
|
+
const stream = await agent.stream("Hello");
|
|
329
|
+
|
|
330
|
+
for await (const chunk of stream.fullStream) {
|
|
331
|
+
if (chunk.type === "finish") {
|
|
332
|
+
// Access response with processor-added metadata from the finish chunk
|
|
333
|
+
const uiMessages = chunk.payload.response?.uiMessages;
|
|
334
|
+
const assistantMessage = uiMessages?.find((m) => m.role === "assistant");
|
|
335
|
+
console.log(assistantMessage?.metadata?.customData);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Or via the response promise after consuming the stream
|
|
340
|
+
const response = await stream.response;
|
|
341
|
+
console.log(response.uiMessages);
|
|
342
|
+
```
|
|
343
|
+
|
|
280
344
|
## Built-in Utility Processors
|
|
281
345
|
|
|
282
346
|
Mastra provides utility processors for common tasks:
|
|
@@ -377,7 +441,7 @@ const agent = new Agent({
|
|
|
377
441
|
});
|
|
378
442
|
```
|
|
379
443
|
|
|
380
|
-
When an agent is registered with Mastra, processor workflows are automatically registered as workflows, allowing you to view and debug them in the
|
|
444
|
+
When an agent is registered with Mastra, processor workflows are automatically registered as workflows, allowing you to view and debug them in the [Studio](https://mastra.ai/docs/v1/getting-started/studio).
|
|
381
445
|
|
|
382
446
|
## Retry mechanism
|
|
383
447
|
|
|
@@ -85,8 +85,8 @@ export const testTool = createTool({
|
|
|
85
85
|
resumeSchema: z.object({
|
|
86
86
|
approved: z.boolean()
|
|
87
87
|
}),
|
|
88
|
-
execute: async (
|
|
89
|
-
const response = await fetch(`https://wttr.in/${location}?format=3`);
|
|
88
|
+
execute: async (inputData) => {
|
|
89
|
+
const response = await fetch(`https://wttr.in/${inputData.location}?format=3`);
|
|
90
90
|
const weather = await response.text();
|
|
91
91
|
|
|
92
92
|
return { weather };
|
|
@@ -121,7 +121,6 @@ const handleResume = async () => {
|
|
|
121
121
|
With this approach, neither the agent nor the tool uses `requireApproval`. Instead, the tool implementation calls `suspend` to pause execution and return context or confirmation prompts to the user.
|
|
122
122
|
|
|
123
123
|
```typescript
|
|
124
|
-
|
|
125
124
|
export const testToolB = createTool({
|
|
126
125
|
id: "test-tool-b",
|
|
127
126
|
description: "Fetches weather for a location",
|
|
@@ -137,14 +136,14 @@ export const testToolB = createTool({
|
|
|
137
136
|
suspendSchema: z.object({
|
|
138
137
|
reason: z.string()
|
|
139
138
|
}),
|
|
140
|
-
execute: async (
|
|
141
|
-
const { resumeData: { approved } = {}, suspend } = agent ?? {};
|
|
139
|
+
execute: async (inputData, context) => {
|
|
140
|
+
const { resumeData: { approved } = {}, suspend } = context?.agent ?? {};
|
|
142
141
|
|
|
143
142
|
if (!approved) {
|
|
144
143
|
return suspend?.({ reason: "Approval required." });
|
|
145
144
|
}
|
|
146
145
|
|
|
147
|
-
const response = await fetch(`https://wttr.in/${location}?format=3`);
|
|
146
|
+
const response = await fetch(`https://wttr.in/${inputData.location}?format=3`);
|
|
148
147
|
const weather = await response.text();
|
|
149
148
|
|
|
150
149
|
return { weather };
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
> Learn how to require approvals, suspend execution, and resume suspended networks while keeping humans in control of agent network workflows.
|
|
2
|
+
|
|
3
|
+
# Network Approval
|
|
4
|
+
|
|
5
|
+
Agent networks can require the same [human-in-the-loop](https://mastra.ai/docs/v1/workflows/human-in-the-loop) oversight used in individual agents and workflows. When a tool, sub-agent, 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.
|
|
6
|
+
|
|
7
|
+
## Storage
|
|
8
|
+
|
|
9
|
+
Network approval uses snapshots to capture execution state. Ensure you've enabled a storage provider in your Mastra instance. If storage isn't enabled you'll see an error relating to snapshot not found.
|
|
10
|
+
|
|
11
|
+
```typescript title="src/mastra/index.ts"
|
|
12
|
+
import { Mastra } from "@mastra/core/mastra";
|
|
13
|
+
import { LibSQLStore } from "@mastra/libsql";
|
|
14
|
+
|
|
15
|
+
export const mastra = new Mastra({
|
|
16
|
+
storage: new LibSQLStore({
|
|
17
|
+
id: "mastra-storage",
|
|
18
|
+
url: ":memory:"
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Approving network tool calls
|
|
24
|
+
|
|
25
|
+
When a tool within a network has `requireApproval: true`, the network stream emits an `agent-execution-approval` chunk and pauses. To allow the tool to execute, call `approveNetworkToolCall` with the `runId`.
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
const stream = await routingAgent.network("Process this query", {
|
|
29
|
+
memory: {
|
|
30
|
+
thread: "user-123",
|
|
31
|
+
resource: "my-app"
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
let runId: string;
|
|
36
|
+
|
|
37
|
+
for await (const chunk of stream) {
|
|
38
|
+
runId = stream.runId;
|
|
39
|
+
// if the requirApproval is in a tool inside a subAgent or the subAgent has requireToolApproval set to true
|
|
40
|
+
if (chunk.type === "agent-execution-approval") {
|
|
41
|
+
console.log("Tool requires approval:", chunk.payload);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// if the requirApproval is in a tool directly in the network agent
|
|
45
|
+
if (chunk.type === "tool-execution-approval") {
|
|
46
|
+
console.log("Tool requires approval:", chunk.payload);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Approve and resume execution
|
|
51
|
+
const approvedStream = await routingAgent.approveNetworkToolCall({
|
|
52
|
+
runId,
|
|
53
|
+
memory: {
|
|
54
|
+
thread: "user-123",
|
|
55
|
+
resource: "my-app"
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
for await (const chunk of approvedStream) {
|
|
60
|
+
if (chunk.type === "network-execution-event-step-finish") {
|
|
61
|
+
console.log(chunk.payload.result);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Declining network tool calls
|
|
67
|
+
|
|
68
|
+
To decline a pending tool call and prevent execution, call `declineNetworkToolCall`. The network continues without executing the tool.
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
const declinedStream = await routingAgent.declineNetworkToolCall({
|
|
72
|
+
runId,
|
|
73
|
+
memory: {
|
|
74
|
+
thread: "user-123",
|
|
75
|
+
resource: "my-app"
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
for await (const chunk of declinedStream) {
|
|
80
|
+
if (chunk.type === "network-execution-event-step-finish") {
|
|
81
|
+
console.log(chunk.payload.result);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Resuming suspended networks
|
|
87
|
+
|
|
88
|
+
When a primitive in the network calls `suspend()`, the stream emits an `agent-execution-suspended`/`tool-execution-suspended`/`workflow-execution-suspended` chunk with a `suspendPayload` containing context from the primitive. Use `resumeNetwork` to provide the data requested by the primitive and continue execution.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import { createTool } from "@mastra/core/tools";
|
|
92
|
+
import { z } from "zod";
|
|
93
|
+
|
|
94
|
+
const confirmationTool = createTool({
|
|
95
|
+
id: "confirmation-tool",
|
|
96
|
+
description: "Requests user confirmation before proceeding",
|
|
97
|
+
inputSchema: z.object({
|
|
98
|
+
action: z.string()
|
|
99
|
+
}),
|
|
100
|
+
outputSchema: z.object({
|
|
101
|
+
confirmed: z.boolean(),
|
|
102
|
+
action: z.string()
|
|
103
|
+
}),
|
|
104
|
+
suspendSchema: z.object({
|
|
105
|
+
message: z.string(),
|
|
106
|
+
action: z.string()
|
|
107
|
+
}),
|
|
108
|
+
resumeSchema: z.object({
|
|
109
|
+
confirmed: z.boolean()
|
|
110
|
+
}),
|
|
111
|
+
execute: async (inputData, context) => {
|
|
112
|
+
const { resumeData, suspend } = context?.agent ?? {};
|
|
113
|
+
|
|
114
|
+
if (!resumeData?.confirmed) {
|
|
115
|
+
return suspend?.({
|
|
116
|
+
message: `Please confirm: ${inputData.action}`,
|
|
117
|
+
action: inputData.action
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return { confirmed: true, action: inputData.action };
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Handle the suspension and resume with user-provided data:
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
const stream = await routingAgent.network("Delete the old records", {
|
|
130
|
+
memory: {
|
|
131
|
+
thread: "user-123",
|
|
132
|
+
resource: "my-app"
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
for await (const chunk of stream) {
|
|
137
|
+
if (chunk.type === "workflow-execution-suspended") {
|
|
138
|
+
console.log(chunk.payload.suspendPayload);
|
|
139
|
+
// { message: "Please confirm: delete old records", action: "delete old records" }
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Resume with user confirmation
|
|
144
|
+
const resumedStream = await routingAgent.resumeNetwork(
|
|
145
|
+
{ confirmed: true },
|
|
146
|
+
{
|
|
147
|
+
runId: stream.runId,
|
|
148
|
+
memory: {
|
|
149
|
+
thread: "user-123",
|
|
150
|
+
resource: "my-app"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
for await (const chunk of resumedStream) {
|
|
156
|
+
if (chunk.type === "network-execution-event-step-finish") {
|
|
157
|
+
console.log(chunk.payload.result);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Automatic primitive resumption
|
|
163
|
+
|
|
164
|
+
When using primitives that call `suspend()`, you can enable automatic resumption so the network resumes suspended primitives based on the user's next message. This creates a conversational flow where users provide the required information naturally.
|
|
165
|
+
|
|
166
|
+
### Enabling auto-resume
|
|
167
|
+
|
|
168
|
+
Set `autoResumeSuspendedTools` to `true` in the agent's `defaultNetworkOptions` or when calling `network()`:
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
import { Agent } from "@mastra/core/agent";
|
|
172
|
+
import { Memory } from "@mastra/memory";
|
|
173
|
+
|
|
174
|
+
// Option 1: In agent configuration
|
|
175
|
+
const routingAgent = new Agent({
|
|
176
|
+
id: "routing-agent",
|
|
177
|
+
name: "Routing Agent",
|
|
178
|
+
instructions: "You coordinate tasks across multiple agents",
|
|
179
|
+
model: "openai/gpt-4o-mini",
|
|
180
|
+
tools: { confirmationTool },
|
|
181
|
+
memory: new Memory(),
|
|
182
|
+
defaultNetworkOptions: {
|
|
183
|
+
autoResumeSuspendedTools: true,
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// Option 2: Per-request
|
|
188
|
+
const stream = await routingAgent.network("Process this request", {
|
|
189
|
+
autoResumeSuspendedTools: true,
|
|
190
|
+
memory: {
|
|
191
|
+
thread: "user-123",
|
|
192
|
+
resource: "my-app"
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### How it works
|
|
198
|
+
|
|
199
|
+
When `autoResumeSuspendedTools` is enabled:
|
|
200
|
+
|
|
201
|
+
1. A primitive suspends execution by calling `suspend()` with a payload
|
|
202
|
+
2. The suspension is persisted to memory along with the conversation
|
|
203
|
+
3. When the user sends their next message on the same thread, the network:
|
|
204
|
+
- Detects the suspended primitive from message history
|
|
205
|
+
- Extracts `resumeData` from the user's message based on the tool's `resumeSchema`
|
|
206
|
+
- Automatically resumes the primitive with the extracted data
|
|
207
|
+
|
|
208
|
+
### Example
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
const stream = await routingAgent.network("Delete the old records", {
|
|
212
|
+
autoResumeSuspendedTools: true,
|
|
213
|
+
memory: {
|
|
214
|
+
thread: "user-123",
|
|
215
|
+
resource: "my-app"
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
for await (const chunk of stream) {
|
|
220
|
+
if (chunk.type === "workflow-execution-suspended") {
|
|
221
|
+
console.log(chunk.payload.suspendPayload);
|
|
222
|
+
// { message: "Please confirm: delete old records", action: "delete old records" }
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// User provides confirmation in their next message
|
|
227
|
+
const resumedStream = await routingAgent.network("Yes, confirmed", {
|
|
228
|
+
autoResumeSuspendedTools: true,
|
|
229
|
+
memory: {
|
|
230
|
+
thread: "user-123",
|
|
231
|
+
resource: "my-app"
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
for await (const chunk of resumedStream) {
|
|
236
|
+
if (chunk.type === "network-execution-event-step-finish") {
|
|
237
|
+
console.log(chunk.payload.result);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
**Conversation flow:**
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
User: "Delete the old records"
|
|
246
|
+
Agent: "Please confirm: delete old records"
|
|
247
|
+
|
|
248
|
+
User: "Yes, confirmed"
|
|
249
|
+
Agent: "Records deleted successfully"
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Requirements
|
|
253
|
+
|
|
254
|
+
For automatic tool resumption to work:
|
|
255
|
+
|
|
256
|
+
- **Memory configured**: The agent needs memory to track suspended tools across messages
|
|
257
|
+
- **Same thread**: The follow-up message must use the same memory thread and resource identifiers
|
|
258
|
+
- **`resumeSchema` defined**: The tool (either directly in the network agent or in a subAgent) / workflow (step that gets suspended) must define a `resumeSchema` so the agent knows what data to extract from the user's message
|
|
259
|
+
|
|
260
|
+
### Manual vs automatic resumption
|
|
261
|
+
|
|
262
|
+
| Approach | Use case |
|
|
263
|
+
|----------|----------|
|
|
264
|
+
| Manual (`resumeNetwork()`) | Programmatic control, webhooks, button clicks, external triggers |
|
|
265
|
+
| Automatic (`autoResumeSuspendedTools`) | Conversational flows where users provide resume data in natural language |
|
|
266
|
+
|
|
267
|
+
Both approaches work with the same tool definitions. Automatic resumption triggers only when suspended tools exist in the message history and the user sends a new message on the same thread.
|
|
268
|
+
|
|
269
|
+
## Related
|
|
270
|
+
|
|
271
|
+
- [Agent Networks](./networks)
|
|
272
|
+
- [Agent Approval](./agent-approval)
|
|
273
|
+
- [Human-in-the-Loop](https://mastra.ai/docs/v1/workflows/human-in-the-loop)
|
|
274
|
+
- [Agent Memory](./agent-memory)
|
|
@@ -189,7 +189,7 @@ await agent.generateLegacy("message for agent");
|
|
|
189
189
|
|
|
190
190
|
> **Note:**
|
|
191
191
|
|
|
192
|
-
The new `.generate()` method offers enhanced capabilities including AI SDK v5 compatibility, better structured output handling, and improved streaming support. See the [migration guide](https://mastra.ai/guides/v1/migrations/vnext-to-standard-apis) for detailed migration instructions.
|
|
192
|
+
The new `.generate()` method offers enhanced capabilities including AI SDK v5+ compatibility, better structured output handling, and improved streaming support. See the [migration guide](https://mastra.ai/guides/v1/migrations/vnext-to-standard-apis) for detailed migration instructions.
|
|
193
193
|
|
|
194
194
|
### Quick Migration Example
|
|
195
195
|
|
|
@@ -423,7 +423,7 @@ Use [`handleWorkflowStream()`](https://mastra.ai/reference/v1/ai-sdk/handle-work
|
|
|
423
423
|
|
|
424
424
|
When a workflow step pipes an agent's stream to the workflow writer (e.g., `await response.fullStream.pipeTo(writer)`), the agent's text chunks and tool calls are forwarded to the UI stream in real time, even when the agent runs inside workflow steps.
|
|
425
425
|
|
|
426
|
-
See [Workflow Streaming](https://mastra.ai/docs/v1/streaming/workflow-streaming
|
|
426
|
+
See [Workflow Streaming](https://mastra.ai/docs/v1/streaming/workflow-streaming) for more details.
|
|
427
427
|
|
|
428
428
|
## Usage example
|
|
429
429
|
|
|
@@ -23,7 +23,7 @@ The command accepts [common flags][common-flags] and the following additional fl
|
|
|
23
23
|
|
|
24
24
|
#### `--https`
|
|
25
25
|
|
|
26
|
-
Enable local HTTPS support. [Learn more](https://mastra.ai/
|
|
26
|
+
Enable local HTTPS support. [Learn more](https://mastra.ai/reference/v1/configuration#serverhttps).
|
|
27
27
|
|
|
28
28
|
#### `--inspect`
|
|
29
29
|
|
|
@@ -67,12 +67,14 @@ const response = await agent.generate(
|
|
|
67
67
|
);
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
You can also use the simplified string format:
|
|
70
|
+
You can also use the simplified string format with memory options:
|
|
71
71
|
|
|
72
72
|
```typescript
|
|
73
73
|
const response = await agent.generate("Hello, how are you?", {
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
memory: {
|
|
75
|
+
thread: "thread-1",
|
|
76
|
+
resource: "resource-1",
|
|
77
|
+
},
|
|
76
78
|
});
|
|
77
79
|
```
|
|
78
80
|
|
|
@@ -91,11 +93,14 @@ response.processDataStream({
|
|
|
91
93
|
});
|
|
92
94
|
```
|
|
93
95
|
|
|
94
|
-
You can also use the simplified string format:
|
|
96
|
+
You can also use the simplified string format with memory options:
|
|
95
97
|
|
|
96
98
|
```typescript
|
|
97
99
|
const response = await agent.stream("Tell me a story", {
|
|
98
|
-
|
|
100
|
+
memory: {
|
|
101
|
+
thread: "thread-1",
|
|
102
|
+
resource: "resource-1",
|
|
103
|
+
},
|
|
99
104
|
clientTools: { colorChangeTool },
|
|
100
105
|
});
|
|
101
106
|
|