@mastra/core 1.18.0 → 1.18.1-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.
Files changed (211) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/agent/agent.d.ts.map +1 -1
  3. package/dist/agent/index.cjs +8 -8
  4. package/dist/agent/index.js +1 -1
  5. package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
  6. package/dist/{chunk-KLVNQDUR.cjs → chunk-2W7R236U.cjs} +3 -3
  7. package/dist/chunk-2W7R236U.cjs.map +1 -0
  8. package/dist/{chunk-V2NQOABM.cjs → chunk-5ANYSU2W.cjs} +9 -9
  9. package/dist/{chunk-V2NQOABM.cjs.map → chunk-5ANYSU2W.cjs.map} +1 -1
  10. package/dist/{chunk-KOTSKPTF.cjs → chunk-6R5PT6ZP.cjs} +5 -5
  11. package/dist/{chunk-KOTSKPTF.cjs.map → chunk-6R5PT6ZP.cjs.map} +1 -1
  12. package/dist/{chunk-LKZQG2ZZ.cjs → chunk-6VRSFFQ4.cjs} +7 -6
  13. package/dist/chunk-6VRSFFQ4.cjs.map +1 -0
  14. package/dist/{chunk-2M3HWTRI.js → chunk-7IE4K74P.js} +4 -4
  15. package/dist/{chunk-2M3HWTRI.js.map → chunk-7IE4K74P.js.map} +1 -1
  16. package/dist/{chunk-I4ZSA3XJ.js → chunk-7V3UNILV.js} +4 -4
  17. package/dist/{chunk-I4ZSA3XJ.js.map → chunk-7V3UNILV.js.map} +1 -1
  18. package/dist/{chunk-ZRLAR66M.js → chunk-AJZQPWAV.js} +59 -19
  19. package/dist/chunk-AJZQPWAV.js.map +1 -0
  20. package/dist/{chunk-XOBRMYFA.js → chunk-BZ2MSXOF.js} +3 -3
  21. package/dist/chunk-BZ2MSXOF.js.map +1 -0
  22. package/dist/{chunk-HRT662B6.js → chunk-EAJDF6UV.js} +12 -7
  23. package/dist/chunk-EAJDF6UV.js.map +1 -0
  24. package/dist/{chunk-PWFPYJGG.cjs → chunk-EXDBQKH4.cjs} +15 -15
  25. package/dist/{chunk-PWFPYJGG.cjs.map → chunk-EXDBQKH4.cjs.map} +1 -1
  26. package/dist/{chunk-GJ62FP5X.js → chunk-HQCBFWL2.js} +18 -35
  27. package/dist/chunk-HQCBFWL2.js.map +1 -0
  28. package/dist/{chunk-UPBMT3QM.js → chunk-JTJCFEIY.js} +8 -8
  29. package/dist/{chunk-UPBMT3QM.js.map → chunk-JTJCFEIY.js.map} +1 -1
  30. package/dist/{chunk-GJIN53S6.cjs → chunk-L2GYXPJJ.cjs} +9 -9
  31. package/dist/{chunk-GJIN53S6.cjs.map → chunk-L2GYXPJJ.cjs.map} +1 -1
  32. package/dist/{chunk-2H53MD2U.cjs → chunk-LVZKPNQO.cjs} +50 -50
  33. package/dist/{chunk-2H53MD2U.cjs.map → chunk-LVZKPNQO.cjs.map} +1 -1
  34. package/dist/{chunk-MJF7NZEF.js → chunk-OLHODPXN.js} +3 -3
  35. package/dist/{chunk-MJF7NZEF.js.map → chunk-OLHODPXN.js.map} +1 -1
  36. package/dist/{chunk-6Z4GSLLO.js → chunk-OTJAMDX5.js} +3 -3
  37. package/dist/{chunk-6Z4GSLLO.js.map → chunk-OTJAMDX5.js.map} +1 -1
  38. package/dist/{chunk-EKFG6JWW.js → chunk-PB3KXPNE.js} +8 -7
  39. package/dist/chunk-PB3KXPNE.js.map +1 -0
  40. package/dist/{chunk-TVZCMQTV.cjs → chunk-QADPCUBX.cjs} +83 -82
  41. package/dist/chunk-QADPCUBX.cjs.map +1 -0
  42. package/dist/{chunk-RTBZOGTO.js → chunk-QNNFMCSE.js} +3 -3
  43. package/dist/{chunk-RTBZOGTO.js.map → chunk-QNNFMCSE.js.map} +1 -1
  44. package/dist/{chunk-7GLVV6CZ.js → chunk-RF4TETYQ.js} +4 -4
  45. package/dist/{chunk-7GLVV6CZ.js.map → chunk-RF4TETYQ.js.map} +1 -1
  46. package/dist/{chunk-XQN3BKCI.js → chunk-UJX2TJIF.js} +3 -3
  47. package/dist/{chunk-XQN3BKCI.js.map → chunk-UJX2TJIF.js.map} +1 -1
  48. package/dist/{chunk-XQRTJIC7.cjs → chunk-VEP4CV7E.cjs} +32 -3
  49. package/dist/chunk-VEP4CV7E.cjs.map +1 -0
  50. package/dist/{chunk-K7AE4BHR.js → chunk-VMBWVH4B.js} +4 -3
  51. package/dist/chunk-VMBWVH4B.js.map +1 -0
  52. package/dist/{chunk-J47RNLSY.cjs → chunk-WLNT3YJ7.cjs} +95 -55
  53. package/dist/chunk-WLNT3YJ7.cjs.map +1 -0
  54. package/dist/{chunk-L3X22YTN.cjs → chunk-WMF4CWAL.cjs} +185 -185
  55. package/dist/{chunk-L3X22YTN.cjs.map → chunk-WMF4CWAL.cjs.map} +1 -1
  56. package/dist/{chunk-4FMKWOPC.js → chunk-X4Q4KB6C.js} +31 -4
  57. package/dist/chunk-X4Q4KB6C.js.map +1 -0
  58. package/dist/{chunk-RTXCZT3M.cjs → chunk-XDZOEUNU.cjs} +19 -36
  59. package/dist/chunk-XDZOEUNU.cjs.map +1 -0
  60. package/dist/{chunk-GXXNF6NF.cjs → chunk-XNBGNCVV.cjs} +15 -10
  61. package/dist/chunk-XNBGNCVV.cjs.map +1 -0
  62. package/dist/{chunk-ZVGS2O2W.cjs → chunk-YCT2YQDL.cjs} +6 -6
  63. package/dist/{chunk-ZVGS2O2W.cjs.map → chunk-YCT2YQDL.cjs.map} +1 -1
  64. package/dist/{chunk-ZQE2VUYD.cjs → chunk-YMPV2RMB.cjs} +7 -7
  65. package/dist/{chunk-ZQE2VUYD.cjs.map → chunk-YMPV2RMB.cjs.map} +1 -1
  66. package/dist/datasets/index.cjs +17 -17
  67. package/dist/datasets/index.js +2 -2
  68. package/dist/docs/SKILL.md +8 -18
  69. package/dist/docs/assets/SOURCE_MAP.json +254 -254
  70. package/dist/docs/references/docs-agents-overview.md +4 -4
  71. package/dist/docs/references/docs-agents-processors.md +1 -1
  72. package/dist/docs/references/{docs-observability-datasets-overview.md → docs-evals-datasets-overview.md} +12 -12
  73. package/dist/docs/references/{docs-observability-datasets-running-experiments.md → docs-evals-datasets-running-experiments.md} +9 -9
  74. package/dist/docs/references/docs-evals-overview.md +8 -9
  75. package/dist/docs/references/docs-memory-observational-memory.md +20 -11
  76. package/dist/docs/references/docs-memory-overview.md +4 -4
  77. package/dist/docs/references/docs-memory-semantic-recall.md +28 -19
  78. package/dist/docs/references/docs-memory-storage.md +4 -4
  79. package/dist/docs/references/docs-rag-chunking-and-embedding.md +2 -2
  80. package/dist/docs/references/docs-server-auth-composite-auth.md +1 -7
  81. package/dist/docs/references/docs-server-auth-custom-auth-provider.md +2 -4
  82. package/dist/docs/references/docs-server-auth-jwt.md +1 -1
  83. package/dist/docs/references/docs-server-auth-simple-auth.md +1 -7
  84. package/dist/docs/references/docs-server-custom-adapters.md +3 -1
  85. package/dist/docs/references/docs-server-custom-api-routes.md +1 -1
  86. package/dist/docs/references/docs-server-mastra-client.md +1 -3
  87. package/dist/docs/references/docs-server-mastra-server.md +8 -0
  88. package/dist/docs/references/docs-server-request-context.md +17 -17
  89. package/dist/docs/references/docs-streaming-events.md +1 -90
  90. package/dist/docs/references/docs-studio-auth.md +142 -0
  91. package/dist/docs/references/docs-studio-deployment.md +260 -0
  92. package/dist/docs/references/docs-studio-observability.md +98 -0
  93. package/dist/docs/references/docs-studio-overview.md +127 -0
  94. package/dist/docs/references/docs-workflows-agents-and-tools.md +7 -10
  95. package/dist/docs/references/docs-workflows-control-flow.md +1 -1
  96. package/dist/docs/references/docs-workflows-overview.md +12 -7
  97. package/dist/docs/references/docs-workflows-suspend-and-resume.md +1 -1
  98. package/dist/docs/references/guides-concepts-multi-agent-systems.md +4 -4
  99. package/dist/docs/references/reference-agents-agent.md +1 -1
  100. package/dist/docs/references/reference-configuration.md +4 -4
  101. package/dist/docs/references/reference-memory-observational-memory.md +1 -1
  102. package/dist/docs/references/reference-storage-cloudflare-d1.md +1 -1
  103. package/dist/docs/references/reference-storage-lance.md +1 -1
  104. package/dist/docs/references/reference-storage-upstash.md +1 -1
  105. package/dist/docs/references/reference.md +16 -14
  106. package/dist/evals/index.cjs +5 -5
  107. package/dist/evals/index.js +2 -2
  108. package/dist/evals/scoreTraces/index.cjs +3 -3
  109. package/dist/evals/scoreTraces/index.js +1 -1
  110. package/dist/harness/harness.d.ts.map +1 -1
  111. package/dist/harness/index.cjs +13 -12
  112. package/dist/harness/index.cjs.map +1 -1
  113. package/dist/harness/index.js +8 -7
  114. package/dist/harness/index.js.map +1 -1
  115. package/dist/index.cjs +2 -2
  116. package/dist/index.js +1 -1
  117. package/dist/llm/index.cjs +16 -16
  118. package/dist/llm/index.js +5 -5
  119. package/dist/llm/model/aisdk/v5/model.d.ts +5 -0
  120. package/dist/llm/model/aisdk/v5/model.d.ts.map +1 -1
  121. package/dist/llm/model/aisdk/v6/model.d.ts +5 -0
  122. package/dist/llm/model/aisdk/v6/model.d.ts.map +1 -1
  123. package/dist/llm/model/provider-types.generated.d.ts +5 -13
  124. package/dist/loop/index.cjs +14 -14
  125. package/dist/loop/index.js +1 -1
  126. package/dist/loop/network/validation.d.ts.map +1 -1
  127. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
  128. package/dist/mastra/index.cjs +2 -2
  129. package/dist/mastra/index.js +1 -1
  130. package/dist/memory/index.cjs +14 -14
  131. package/dist/memory/index.js +1 -1
  132. package/dist/models-dev-WD6XLSFC.cjs +12 -0
  133. package/dist/{models-dev-5WY37RVC.cjs.map → models-dev-WD6XLSFC.cjs.map} +1 -1
  134. package/dist/models-dev-XG4KIUFT.js +3 -0
  135. package/dist/{models-dev-Y2UFJEOO.js.map → models-dev-XG4KIUFT.js.map} +1 -1
  136. package/dist/netlify-FMBBUFKT.cjs +12 -0
  137. package/dist/{netlify-ADZQ5ZNY.cjs.map → netlify-FMBBUFKT.cjs.map} +1 -1
  138. package/dist/netlify-NDOVF45T.js +3 -0
  139. package/dist/{netlify-I4AUVRO2.js.map → netlify-NDOVF45T.js.map} +1 -1
  140. package/dist/processor-provider/index.cjs +10 -10
  141. package/dist/processor-provider/index.js +1 -1
  142. package/dist/processors/index.cjs +44 -44
  143. package/dist/processors/index.js +1 -1
  144. package/dist/provider-registry-KHXFOGCK.js +3 -0
  145. package/dist/{provider-registry-C7SZ5ZT4.js.map → provider-registry-KHXFOGCK.js.map} +1 -1
  146. package/dist/provider-registry-VUG7E4SG.cjs +40 -0
  147. package/dist/{provider-registry-I5RW3MEE.cjs.map → provider-registry-VUG7E4SG.cjs.map} +1 -1
  148. package/dist/provider-registry.json +14 -31
  149. package/dist/relevance/index.cjs +3 -3
  150. package/dist/relevance/index.js +1 -1
  151. package/dist/storage/index.cjs +74 -74
  152. package/dist/storage/index.js +1 -1
  153. package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
  154. package/dist/stream/index.cjs +8 -8
  155. package/dist/stream/index.js +1 -1
  156. package/dist/test-utils/llm-mock.cjs +4 -4
  157. package/dist/test-utils/llm-mock.js +1 -1
  158. package/dist/tool-loop-agent/index.cjs +4 -4
  159. package/dist/tool-loop-agent/index.js +1 -1
  160. package/dist/tools/tool-builder/builder.d.ts.map +1 -1
  161. package/dist/utils.cjs +31 -23
  162. package/dist/utils.d.ts +10 -0
  163. package/dist/utils.d.ts.map +1 -1
  164. package/dist/utils.js +1 -1
  165. package/dist/vector/index.cjs +7 -7
  166. package/dist/vector/index.js +1 -1
  167. package/dist/workflows/evented/index.cjs +10 -10
  168. package/dist/workflows/evented/index.js +1 -1
  169. package/dist/workflows/index.cjs +24 -24
  170. package/dist/workflows/index.js +1 -1
  171. package/dist/workflows/workflow.d.ts.map +1 -1
  172. package/dist/workspace/index.cjs +68 -68
  173. package/dist/workspace/index.js +1 -1
  174. package/dist/workspace/workspace.d.ts +1 -0
  175. package/dist/workspace/workspace.d.ts.map +1 -1
  176. package/package.json +2 -2
  177. package/src/llm/model/provider-types.generated.d.ts +5 -13
  178. package/dist/chunk-4FMKWOPC.js.map +0 -1
  179. package/dist/chunk-EKFG6JWW.js.map +0 -1
  180. package/dist/chunk-GJ62FP5X.js.map +0 -1
  181. package/dist/chunk-GXXNF6NF.cjs.map +0 -1
  182. package/dist/chunk-HRT662B6.js.map +0 -1
  183. package/dist/chunk-J47RNLSY.cjs.map +0 -1
  184. package/dist/chunk-K7AE4BHR.js.map +0 -1
  185. package/dist/chunk-KLVNQDUR.cjs.map +0 -1
  186. package/dist/chunk-LKZQG2ZZ.cjs.map +0 -1
  187. package/dist/chunk-RTXCZT3M.cjs.map +0 -1
  188. package/dist/chunk-TVZCMQTV.cjs.map +0 -1
  189. package/dist/chunk-XOBRMYFA.js.map +0 -1
  190. package/dist/chunk-XQRTJIC7.cjs.map +0 -1
  191. package/dist/chunk-ZRLAR66M.js.map +0 -1
  192. package/dist/docs/references/docs-observability-logging.md +0 -99
  193. package/dist/docs/references/docs-observability-overview.md +0 -70
  194. package/dist/docs/references/docs-observability-tracing-bridges-otel.md +0 -209
  195. package/dist/docs/references/docs-observability-tracing-exporters-arize.md +0 -272
  196. package/dist/docs/references/docs-observability-tracing-exporters-braintrust.md +0 -126
  197. package/dist/docs/references/docs-observability-tracing-exporters-cloud.md +0 -127
  198. package/dist/docs/references/docs-observability-tracing-exporters-datadog.md +0 -317
  199. package/dist/docs/references/docs-observability-tracing-exporters-default.md +0 -209
  200. package/dist/docs/references/docs-observability-tracing-exporters-laminar.md +0 -100
  201. package/dist/docs/references/docs-observability-tracing-exporters-langfuse.md +0 -213
  202. package/dist/docs/references/docs-observability-tracing-exporters-langsmith.md +0 -198
  203. package/dist/docs/references/docs-observability-tracing-exporters-otel.md +0 -476
  204. package/dist/docs/references/docs-observability-tracing-exporters-posthog.md +0 -148
  205. package/dist/docs/references/docs-observability-tracing-overview.md +0 -1112
  206. package/dist/models-dev-5WY37RVC.cjs +0 -12
  207. package/dist/models-dev-Y2UFJEOO.js +0 -3
  208. package/dist/netlify-ADZQ5ZNY.cjs +0 -12
  209. package/dist/netlify-I4AUVRO2.js +0 -3
  210. package/dist/provider-registry-C7SZ5ZT4.js +0 -3
  211. package/dist/provider-registry-I5RW3MEE.cjs +0 -40
@@ -1,16 +1,16 @@
1
1
  import { DefaultVoice } from './chunk-YDLGEJ7W.js';
2
2
  import { PUBSUB_SYMBOL, STREAM_FORMAT_SYMBOL } from './chunk-2QXNHEDL.js';
3
- import { createWorkspaceTools, createSkillTools, getTiktoken, BM25Index } from './chunk-HRT662B6.js';
4
- import { InMemoryStore } from './chunk-MJF7NZEF.js';
3
+ import { createWorkspaceTools, createSkillTools, getTiktoken, BM25Index } from './chunk-EAJDF6UV.js';
4
+ import { InMemoryStore } from './chunk-OLHODPXN.js';
5
5
  import { MessageList, coreContentToString, DefaultGeneratedFile, DefaultGeneratedFileWithType, sanitizeToolName } from './chunk-SLZ3WO42.js';
6
6
  import { parsePartialJson, isDeepEqualData, stepCountIs } from './chunk-2PHG443D.js';
7
7
  import { generateId, APICallError, tool, asSchema } from './chunk-6PALJNKG.js';
8
8
  import { executeHook } from './chunk-L54GIUCB.js';
9
- import { resolveModelConfig, ModelRouterEmbeddingModel, ModelRouterLanguageModel } from './chunk-EKFG6JWW.js';
10
- import { MastraLLMV1 } from './chunk-K7AE4BHR.js';
9
+ import { resolveModelConfig, ModelRouterEmbeddingModel, ModelRouterLanguageModel } from './chunk-PB3KXPNE.js';
10
+ import { MastraLLMV1 } from './chunk-VMBWVH4B.js';
11
11
  import { noopLogger } from './chunk-PSCMWPLC.js';
12
12
  import { EventEmitterPubSub } from './chunk-X2HAI3OX.js';
13
- import { removeUndefinedValues, ensureToolProperties, makeCoreTool, createMastraProxy, deepMerge, generateEmptyFromSchema, selectFields, delay } from './chunk-4FMKWOPC.js';
13
+ import { removeUndefinedValues, safeStringify, ensureToolProperties, makeCoreTool, createMastraProxy, deepMerge, generateEmptyFromSchema, selectFields, ensureSerializable, delay } from './chunk-X4Q4KB6C.js';
14
14
  import { resolveObservabilityContext, EntityType, createObservabilityContext, getRootExportSpan, getOrCreateSpan, wrapMastra, executeWithContext, executeWithContextSync } from './chunk-KRFGPA2H.js';
15
15
  import { ToolStream } from './chunk-DD2VNRQM.js';
16
16
  import { Tool, createTool, isMastraTool, isProviderTool, getProviderToolName, isProviderDefinedTool } from './chunk-FA4PTEBK.js';
@@ -618,10 +618,16 @@ function prepareToolsAndToolChoice({
618
618
  activeTools,
619
619
  targetVersion = "v2"
620
620
  }) {
621
+ if (toolChoice === "none") {
622
+ return {
623
+ tools: void 0,
624
+ toolChoice: { type: "none" }
625
+ };
626
+ }
621
627
  if (Object.keys(tools || {}).length === 0) {
622
628
  return {
623
629
  tools: void 0,
624
- toolChoice: toolChoice === "none" ? { type: "none" } : void 0
630
+ toolChoice: void 0
625
631
  };
626
632
  }
627
633
  const filteredTools = activeTools != null ? Object.entries(tools || {}).filter(([name]) => activeTools.includes(name)) : Object.entries(tools || {});
@@ -8307,6 +8313,16 @@ function isToolStep(input) {
8307
8313
  function isStepParams(input) {
8308
8314
  return input !== null && typeof input === "object" && "id" in input && "execute" in input && !(input instanceof Agent) && !(input instanceof Tool);
8309
8315
  }
8316
+ function findStepInGraph(graph, stepId) {
8317
+ for (const entry of graph) {
8318
+ if ("step" in entry && entry.step?.id === stepId) return entry;
8319
+ if ((entry.type === "conditional" || entry.type === "parallel") && "steps" in entry) {
8320
+ const found = findStepInGraph(entry.steps, stepId);
8321
+ if (found) return found;
8322
+ }
8323
+ }
8324
+ return void 0;
8325
+ }
8310
8326
  function createStep(params, agentOrToolOptions) {
8311
8327
  if (isAgent(params)) {
8312
8328
  return createStepFromAgent(params, agentOrToolOptions);
@@ -9787,7 +9803,7 @@ var Workflow = class extends MastraBase {
9787
9803
  const { input, ...steps } = context;
9788
9804
  let finalSteps = {};
9789
9805
  for (const step of Object.keys(steps)) {
9790
- const stepGraph = serializedStepGraph.find((stepGraph2) => stepGraph2?.step?.id === step);
9806
+ const stepGraph = findStepInGraph(serializedStepGraph, step);
9791
9807
  finalSteps[step] = steps[step];
9792
9808
  if (stepGraph && stepGraph?.step?.component === "WORKFLOW") {
9793
9809
  const stepResult = steps[step];
@@ -11564,7 +11580,7 @@ async function runDefaultCompletionCheck(agent, context, streamContext, abortSig
11564
11580
  Primitives already executed: ${completedPrimitives.join(", ")}` : "";
11565
11581
  const completionPrompt = `
11566
11582
  The ${context.selectedPrimitive.type} ${context.selectedPrimitive.id} has contributed to the task.
11567
- This is the result: ${JSON.stringify(context.primitiveResult)}
11583
+ This is the result: ${safeStringify(context.primitiveResult)}
11568
11584
 
11569
11585
  ${completedSection}
11570
11586
 
@@ -11660,7 +11676,7 @@ async function generateFinalResult(agent, context, streamContext, abortSignal, o
11660
11676
  Original task: ${context.originalTask}
11661
11677
 
11662
11678
  The ${context.selectedPrimitive.type} ${context.selectedPrimitive.id} produced this result:
11663
- ${JSON.stringify(context.primitiveResult)}
11679
+ ${safeStringify(context.primitiveResult)}
11664
11680
 
11665
11681
  IMPORTANT: If the above result is from an AGENT PRIMITIVE and it is a suitable final result itself considering the original task, then finalResult should be an empty string or undefined.
11666
11682
  You should evaluate if the above result is comprehensive enough to accomplish the user's original task.
@@ -11718,7 +11734,7 @@ async function generateStructuredFinalResult(agent, context, structuredOutputOpt
11718
11734
  Original task: ${context.originalTask}
11719
11735
 
11720
11736
  The ${context.selectedPrimitive.type} ${context.selectedPrimitive.id} produced this result:
11721
- ${JSON.stringify(context.primitiveResult)}
11737
+ ${safeStringify(context.primitiveResult)}
11722
11738
 
11723
11739
  Based on the task and result above, generate a structured response according to the provided schema.
11724
11740
  Use the conversation history and primitive results to craft the response.
@@ -13912,7 +13928,8 @@ function createToolCallStep({
13912
13928
  args.resourceId = _internal?.resourceId;
13913
13929
  }
13914
13930
  }
13915
- const result = await tool2.execute(args, toolOptions);
13931
+ const rawResult = await tool2.execute(args, toolOptions);
13932
+ const result = ensureSerializable(rawResult);
13916
13933
  if (tool2 && "onOutput" in tool2 && typeof tool2.onOutput === "function") {
13917
13934
  try {
13918
13935
  await tool2.onOutput({
@@ -18437,7 +18454,16 @@ function createMapResultsStep({
18437
18454
  ...modelId && { modelId }
18438
18455
  });
18439
18456
  }
18440
- agentSpan?.error({ error: payload.error, endSpan: true });
18457
+ const error = payload.error instanceof Error ? payload.error : new MastraError(
18458
+ {
18459
+ id: "AGENT_STREAM_ERROR",
18460
+ domain: "AGENT" /* AGENT */,
18461
+ category: "SYSTEM" /* SYSTEM */,
18462
+ details: { runId }
18463
+ },
18464
+ payload.error
18465
+ );
18466
+ agentSpan?.error({ error, endSpan: true });
18441
18467
  return;
18442
18468
  }
18443
18469
  const aborted = options.abortSignal?.aborted;
@@ -18465,7 +18491,19 @@ function createMapResultsStep({
18465
18491
  error: e,
18466
18492
  runId
18467
18493
  });
18494
+ const spanError = e instanceof Error ? e : new MastraError(
18495
+ {
18496
+ id: "AGENT_ON_FINISH_ERROR",
18497
+ domain: "AGENT" /* AGENT */,
18498
+ category: "SYSTEM" /* SYSTEM */,
18499
+ details: { runId }
18500
+ },
18501
+ e
18502
+ );
18503
+ agentSpan?.error({ error: spanError, endSpan: true });
18468
18504
  }
18505
+ } else {
18506
+ agentSpan?.end();
18469
18507
  }
18470
18508
  await options?.onFinish?.({
18471
18509
  ...payload,
@@ -21114,10 +21152,7 @@ ${effectiveInstructions}`;
21114
21152
  this.logger.error(`[Agent:${this.name}] - messageFilter error: ${filterError}`);
21115
21153
  }
21116
21154
  }
21117
- const messagesForSubAgent = [
21118
- ...filteredContextMessages,
21119
- { role: "user", content: effectivePrompt }
21120
- ];
21155
+ const messagesForSubAgent = [{ role: "user", content: effectivePrompt }];
21121
21156
  const subAgentPromptCreatedAt = /* @__PURE__ */ new Date();
21122
21157
  if ((methodType === "generate" || methodType === "generateLegacy") && supportedLanguageModelSpecifications.includes(modelVersion)) {
21123
21158
  const generateResult = resumeData ? await agent.resumeGenerate(resumeData, {
@@ -21126,6 +21161,7 @@ ${effectiveInstructions}`;
21126
21161
  ...resolveObservabilityContext(context ?? {}),
21127
21162
  ...effectiveInstructions && { instructions: effectiveInstructions },
21128
21163
  ...effectiveMaxSteps && { maxSteps: effectiveMaxSteps },
21164
+ context: filteredContextMessages,
21129
21165
  ...resourceId && threadId && !subAgentHasOwnMemoryConfig ? {
21130
21166
  memory: {
21131
21167
  resource: subAgentResourceId,
@@ -21138,6 +21174,7 @@ ${effectiveInstructions}`;
21138
21174
  ...resolveObservabilityContext(context ?? {}),
21139
21175
  ...effectiveInstructions && { instructions: effectiveInstructions },
21140
21176
  ...effectiveMaxSteps && { maxSteps: effectiveMaxSteps },
21177
+ context: filteredContextMessages,
21141
21178
  ...resourceId && threadId && !subAgentHasOwnMemoryConfig ? {
21142
21179
  memory: {
21143
21180
  resource: subAgentResourceId,
@@ -21199,7 +21236,8 @@ ${effectiveInstructions}`;
21199
21236
  } else if (methodType === "generate" && modelVersion === "v1") {
21200
21237
  const generateResult = await agent.generateLegacy(messagesForSubAgent, {
21201
21238
  requestContext,
21202
- ...resolveObservabilityContext(context ?? {})
21239
+ ...resolveObservabilityContext(context ?? {}),
21240
+ context: filteredContextMessages
21203
21241
  });
21204
21242
  result = { text: generateResult.text };
21205
21243
  } else if ((methodType === "stream" || methodType === "streamLegacy") && supportedLanguageModelSpecifications.includes(modelVersion)) {
@@ -21209,6 +21247,7 @@ ${effectiveInstructions}`;
21209
21247
  ...resolveObservabilityContext(context ?? {}),
21210
21248
  ...effectiveInstructions && { instructions: effectiveInstructions },
21211
21249
  ...effectiveMaxSteps && { maxSteps: effectiveMaxSteps },
21250
+ context: filteredContextMessages,
21212
21251
  ...resourceId && threadId && !subAgentHasOwnMemoryConfig ? {
21213
21252
  memory: {
21214
21253
  resource: subAgentResourceId,
@@ -21223,6 +21262,7 @@ ${effectiveInstructions}`;
21223
21262
  ...resolveObservabilityContext(context ?? {}),
21224
21263
  ...effectiveInstructions && { instructions: effectiveInstructions },
21225
21264
  ...effectiveMaxSteps && { maxSteps: effectiveMaxSteps },
21265
+ context: filteredContextMessages,
21226
21266
  ...resourceId && threadId && !subAgentHasOwnMemoryConfig ? {
21227
21267
  memory: {
21228
21268
  resource: subAgentResourceId,
@@ -27293,5 +27333,5 @@ var MockMemory = class extends MastraMemory {
27293
27333
  };
27294
27334
 
27295
27335
  export { Agent, AgentsMDInjector, BaseProcessor, BatchPartsProcessor, ChunkFrom, DefaultExecutionEngine, ExecutionEngine, FilePartSchema, ImagePartSchema, LanguageDetector, MastraAgentNetworkStream, MastraMemory, MastraModelOutput, MastraScorer, MemoryProcessor, MessageContentSchema, MessageHistory, MessagePartSchema, MockMemory, ModerationProcessor, PIIDetector, ProcessorInputPhaseSchema, ProcessorInputStepPhaseSchema, ProcessorMessageContentSchema, ProcessorMessageSchema, ProcessorOutputResultPhaseSchema, ProcessorOutputStepPhaseSchema, ProcessorOutputStreamPhaseSchema, ProcessorRunner, ProcessorState, ProcessorStepInputSchema, ProcessorStepOutputSchema, ProcessorStepSchema, PromptInjectionDetector, ReasoningPartSchema, Run, SemanticRecall, SkillSearchProcessor, SkillsProcessor, SourcePartSchema, StepStartPartSchema, StructuredOutputProcessor, SystemPromptScrubber, TextPartSchema, TokenLimiterProcessor, ToolCallFilter, ToolInvocationPartSchema, ToolSearchProcessor, TripWire, UnicodeNormalizer, WORKING_MEMORY_END_TAG, WORKING_MEMORY_START_TAG, Workflow, WorkflowRunOutput, WorkingMemory, WorkspaceInstructionsProcessor, augmentWithInit, cleanStepResult, cloneStep, cloneWorkflow, convertFullStreamChunkToMastra, convertFullStreamChunkToUIMessageStream, convertMastraChunkToAISDKv5, createDeprecationProxy, createScorer, createStep, createTimeTravelExecutionParams, createWorkflow, extractWorkingMemoryContent, extractWorkingMemoryTags, formatCheckFeedback, formatCompletionFeedback, formatStreamCompletionFeedback, formatValidationFeedback, forwardAgentStreamChunk, generateFinalResult, generateStructuredFinalResult, getResumeLabelsByStepId, getStepIds, getStepResult, getThreadOMMetadata, globalEmbeddingCache, hydrateSerializedStepErrors, isObservationalMemoryEnabled, isProcessor, isProcessorWorkflow, isSupportedLanguageModel, loop, mapVariable, memoryDefaultOptions, parseMemoryRequestContext, removeWorkingMemoryTags, resolveThreadIdFromArgs, runChecks, runCompletionScorers, runCountDeprecationMessage, runDefaultCompletionCheck, runStreamCompletionScorers, runValidation, setThreadOMMetadata, supportedLanguageModelSpecifications, tryGenerateWithJsonFallback, tryStreamWithJsonFallback, validateStepInput, validateStepRequestContext, validateStepResumeData, validateStepStateData, validateStepSuspendData };
27296
- //# sourceMappingURL=chunk-ZRLAR66M.js.map
27297
- //# sourceMappingURL=chunk-ZRLAR66M.js.map
27336
+ //# sourceMappingURL=chunk-AJZQPWAV.js.map
27337
+ //# sourceMappingURL=chunk-AJZQPWAV.js.map