@mastra/core 1.9.0 → 1.10.0

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 (438) hide show
  1. package/CHANGELOG.md +202 -0
  2. package/dist/agent/agent.d.ts +22 -3
  3. package/dist/agent/agent.d.ts.map +1 -1
  4. package/dist/agent/index.cjs +13 -13
  5. package/dist/agent/index.js +2 -2
  6. package/dist/agent/message-list/index.cjs +18 -18
  7. package/dist/agent/message-list/index.js +1 -1
  8. package/dist/agent/message-list/message-list.d.ts.map +1 -1
  9. package/dist/{chunk-IOY7Y5GV.js → chunk-3VVNJPTO.js} +602 -187
  10. package/dist/chunk-3VVNJPTO.js.map +1 -0
  11. package/dist/{chunk-VDKWYUGC.cjs → chunk-5WBEMKE2.cjs} +7 -3
  12. package/dist/chunk-5WBEMKE2.cjs.map +1 -0
  13. package/dist/{chunk-H5S4PS44.cjs → chunk-76Q75VI4.cjs} +602 -187
  14. package/dist/chunk-76Q75VI4.cjs.map +1 -0
  15. package/dist/{chunk-ZBESCKPX.cjs → chunk-7AHCLTZZ.cjs} +1572 -36
  16. package/dist/chunk-7AHCLTZZ.cjs.map +1 -0
  17. package/dist/{chunk-SEKQJ447.js → chunk-ACAILOJE.js} +166 -68
  18. package/dist/chunk-ACAILOJE.js.map +1 -0
  19. package/dist/{chunk-YIJZBU54.cjs → chunk-BCSVBOAN.cjs} +240 -463
  20. package/dist/chunk-BCSVBOAN.cjs.map +1 -0
  21. package/dist/{chunk-ZVWVQ6MG.js → chunk-CY4ZWL2X.js} +8 -3
  22. package/dist/chunk-CY4ZWL2X.js.map +1 -0
  23. package/dist/{chunk-ET7GXCHS.js → chunk-DIKRJVK6.js} +5 -5
  24. package/dist/{chunk-ET7GXCHS.js.map → chunk-DIKRJVK6.js.map} +1 -1
  25. package/dist/{chunk-P6ZX7OKT.cjs → chunk-E6I5LBDM.cjs} +7 -7
  26. package/dist/{chunk-P6ZX7OKT.cjs.map → chunk-E6I5LBDM.cjs.map} +1 -1
  27. package/dist/{chunk-BFV3GSGS.js → chunk-FT5Q6XTK.js} +1546 -22
  28. package/dist/chunk-FT5Q6XTK.js.map +1 -0
  29. package/dist/{chunk-K54LFB4P.js → chunk-FXOWXS4O.js} +3 -3
  30. package/dist/{chunk-K54LFB4P.js.map → chunk-FXOWXS4O.js.map} +1 -1
  31. package/dist/{chunk-QNXY3J6B.cjs → chunk-GCRPNAAR.cjs} +22 -19
  32. package/dist/chunk-GCRPNAAR.cjs.map +1 -0
  33. package/dist/{chunk-5M3RMO7U.js → chunk-GTA5BKXZ.js} +8 -8
  34. package/dist/{chunk-5M3RMO7U.js.map → chunk-GTA5BKXZ.js.map} +1 -1
  35. package/dist/{chunk-G5R2755Q.cjs → chunk-HAIQ57YB.cjs} +53 -20
  36. package/dist/chunk-HAIQ57YB.cjs.map +1 -0
  37. package/dist/{chunk-3ZBLD2Y4.cjs → chunk-HH76UOJL.cjs} +2 -2
  38. package/dist/{chunk-3ZBLD2Y4.cjs.map → chunk-HH76UOJL.cjs.map} +1 -1
  39. package/dist/{chunk-HAGCXIBX.cjs → chunk-HNYQITSV.cjs} +9 -9
  40. package/dist/{chunk-HAGCXIBX.cjs.map → chunk-HNYQITSV.cjs.map} +1 -1
  41. package/dist/{chunk-GJTLWOKJ.js → chunk-HQA3IBLZ.js} +51 -18
  42. package/dist/chunk-HQA3IBLZ.js.map +1 -0
  43. package/dist/{chunk-4BXXAZ75.js → chunk-HQTHWVAK.js} +15 -7
  44. package/dist/chunk-HQTHWVAK.js.map +1 -0
  45. package/dist/{chunk-CCLV5CAA.js → chunk-JGOH7RWL.js} +7 -3
  46. package/dist/chunk-JGOH7RWL.js.map +1 -0
  47. package/dist/{chunk-Y6TGIUGL.js → chunk-LSF5WJ6G.js} +2 -2
  48. package/dist/{chunk-Y6TGIUGL.js.map → chunk-LSF5WJ6G.js.map} +1 -1
  49. package/dist/{chunk-D6HO5QAM.cjs → chunk-M26GEN4C.cjs} +14 -9
  50. package/dist/chunk-M26GEN4C.cjs.map +1 -0
  51. package/dist/{chunk-4P35AVPE.cjs → chunk-MEMYFFOL.cjs} +256 -157
  52. package/dist/chunk-MEMYFFOL.cjs.map +1 -0
  53. package/dist/{chunk-BQ355Z3O.js → chunk-NUZWQA4J.js} +4 -4
  54. package/dist/{chunk-BQ355Z3O.js.map → chunk-NUZWQA4J.js.map} +1 -1
  55. package/dist/{chunk-JIRB5LX4.js → chunk-OHX36YXF.js} +5 -3
  56. package/dist/chunk-OHX36YXF.js.map +1 -0
  57. package/dist/{chunk-PKORY4ZZ.cjs → chunk-OOTLMVNN.cjs} +107 -7
  58. package/dist/chunk-OOTLMVNN.cjs.map +1 -0
  59. package/dist/{chunk-D4M6E4OQ.cjs → chunk-OWZ6QT24.cjs} +16 -8
  60. package/dist/chunk-OWZ6QT24.cjs.map +1 -0
  61. package/dist/{chunk-6OHS6ZQ3.js → chunk-PDJCIONR.js} +8 -8
  62. package/dist/{chunk-6OHS6ZQ3.js.map → chunk-PDJCIONR.js.map} +1 -1
  63. package/dist/{chunk-WU2P7XOU.cjs → chunk-PP4G2TZZ.cjs} +20 -20
  64. package/dist/{chunk-WU2P7XOU.cjs.map → chunk-PP4G2TZZ.cjs.map} +1 -1
  65. package/dist/{chunk-VWAK25TU.js → chunk-SBBWRNZA.js} +10 -7
  66. package/dist/chunk-SBBWRNZA.js.map +1 -0
  67. package/dist/{chunk-TU4YMXOQ.js → chunk-TJIFNVPX.js} +6 -6
  68. package/dist/{chunk-TU4YMXOQ.js.map → chunk-TJIFNVPX.js.map} +1 -1
  69. package/dist/{chunk-V5YNS2QO.cjs → chunk-XJNQHPBJ.cjs} +15 -15
  70. package/dist/{chunk-V5YNS2QO.cjs.map → chunk-XJNQHPBJ.cjs.map} +1 -1
  71. package/dist/{chunk-MVYP55NA.js → chunk-YC6Z75K2.js} +113 -336
  72. package/dist/chunk-YC6Z75K2.js.map +1 -0
  73. package/dist/{chunk-3ZF7IC6Q.cjs → chunk-YZMSJKAK.cjs} +5 -3
  74. package/dist/chunk-YZMSJKAK.cjs.map +1 -0
  75. package/dist/{chunk-L3WDI7HP.cjs → chunk-Z2X5VTYJ.cjs} +65 -65
  76. package/dist/{chunk-L3WDI7HP.cjs.map → chunk-Z2X5VTYJ.cjs.map} +1 -1
  77. package/dist/{chunk-BN5MV2QK.cjs → chunk-Z52OAJ73.cjs} +4 -4
  78. package/dist/{chunk-BN5MV2QK.cjs.map → chunk-Z52OAJ73.cjs.map} +1 -1
  79. package/dist/{chunk-WYPSC6CO.js → chunk-ZBU6P4JV.js} +104 -4
  80. package/dist/chunk-ZBU6P4JV.js.map +1 -0
  81. package/dist/datasets/experiment/index.d.ts.map +1 -1
  82. package/dist/datasets/experiment/scorer.d.ts.map +1 -1
  83. package/dist/datasets/index.cjs +17 -17
  84. package/dist/datasets/index.js +2 -2
  85. package/dist/di/index.cjs +4 -4
  86. package/dist/di/index.js +1 -1
  87. package/dist/docs/SKILL.md +1 -1
  88. package/dist/docs/assets/SOURCE_MAP.json +443 -384
  89. package/dist/docs/references/docs-agents-agent-approval.md +61 -31
  90. package/dist/docs/references/docs-agents-supervisor-agents.md +1 -1
  91. package/dist/docs/references/docs-memory-observational-memory.md +9 -0
  92. package/dist/docs/references/docs-memory-semantic-recall.md +17 -1
  93. package/dist/docs/references/docs-workspace-skills.md +7 -5
  94. package/dist/docs/references/reference-agents-agent.md +20 -20
  95. package/dist/docs/references/reference-agents-generate.md +200 -66
  96. package/dist/docs/references/reference-agents-generateLegacy.md +77 -35
  97. package/dist/docs/references/reference-agents-getDefaultGenerateOptions.md +4 -6
  98. package/dist/docs/references/reference-agents-getDefaultOptions.md +4 -6
  99. package/dist/docs/references/reference-agents-getDefaultStreamOptions.md +4 -6
  100. package/dist/docs/references/reference-agents-getDescription.md +1 -1
  101. package/dist/docs/references/reference-agents-getInstructions.md +4 -6
  102. package/dist/docs/references/reference-agents-getLLM.md +6 -8
  103. package/dist/docs/references/reference-agents-getMemory.md +4 -6
  104. package/dist/docs/references/reference-agents-getModel.md +4 -6
  105. package/dist/docs/references/reference-agents-getTools.md +5 -7
  106. package/dist/docs/references/reference-agents-getVoice.md +4 -6
  107. package/dist/docs/references/reference-agents-listAgents.md +4 -6
  108. package/dist/docs/references/reference-agents-listScorers.md +4 -6
  109. package/dist/docs/references/reference-agents-listTools.md +4 -6
  110. package/dist/docs/references/reference-agents-listWorkflows.md +4 -6
  111. package/dist/docs/references/reference-agents-network.md +69 -23
  112. package/dist/docs/references/reference-ai-sdk-chat-route.md +7 -7
  113. package/dist/docs/references/reference-ai-sdk-network-route.md +3 -3
  114. package/dist/docs/references/reference-ai-sdk-to-ai-sdk-stream.md +9 -9
  115. package/dist/docs/references/reference-ai-sdk-with-mastra.md +12 -12
  116. package/dist/docs/references/reference-ai-sdk-workflow-route.md +3 -3
  117. package/dist/docs/references/reference-auth-auth0.md +6 -6
  118. package/dist/docs/references/reference-auth-clerk.md +5 -5
  119. package/dist/docs/references/reference-auth-firebase.md +7 -7
  120. package/dist/docs/references/reference-auth-jwt.md +1 -1
  121. package/dist/docs/references/reference-auth-supabase.md +4 -4
  122. package/dist/docs/references/reference-auth-workos.md +6 -6
  123. package/dist/docs/references/reference-core-addGateway.md +2 -2
  124. package/dist/docs/references/reference-core-getAgent.md +2 -2
  125. package/dist/docs/references/reference-core-getAgentById.md +2 -2
  126. package/dist/docs/references/reference-core-getDeployer.md +1 -1
  127. package/dist/docs/references/reference-core-getGateway.md +2 -2
  128. package/dist/docs/references/reference-core-getGatewayById.md +2 -2
  129. package/dist/docs/references/reference-core-getLogger.md +1 -1
  130. package/dist/docs/references/reference-core-getMCPServer.md +2 -2
  131. package/dist/docs/references/reference-core-getMCPServerById.md +3 -3
  132. package/dist/docs/references/reference-core-getMemory.md +2 -2
  133. package/dist/docs/references/reference-core-getScorer.md +2 -2
  134. package/dist/docs/references/reference-core-getScorerById.md +2 -2
  135. package/dist/docs/references/reference-core-getServer.md +1 -1
  136. package/dist/docs/references/reference-core-getStorage.md +1 -1
  137. package/dist/docs/references/reference-core-getStoredAgentById.md +18 -20
  138. package/dist/docs/references/reference-core-getTelemetry.md +1 -1
  139. package/dist/docs/references/reference-core-getVector.md +2 -2
  140. package/dist/docs/references/reference-core-getWorkflow.md +3 -3
  141. package/dist/docs/references/reference-core-listAgents.md +1 -1
  142. package/dist/docs/references/reference-core-listGateways.md +1 -1
  143. package/dist/docs/references/reference-core-listLogs.md +9 -11
  144. package/dist/docs/references/reference-core-listLogsByRunId.md +9 -9
  145. package/dist/docs/references/reference-core-listMCPServers.md +1 -1
  146. package/dist/docs/references/reference-core-listMemory.md +1 -1
  147. package/dist/docs/references/reference-core-listScorers.md +1 -1
  148. package/dist/docs/references/reference-core-listStoredAgents.md +9 -11
  149. package/dist/docs/references/reference-core-listVectors.md +1 -1
  150. package/dist/docs/references/reference-core-listWorkflows.md +2 -2
  151. package/dist/docs/references/reference-core-mastra-class.md +17 -17
  152. package/dist/docs/references/reference-core-mastra-model-gateway.md +15 -15
  153. package/dist/docs/references/reference-core-setLogger.md +2 -4
  154. package/dist/docs/references/reference-core-setStorage.md +1 -1
  155. package/dist/docs/references/reference-datasets-addItem.md +20 -4
  156. package/dist/docs/references/reference-datasets-addItems.md +8 -2
  157. package/dist/docs/references/reference-datasets-compareExperiments.md +15 -3
  158. package/dist/docs/references/reference-datasets-create.md +6 -6
  159. package/dist/docs/references/reference-datasets-dataset.md +1 -1
  160. package/dist/docs/references/reference-datasets-delete.md +2 -2
  161. package/dist/docs/references/reference-datasets-deleteExperiment.md +2 -2
  162. package/dist/docs/references/reference-datasets-deleteItem.md +2 -2
  163. package/dist/docs/references/reference-datasets-deleteItems.md +2 -2
  164. package/dist/docs/references/reference-datasets-get.md +2 -2
  165. package/dist/docs/references/reference-datasets-getDetails.md +9 -9
  166. package/dist/docs/references/reference-datasets-getExperiment.md +2 -2
  167. package/dist/docs/references/reference-datasets-getItem.md +3 -3
  168. package/dist/docs/references/reference-datasets-getItemHistory.md +22 -2
  169. package/dist/docs/references/reference-datasets-list.md +7 -3
  170. package/dist/docs/references/reference-datasets-listExperimentResults.md +34 -4
  171. package/dist/docs/references/reference-datasets-listExperiments.md +41 -3
  172. package/dist/docs/references/reference-datasets-listItems.md +18 -6
  173. package/dist/docs/references/reference-datasets-listVersions.md +23 -3
  174. package/dist/docs/references/reference-datasets-startExperiment.md +62 -12
  175. package/dist/docs/references/reference-datasets-startExperimentAsync.md +5 -1
  176. package/dist/docs/references/reference-datasets-update.md +6 -6
  177. package/dist/docs/references/reference-datasets-updateItem.md +5 -5
  178. package/dist/docs/references/reference-evals-answer-relevancy.md +11 -11
  179. package/dist/docs/references/reference-evals-answer-similarity.md +17 -19
  180. package/dist/docs/references/reference-evals-bias.md +10 -10
  181. package/dist/docs/references/reference-evals-completeness.md +3 -3
  182. package/dist/docs/references/reference-evals-content-similarity.md +6 -6
  183. package/dist/docs/references/reference-evals-context-precision.md +4 -4
  184. package/dist/docs/references/reference-evals-create-scorer.md +47 -49
  185. package/dist/docs/references/reference-evals-faithfulness.md +11 -11
  186. package/dist/docs/references/reference-evals-hallucination.md +17 -21
  187. package/dist/docs/references/reference-evals-keyword-coverage.md +4 -4
  188. package/dist/docs/references/reference-evals-mastra-scorer.md +14 -14
  189. package/dist/docs/references/reference-evals-run-evals.md +16 -16
  190. package/dist/docs/references/reference-evals-scorer-utils.md +3 -3
  191. package/dist/docs/references/reference-evals-textual-difference.md +3 -3
  192. package/dist/docs/references/reference-evals-tone-consistency.md +3 -3
  193. package/dist/docs/references/reference-evals-toxicity.md +8 -8
  194. package/dist/docs/references/reference-harness-harness-class.md +34 -42
  195. package/dist/docs/references/reference-logging-pino-logger.md +5 -5
  196. package/dist/docs/references/reference-memory-deleteMessages.md +2 -2
  197. package/dist/docs/references/reference-memory-memory-class.md +12 -14
  198. package/dist/docs/references/reference-memory-observational-memory.md +102 -94
  199. package/dist/docs/references/reference-observability-tracing-configuration.md +27 -10
  200. package/dist/docs/references/reference-observability-tracing-exporters-console-exporter.md +4 -7
  201. package/dist/docs/references/reference-processors-batch-parts-processor.md +8 -10
  202. package/dist/docs/references/reference-processors-language-detector.md +14 -16
  203. package/dist/docs/references/reference-processors-message-history-processor.md +7 -9
  204. package/dist/docs/references/reference-processors-moderation-processor.md +13 -15
  205. package/dist/docs/references/reference-processors-pii-detector.md +14 -16
  206. package/dist/docs/references/reference-processors-processor-interface.md +62 -62
  207. package/dist/docs/references/reference-processors-prompt-injection-detector.md +11 -13
  208. package/dist/docs/references/reference-processors-semantic-recall-processor.md +14 -16
  209. package/dist/docs/references/reference-processors-system-prompt-scrubber.md +12 -14
  210. package/dist/docs/references/reference-processors-token-limiter-processor.md +11 -13
  211. package/dist/docs/references/reference-processors-tool-call-filter.md +5 -7
  212. package/dist/docs/references/reference-processors-tool-search-processor.md +9 -11
  213. package/dist/docs/references/reference-processors-unicode-normalizer.md +8 -10
  214. package/dist/docs/references/reference-processors-working-memory-processor.md +14 -18
  215. package/dist/docs/references/reference-rag-database-config.md +11 -7
  216. package/dist/docs/references/reference-rag-embeddings.md +12 -12
  217. package/dist/docs/references/reference-server-mastra-server.md +10 -10
  218. package/dist/docs/references/reference-server-register-api-route.md +13 -13
  219. package/dist/docs/references/reference-storage-cloudflare-d1.md +5 -5
  220. package/dist/docs/references/reference-storage-composite.md +9 -9
  221. package/dist/docs/references/reference-storage-lance.md +3 -3
  222. package/dist/docs/references/reference-storage-libsql.md +2 -2
  223. package/dist/docs/references/reference-storage-mongodb.md +5 -5
  224. package/dist/docs/references/reference-storage-mssql.md +2 -2
  225. package/dist/docs/references/reference-storage-postgresql.md +25 -25
  226. package/dist/docs/references/reference-storage-upstash.md +3 -3
  227. package/dist/docs/references/reference-streaming-ChunkType.md +251 -59
  228. package/dist/docs/references/reference-streaming-agents-MastraModelOutput.md +86 -16
  229. package/dist/docs/references/reference-streaming-agents-streamLegacy.md +79 -39
  230. package/dist/docs/references/reference-streaming-workflows-resumeStream.md +18 -8
  231. package/dist/docs/references/reference-streaming-workflows-stream.md +21 -9
  232. package/dist/docs/references/reference-streaming-workflows-timeTravelStream.md +4 -4
  233. package/dist/docs/references/reference-tools-create-tool.md +25 -21
  234. package/dist/docs/references/reference-tools-graph-rag-tool.md +16 -18
  235. package/dist/docs/references/reference-tools-mcp-client.md +38 -27
  236. package/dist/docs/references/reference-tools-mcp-server.md +45 -45
  237. package/dist/docs/references/reference-tools-vector-query-tool.md +34 -22
  238. package/dist/docs/references/reference-vectors-libsql.md +31 -31
  239. package/dist/docs/references/reference-vectors-mongodb.md +32 -32
  240. package/dist/docs/references/reference-vectors-pg.md +60 -44
  241. package/dist/docs/references/reference-vectors-upstash.md +25 -25
  242. package/dist/docs/references/reference-voice-composite-voice.md +10 -10
  243. package/dist/docs/references/reference-voice-mastra-voice.md +20 -20
  244. package/dist/docs/references/reference-voice-voice.addInstructions.md +1 -1
  245. package/dist/docs/references/reference-voice-voice.addTools.md +1 -1
  246. package/dist/docs/references/reference-voice-voice.connect.md +3 -3
  247. package/dist/docs/references/reference-voice-voice.events.md +11 -11
  248. package/dist/docs/references/reference-voice-voice.listen.md +9 -9
  249. package/dist/docs/references/reference-voice-voice.on.md +2 -2
  250. package/dist/docs/references/reference-voice-voice.speak.md +11 -11
  251. package/dist/docs/references/reference-workflows-run-methods-cancel.md +2 -2
  252. package/dist/docs/references/reference-workflows-run-methods-restart.md +17 -5
  253. package/dist/docs/references/reference-workflows-run-methods-resume.md +23 -9
  254. package/dist/docs/references/reference-workflows-run-methods-start.md +22 -8
  255. package/dist/docs/references/reference-workflows-run-methods-startAsync.md +12 -6
  256. package/dist/docs/references/reference-workflows-run-methods-timeTravel.md +29 -13
  257. package/dist/docs/references/reference-workflows-run.md +12 -12
  258. package/dist/docs/references/reference-workflows-step.md +24 -26
  259. package/dist/docs/references/reference-workflows-workflow-methods-branch.md +2 -2
  260. package/dist/docs/references/reference-workflows-workflow-methods-commit.md +1 -1
  261. package/dist/docs/references/reference-workflows-workflow-methods-create-run.md +4 -4
  262. package/dist/docs/references/reference-workflows-workflow-methods-dountil.md +3 -3
  263. package/dist/docs/references/reference-workflows-workflow-methods-dowhile.md +3 -3
  264. package/dist/docs/references/reference-workflows-workflow-methods-foreach.md +9 -9
  265. package/dist/docs/references/reference-workflows-workflow-methods-map.md +2 -2
  266. package/dist/docs/references/reference-workflows-workflow-methods-parallel.md +2 -2
  267. package/dist/docs/references/reference-workflows-workflow-methods-sleep.md +2 -2
  268. package/dist/docs/references/reference-workflows-workflow-methods-sleepUntil.md +2 -2
  269. package/dist/docs/references/reference-workflows-workflow-methods-then.md +2 -2
  270. package/dist/docs/references/reference-workflows-workflow.md +40 -50
  271. package/dist/docs/references/reference-workspace-filesystem.md +22 -22
  272. package/dist/docs/references/reference-workspace-local-filesystem.md +35 -35
  273. package/dist/docs/references/reference-workspace-local-sandbox.md +26 -26
  274. package/dist/docs/references/reference-workspace-sandbox.md +8 -8
  275. package/dist/docs/references/reference-workspace-workspace-class.md +30 -34
  276. package/dist/editor/types.d.ts +1 -0
  277. package/dist/editor/types.d.ts.map +1 -1
  278. package/dist/evals/index.cjs +20 -20
  279. package/dist/evals/index.js +3 -3
  280. package/dist/evals/scoreTraces/index.cjs +5 -5
  281. package/dist/evals/scoreTraces/index.js +2 -2
  282. package/dist/harness/harness.d.ts.map +1 -1
  283. package/dist/harness/index.cjs +25 -21
  284. package/dist/harness/index.cjs.map +1 -1
  285. package/dist/harness/index.js +15 -11
  286. package/dist/harness/index.js.map +1 -1
  287. package/dist/index.cjs +2 -2
  288. package/dist/index.js +1 -1
  289. package/dist/integration/index.cjs +2 -2
  290. package/dist/integration/index.js +1 -1
  291. package/dist/llm/index.cjs +12 -12
  292. package/dist/llm/index.js +3 -3
  293. package/dist/llm/model/model.d.ts.map +1 -1
  294. package/dist/llm/model/model.loop.d.ts.map +1 -1
  295. package/dist/llm/model/provider-types.generated.d.ts +5 -1
  296. package/dist/loop/index.cjs +14 -14
  297. package/dist/loop/index.js +1 -1
  298. package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
  299. package/dist/mastra/index.cjs +2 -2
  300. package/dist/mastra/index.js +1 -1
  301. package/dist/memory/index.cjs +14 -14
  302. package/dist/memory/index.js +1 -1
  303. package/dist/models-dev-2FJK72J2.cjs +12 -0
  304. package/dist/{models-dev-UVWCKPA2.cjs.map → models-dev-2FJK72J2.cjs.map} +1 -1
  305. package/dist/models-dev-CMQG6EMO.js +3 -0
  306. package/dist/{models-dev-W3LXZTEB.js.map → models-dev-CMQG6EMO.js.map} +1 -1
  307. package/dist/processor-provider/index.cjs +10 -10
  308. package/dist/processor-provider/index.js +1 -1
  309. package/dist/processors/index.cjs +42 -42
  310. package/dist/processors/index.js +1 -1
  311. package/dist/processors/processors/skills.d.ts +9 -42
  312. package/dist/processors/processors/skills.d.ts.map +1 -1
  313. package/dist/provider-registry-EHOAWHFE.cjs +40 -0
  314. package/dist/{provider-registry-4HLP2JRR.cjs.map → provider-registry-EHOAWHFE.cjs.map} +1 -1
  315. package/dist/provider-registry-LVP6T63V.js +3 -0
  316. package/dist/{provider-registry-K3DWQSMH.js.map → provider-registry-LVP6T63V.js.map} +1 -1
  317. package/dist/provider-registry.json +12 -4
  318. package/dist/relevance/index.cjs +3 -3
  319. package/dist/relevance/index.js +1 -1
  320. package/dist/request-context/index.cjs +4 -4
  321. package/dist/request-context/index.d.ts.map +1 -1
  322. package/dist/request-context/index.js +1 -1
  323. package/dist/storage/base.d.ts +34 -1
  324. package/dist/storage/base.d.ts.map +1 -1
  325. package/dist/storage/constants.cjs +56 -56
  326. package/dist/storage/constants.js +1 -1
  327. package/dist/storage/domains/agents/filesystem.d.ts +28 -0
  328. package/dist/storage/domains/agents/filesystem.d.ts.map +1 -0
  329. package/dist/storage/domains/agents/index.d.ts +1 -0
  330. package/dist/storage/domains/agents/index.d.ts.map +1 -1
  331. package/dist/storage/domains/experiments/inmemory.d.ts.map +1 -1
  332. package/dist/storage/domains/mcp-clients/filesystem.d.ts +28 -0
  333. package/dist/storage/domains/mcp-clients/filesystem.d.ts.map +1 -0
  334. package/dist/storage/domains/mcp-clients/index.d.ts +1 -0
  335. package/dist/storage/domains/mcp-clients/index.d.ts.map +1 -1
  336. package/dist/storage/domains/mcp-servers/filesystem.d.ts +28 -0
  337. package/dist/storage/domains/mcp-servers/filesystem.d.ts.map +1 -0
  338. package/dist/storage/domains/mcp-servers/index.d.ts +1 -0
  339. package/dist/storage/domains/mcp-servers/index.d.ts.map +1 -1
  340. package/dist/storage/domains/prompt-blocks/filesystem.d.ts +28 -0
  341. package/dist/storage/domains/prompt-blocks/filesystem.d.ts.map +1 -0
  342. package/dist/storage/domains/prompt-blocks/index.d.ts +1 -0
  343. package/dist/storage/domains/prompt-blocks/index.d.ts.map +1 -1
  344. package/dist/storage/domains/scorer-definitions/filesystem.d.ts +28 -0
  345. package/dist/storage/domains/scorer-definitions/filesystem.d.ts.map +1 -0
  346. package/dist/storage/domains/scorer-definitions/index.d.ts +1 -0
  347. package/dist/storage/domains/scorer-definitions/index.d.ts.map +1 -1
  348. package/dist/storage/domains/skills/filesystem.d.ts +28 -0
  349. package/dist/storage/domains/skills/filesystem.d.ts.map +1 -0
  350. package/dist/storage/domains/skills/index.d.ts +1 -0
  351. package/dist/storage/domains/skills/index.d.ts.map +1 -1
  352. package/dist/storage/domains/workspaces/filesystem.d.ts +28 -0
  353. package/dist/storage/domains/workspaces/filesystem.d.ts.map +1 -0
  354. package/dist/storage/domains/workspaces/index.d.ts +1 -0
  355. package/dist/storage/domains/workspaces/index.d.ts.map +1 -1
  356. package/dist/storage/filesystem-db.d.ts +82 -0
  357. package/dist/storage/filesystem-db.d.ts.map +1 -0
  358. package/dist/storage/filesystem-versioned.d.ts +148 -0
  359. package/dist/storage/filesystem-versioned.d.ts.map +1 -0
  360. package/dist/storage/filesystem.d.ts +39 -0
  361. package/dist/storage/filesystem.d.ts.map +1 -0
  362. package/dist/storage/git-history.d.ts +68 -0
  363. package/dist/storage/git-history.d.ts.map +1 -0
  364. package/dist/storage/index.cjs +208 -160
  365. package/dist/storage/index.d.ts +4 -0
  366. package/dist/storage/index.d.ts.map +1 -1
  367. package/dist/storage/index.js +2 -2
  368. package/dist/storage/types.d.ts +1 -0
  369. package/dist/storage/types.d.ts.map +1 -1
  370. package/dist/stream/RunOutput.d.ts +1 -1
  371. package/dist/stream/aisdk/v5/output-helpers.d.ts +6 -6
  372. package/dist/stream/base/output.d.ts +3 -3
  373. package/dist/stream/base/schema.d.ts +1 -1
  374. package/dist/stream/index.cjs +11 -11
  375. package/dist/stream/index.js +2 -2
  376. package/dist/test-utils/llm-mock.cjs +4 -4
  377. package/dist/test-utils/llm-mock.js +1 -1
  378. package/dist/tool-loop-agent/index.cjs +4 -4
  379. package/dist/tool-loop-agent/index.js +1 -1
  380. package/dist/tools/index.cjs +6 -6
  381. package/dist/tools/index.js +1 -1
  382. package/dist/tools/is-vercel-tool.cjs +2 -2
  383. package/dist/tools/is-vercel-tool.js +1 -1
  384. package/dist/tools/tool-builder/builder.d.ts.map +1 -1
  385. package/dist/tools/tool.d.ts +6 -0
  386. package/dist/tools/tool.d.ts.map +1 -1
  387. package/dist/tools/types.d.ts +27 -0
  388. package/dist/tools/types.d.ts.map +1 -1
  389. package/dist/utils.cjs +23 -23
  390. package/dist/utils.js +1 -1
  391. package/dist/vector/index.cjs +9 -9
  392. package/dist/vector/index.js +2 -2
  393. package/dist/workflows/evented/index.cjs +10 -10
  394. package/dist/workflows/evented/index.js +1 -1
  395. package/dist/workflows/index.cjs +25 -25
  396. package/dist/workflows/index.js +1 -1
  397. package/dist/workspace/index.cjs +70 -66
  398. package/dist/workspace/index.d.ts +1 -0
  399. package/dist/workspace/index.d.ts.map +1 -1
  400. package/dist/workspace/index.js +1 -1
  401. package/dist/workspace/sandbox/execa.d.ts +9 -0
  402. package/dist/workspace/sandbox/execa.d.ts.map +1 -0
  403. package/dist/workspace/sandbox/local-process-manager.d.ts.map +1 -1
  404. package/dist/workspace/skills/index.d.ts +1 -0
  405. package/dist/workspace/skills/index.d.ts.map +1 -1
  406. package/dist/workspace/skills/tools.d.ts +36 -0
  407. package/dist/workspace/skills/tools.d.ts.map +1 -0
  408. package/dist/workspace/tools/execute-command.d.ts.map +1 -1
  409. package/dist/workspace/tools/output-helpers.d.ts +4 -3
  410. package/dist/workspace/tools/output-helpers.d.ts.map +1 -1
  411. package/package.json +9 -9
  412. package/src/llm/model/provider-types.generated.d.ts +5 -1
  413. package/dist/chunk-3ZF7IC6Q.cjs.map +0 -1
  414. package/dist/chunk-4BXXAZ75.js.map +0 -1
  415. package/dist/chunk-4P35AVPE.cjs.map +0 -1
  416. package/dist/chunk-BFV3GSGS.js.map +0 -1
  417. package/dist/chunk-CCLV5CAA.js.map +0 -1
  418. package/dist/chunk-D4M6E4OQ.cjs.map +0 -1
  419. package/dist/chunk-D6HO5QAM.cjs.map +0 -1
  420. package/dist/chunk-G5R2755Q.cjs.map +0 -1
  421. package/dist/chunk-GJTLWOKJ.js.map +0 -1
  422. package/dist/chunk-H5S4PS44.cjs.map +0 -1
  423. package/dist/chunk-IOY7Y5GV.js.map +0 -1
  424. package/dist/chunk-JIRB5LX4.js.map +0 -1
  425. package/dist/chunk-MVYP55NA.js.map +0 -1
  426. package/dist/chunk-PKORY4ZZ.cjs.map +0 -1
  427. package/dist/chunk-QNXY3J6B.cjs.map +0 -1
  428. package/dist/chunk-SEKQJ447.js.map +0 -1
  429. package/dist/chunk-VDKWYUGC.cjs.map +0 -1
  430. package/dist/chunk-VWAK25TU.js.map +0 -1
  431. package/dist/chunk-WYPSC6CO.js.map +0 -1
  432. package/dist/chunk-YIJZBU54.cjs.map +0 -1
  433. package/dist/chunk-ZBESCKPX.cjs.map +0 -1
  434. package/dist/chunk-ZVWVQ6MG.js.map +0 -1
  435. package/dist/models-dev-UVWCKPA2.cjs +0 -12
  436. package/dist/models-dev-W3LXZTEB.js +0 -3
  437. package/dist/provider-registry-4HLP2JRR.cjs +0 -40
  438. package/dist/provider-registry-K3DWQSMH.js +0 -3
@@ -45,139 +45,273 @@ console.log(`Remaining requests: ${remainingRequests}, Remaining tokens: ${remai
45
45
 
46
46
  ## Parameters
47
47
 
48
- **messages:** (`string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[]`): The messages to send to the agent. Can be a single string, array of strings, or structured message objects.
48
+ **messages** (`string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[]`): The messages to send to the agent. Can be a single string, array of strings, or structured message objects.
49
49
 
50
- **options?:** (`AgentExecutionOptions<Output, Format>`): Optional configuration for the generation process.
50
+ **options** (`AgentExecutionOptions<Output, Format>`): Optional configuration for the generation process.
51
51
 
52
- ### Options
52
+ **options.maxSteps** (`number`): Maximum number of steps to run during execution.
53
53
 
54
- **maxSteps?:** (`number`): Maximum number of steps to run during execution.
54
+ **options.stopWhen** (`LoopOptions['stopWhen']`): Conditions for stopping execution (e.g., step count, token limit).
55
55
 
56
- **stopWhen?:** (`LoopOptions['stopWhen']`): Conditions for stopping execution (e.g., step count, token limit).
56
+ **options.onIterationComplete** (`(context: IterationCompleteContext) => { continue?: boolean; feedback?: string } | void | Promise<{ continue?: boolean; feedback?: string } | void>`): Callback function called after each iteration completes. Use this to monitor progress, provide feedback to guide the agent, or stop execution early. The callback receives context about the iteration including the current text, tool calls, and finish reason.
57
57
 
58
- **onIterationComplete?:** (`(context: IterationCompleteContext) => { continue?: boolean; feedback?: string } | void | Promise<{ continue?: boolean; feedback?: string } | void>`): context.iteration:numberCurrent iteration number (1-based).context.maxIterations:number | undefinedMaximum iterations allowed (if set).context.text:stringThe text response from this iteration.context.isFinal:booleanWhether this is the final iteration.context.finishReason:stringReason why this iteration finished (e.g., 'stop', 'length', 'tool-calls').context.toolCalls:ToolCall\[]Tool calls made in this iteration.context.messages:MastraDBMessage\[]All messages accumulated so far.return.continue?:booleanSet to false to stop execution early.return.feedback?:stringFeedback message to guide the agent's next iteration.
58
+ **options.onIterationComplete.context.iteration** (`number`): Current iteration number (1-based).
59
59
 
60
- **isTaskComplete?:** (`IsTaskCompleteConfig`): scorers:MastraScorer\[]Array of scorers that evaluate task completion. Each scorer returns 0 (failed) or 1 (passed).strategy?:'all' | 'any'Strategy for combining scorer results. 'all' requires all scorers to pass, 'any' requires at least one.onComplete?:(result: IsTaskCompleteRunResult) => void | Promise\<void>Callback called when the task completion check finishes. Receives the result with individual scorer scores.parallel?:booleanWhether to run scorers in parallel.timeout?:numberMaximum time in milliseconds to wait for all scorers to complete.
60
+ **options.onIterationComplete.context.maxIterations** (`number | undefined`): Maximum iterations allowed (if set).
61
61
 
62
- **delegation?:** (`DelegationConfig`): onDelegationStart?:(context: DelegationStartContext) => DelegationStartResult | void | Promise\<DelegationStartResult | void>Called before delegating to a subagent. Use this to modify the delegation parameters or reject the delegation entirely.onDelegationComplete?:(context: DelegationCompleteContext) => { feedback?: string } | void | Promise<{ feedback?: string } | void>Called after a subagent delegation completes. The context includes a \`bail()\` method to stop further execution, and you can return \`{ feedback }\` to guide the supervisor's next action. Feedback is saved to supervisor memory as an assistant message.messageFilter?:(context: MessageFilterContext) => MastraDBMessage\[] | Promise\<MastraDBMessage\[]>Callback function called before delegating to a subagent. Use this to filter the messages that are passed to the subagent.
62
+ **options.onIterationComplete.context.text** (`string`): The text response from this iteration.
63
63
 
64
- **scorers?:** (`MastraScorers | Record<string, { scorer: MastraScorer['name']; sampling?: ScoringSamplingConfig }>`): scorer:stringName of the scorer to use.sampling?:ScoringSamplingConfigSampling configuration for the scorer.type:'none' | 'ratio'Type of sampling strategy. Use 'none' to disable sampling or 'ratio' for percentage-based sampling.rate?:numberSampling rate (0-1). Required when type is 'ratio'.
64
+ **options.onIterationComplete.context.isFinal** (`boolean`): Whether this is the final iteration.
65
65
 
66
- **returnScorerData?:** (`boolean`): Whether to return detailed scoring data in the response.
66
+ **options.onIterationComplete.context.finishReason** (`string`): Reason why this iteration finished (e.g., 'stop', 'length', 'tool-calls').
67
67
 
68
- **onChunk?:** (`(chunk: ChunkType) => Promise<void> | void`): Callback function called for each chunk during generation.
68
+ **options.onIterationComplete.context.toolCalls** (`ToolCall[]`): Tool calls made in this iteration.
69
69
 
70
- **onError?:** (`({ error }: { error: Error | string }) => Promise<void> | void`): Callback function called when an error occurs during generation.
70
+ **options.onIterationComplete.context.messages** (`MastraDBMessage[]`): All messages accumulated so far.
71
71
 
72
- **onAbort?:** (`(event: any) => Promise<void> | void`): Callback function called when the generation is aborted.
72
+ **options.onIterationComplete.return.continue** (`boolean`): Set to false to stop execution early.
73
73
 
74
- **activeTools?:** (`Array<keyof ToolSet> | undefined`): Array of tool names that should be active during execution. If undefined, all available tools are active.
74
+ **options.onIterationComplete.return.feedback** (`string`): Feedback message to guide the agent's next iteration.
75
75
 
76
- **abortSignal?:** (`AbortSignal`): Signal object that allows you to abort the agent's execution. When the signal is aborted, all ongoing operations will be terminated.
76
+ **options.isTaskComplete** (`IsTaskCompleteConfig`): Task completion scoring configuration that validates whether the task is complete. Uses Mastra's evaluation scorers to automatically check if the agent's response satisfies the completion criteria.
77
77
 
78
- **prepareStep?:** (`PrepareStepFunction`): Callback function called before each step of multi-step execution.
78
+ **options.isTaskComplete.scorers** (`MastraScorer[]`): Array of scorers that evaluate task completion. Each scorer returns 0 (failed) or 1 (passed).
79
79
 
80
- **requireToolApproval?:** (`boolean`): When true, all tool calls require explicit approval before execution. The generate() method will return with \`finishReason: 'suspended'\` and include a \`suspendPayload\` with tool call details (\`toolCallId\`, \`toolName\`, \`args\`). Use \`approveToolCallGenerate()\` or \`declineToolCallGenerate()\` to proceed. See \[Agent Approval]\(/docs/agents/agent-approval#tool-approval-with-generate) for details.
80
+ **options.isTaskComplete.strategy** (`'all' | 'any'`): Strategy for combining scorer results. 'all' requires all scorers to pass, 'any' requires at least one.
81
81
 
82
- **autoResumeSuspendedTools?:** (`boolean`): When true, automatically resumes suspended tools when the user sends a new message on the same thread. The agent extracts \`resumeData\` from the user's message based on the tool's \`resumeSchema\`. Requires memory to be configured.
82
+ **options.isTaskComplete.onComplete** (`(result: IsTaskCompleteRunResult) => void | Promise<void>`): Callback called when the task completion check finishes. Receives the result with individual scorer scores.
83
83
 
84
- **toolCallConcurrency?:** (`number`): Maximum number of tool calls to execute concurrently. Defaults to 1 when approval may be required, otherwise 10.
84
+ **options.isTaskComplete.parallel** (`boolean`): Whether to run scorers in parallel.
85
85
 
86
- **context?:** (`ModelMessage[]`): Additional context messages to provide to the agent.
86
+ **options.isTaskComplete.timeout** (`number`): Maximum time in milliseconds to wait for all scorers to complete.
87
87
 
88
- **structuredOutput?:** (`StructuredOutputOptions<S extends ZodTypeAny = ZodTypeAny>`): schema:z.ZodSchema\<S>Zod schema defining the expected output structure.model?:MastraLanguageModelLanguage model to use for structured output generation. If provided, enables the agent to respond in multi step with tool calls, text, and structured outputerrorStrategy?:'strict' | 'warn' | 'fallback'Strategy for handling schema validation errors. 'strict' throws errors, 'warn' logs warnings, 'fallback' uses fallback values.fallbackValue?:\<S extends ZodTypeAny>Fallback value to use when schema validation fails and errorStrategy is 'fallback'.instructions?:stringAdditional instructions for the structured output model.jsonPromptInjection?:booleanInjects system prompt into the main agent instructing it to return structured output, useful for when a model does not natively support structured outputs.logger?:IMastraLoggerOptional logger instance for structured logging during output generation.providerOptions?:ProviderOptionsProvider-specific options passed to the internal structuring agent. Use this to control model behavior like reasoning effort for thinking models (e.g., \`{ openai: { reasoningEffort: 'low' } }\`).
88
+ **options.delegation** (`DelegationConfig`): Configuration for subagent delegation. Use this to control and monitor when the agent delegates tasks to other agents, including the ability to modify, reject delegations, and provide feedback to guide the supervisor.
89
89
 
90
- **outputProcessors?:** (`OutputProcessorOrWorkflow[]`): Output processors to use for this execution (overrides agent's default).
90
+ **options.delegation.onDelegationStart** (`(context: DelegationStartContext) => DelegationStartResult | void | Promise<DelegationStartResult | void>`): Called before delegating to a subagent. Use this to modify the delegation parameters or reject the delegation entirely.
91
91
 
92
- **maxProcessorRetries?:** (`number`): Maximum number of times processors can trigger a retry for this generation. Overrides agent's default maxProcessorRetries.
92
+ **options.delegation.onDelegationComplete** (`(context: DelegationCompleteContext) => { feedback?: string } | void | Promise<{ feedback?: string } | void>`): Called after a subagent delegation completes. The context includes a \`bail()\` method to stop further execution, and you can return \`{ feedback }\` to guide the supervisor's next action. Feedback is saved to supervisor memory as an assistant message.
93
93
 
94
- **inputProcessors?:** (`InputProcessorOrWorkflow[]`): Input processors to use for this execution (overrides agent's default).
94
+ **options.delegation.messageFilter** (`(context: MessageFilterContext) => MastraDBMessage[] | Promise<MastraDBMessage[]>`): Callback function called before delegating to a subagent. Use this to filter the messages that are passed to the subagent.
95
95
 
96
- **instructions?:** (`string | string[] | CoreSystemMessage | SystemModelMessage | CoreSystemMessage[] | SystemModelMessage[]`): Custom instructions that override the agent's default instructions for this execution. Can be a single string, message object, or array of either.
96
+ **options.scorers** (`MastraScorers | Record<string, { scorer: MastraScorer['name']; sampling?: ScoringSamplingConfig }>`): Evaluation scorers to run on the execution results.
97
97
 
98
- **system?:** (`string | string[] | CoreSystemMessage | SystemModelMessage | CoreSystemMessage[] | SystemModelMessage[]`): Custom system message(s) to include in the prompt. Can be a single string, message object, or array of either. System messages provide additional context or behavior instructions that supplement the agent's main instructions.
98
+ **options.scorers.scorer** (`string`): Name of the scorer to use.
99
99
 
100
- **output?:** (`Zod schema | JsonSchema7`): \*\*Deprecated.\*\* Use structuredOutput without a model to achieve the same thing. Defines the expected structure of the output. Can be a JSON Schema object or a Zod schema.
100
+ **options.scorers.sampling** (`ScoringSamplingConfig`): Sampling configuration for the scorer.
101
101
 
102
- **memory?:** (`object`): thread:string | { id: string; metadata?: Record\<string, any>, title?: string }Thread identifier for conversation continuity. Can be a string ID or an object with ID and optional metadata/title.resource:stringResource identifier for organizing conversations by user, session, or context.options?:MemoryConfigAdditional memory configuration options including lastMessages, readOnly, semanticRecall, and workingMemory.
102
+ **options.scorers.sampling.type** (`'none' | 'ratio'`): Type of sampling strategy. Use 'none' to disable sampling or 'ratio' for percentage-based sampling.
103
103
 
104
- **onFinish?:** (`LoopConfig['onFinish']`): Callback fired when generation completes.
104
+ **options.scorers.sampling.rate** (`number`): Sampling rate (0-1). Required when type is 'ratio'.
105
105
 
106
- **onStepFinish?:** (`LoopConfig['onStepFinish']`): Callback fired after each generation step.
106
+ **options.returnScorerData** (`boolean`): Whether to return detailed scoring data in the response.
107
107
 
108
- **telemetry?:** (`TelemetrySettings`): isEnabled?:booleanWhether telemetry collection is enabled.recordInputs?:booleanWhether to record input data in telemetry.recordOutputs?:booleanWhether to record output data in telemetry.functionId?:stringIdentifier for the function being executed.
108
+ **options.onChunk** (`(chunk: ChunkType) => Promise<void> | void`): Callback function called for each chunk during generation.
109
109
 
110
- **modelSettings?:** (`CallSettings`): temperature?:numberControls randomness in generation (0-2). Higher values make output more random.maxOutputTokens?:numberMaximum number of tokens to generate in the response. Note: Use maxOutputTokens (not maxTokens) as per AI SDK v5 convention.maxRetries?:numberMaximum number of retry attempts for failed requests.topP?:numberNucleus sampling parameter (0-1). Controls diversity of generated text.topK?:numberTop-k sampling parameter. Limits vocabulary to k most likely tokens.presencePenalty?:numberPenalty for token presence (-2 to 2). Reduces repetition.frequencyPenalty?:numberPenalty for token frequency (-2 to 2). Reduces repetition of frequent tokens.stopSequences?:string\[]Stop sequences. If set, the model will stop generating text when one of the stop sequences is generated.
110
+ **options.onError** (`({ error }: { error: Error | string }) => Promise<void> | void`): Callback function called when an error occurs during generation.
111
111
 
112
- **toolChoice?:** (`'auto' | 'none' | 'required' | { type: 'tool'; toolName: string }`): 'auto':stringLet the model decide when to use tools (default).'none':stringDisable tool usage entirely.'required':stringForce the model to use at least one tool.{ type: 'tool'; toolName: string }:objectForce the model to use a specific tool.
112
+ **options.onAbort** (`(event: any) => Promise<void> | void`): Callback function called when the generation is aborted.
113
113
 
114
- **toolsets?:** (`ToolsetsInput`): Additional tool sets that can be used for this execution.
114
+ **options.activeTools** (`Array<keyof ToolSet> | undefined`): Array of tool names that should be active during execution. If undefined, all available tools are active.
115
115
 
116
- **clientTools?:** (`ToolsInput`): Client-side tools available during execution.
116
+ **options.abortSignal** (`AbortSignal`): Signal object that allows you to abort the agent's execution. When the signal is aborted, all ongoing operations will be terminated.
117
117
 
118
- **savePerStep?:** (`boolean`): Save messages incrementally after each generation step completes (default: false).
118
+ **options.prepareStep** (`PrepareStepFunction`): Callback function called before each step of multi-step execution.
119
119
 
120
- **providerOptions?:** (`Record<string, Record<string, JSONValue>>`): openai?:Record\<string, JSONValue>OpenAI-specific options like reasoningEffort, responseFormat, etc.anthropic?:Record\<string, JSONValue>Anthropic-specific options like maxTokens, etc.google?:Record\<string, JSONValue>Google-specific options.\[providerName]?:Record\<string, JSONValue>Any provider-specific options.
120
+ **options.requireToolApproval** (`boolean`): When true, all tool calls require explicit approval before execution. The generate() method will return with \`finishReason: 'suspended'\` and include a \`suspendPayload\` with tool call details (\`toolCallId\`, \`toolName\`, \`args\`). Use \`approveToolCallGenerate()\` or \`declineToolCallGenerate()\` to proceed. See \[Agent Approval]\(/docs/agents/agent-approval#tool-approval-with-generate) for details.
121
121
 
122
- **runId?:** (`string`): Unique identifier for this execution run.
122
+ **options.autoResumeSuspendedTools** (`boolean`): When true, automatically resumes suspended tools when the user sends a new message on the same thread. The agent extracts \`resumeData\` from the user's message based on the tool's \`resumeSchema\`. Requires memory to be configured.
123
123
 
124
- **requestContext?:** (`RequestContext`): Request Context containing dynamic configuration and state.
124
+ **options.toolCallConcurrency** (`number`): Maximum number of tool calls to execute concurrently. Defaults to 1 when approval may be required, otherwise 10.
125
125
 
126
- **tracingContext?:** (`TracingContext`): currentSpan?:SpanCurrent span for creating child spans and adding metadata. Use this to create custom child spans or update span attributes during execution.
126
+ **options.context** (`ModelMessage[]`): Additional context messages to provide to the agent.
127
127
 
128
- **tracingOptions?:** (`TracingOptions`): metadata?:Record\<string, any>Metadata to add to the root trace span. Useful for adding custom attributes like user IDs, session IDs, or feature flags.requestContextKeys?:string\[]Additional RequestContext keys to extract as metadata for this trace. Supports dot notation for nested values (e.g., 'user.id').traceId?:stringTrace ID to use for this execution (1-32 hexadecimal characters). If provided, this trace will be part of the specified trace.parentSpanId?:stringParent span ID to use for this execution (1-16 hexadecimal characters). If provided, the root span will be created as a child of this span.tags?:string\[]Tags to apply to this trace. String labels for categorizing and filtering traces.
128
+ **options.structuredOutput** (`StructuredOutputOptions<S extends ZodTypeAny = ZodTypeAny>`): Options to fine tune your structured output generation.
129
129
 
130
- **includeRawChunks?:** (`boolean`): Whether to include raw chunks in the stream output. Not available on all model providers.
130
+ **options.structuredOutput.schema** (`z.ZodSchema<S>`): Zod schema defining the expected output structure.
131
+
132
+ **options.structuredOutput.model** (`MastraLanguageModel`): Language model to use for structured output generation. If provided, enables the agent to respond in multi step with tool calls, text, and structured output
133
+
134
+ **options.structuredOutput.errorStrategy** (`'strict' | 'warn' | 'fallback'`): Strategy for handling schema validation errors. 'strict' throws errors, 'warn' logs warnings, 'fallback' uses fallback values.
135
+
136
+ **options.structuredOutput.fallbackValue** (`<S extends ZodTypeAny>`): Fallback value to use when schema validation fails and errorStrategy is 'fallback'.
137
+
138
+ **options.structuredOutput.instructions** (`string`): Additional instructions for the structured output model.
139
+
140
+ **options.structuredOutput.jsonPromptInjection** (`boolean`): Injects system prompt into the main agent instructing it to return structured output, useful for when a model does not natively support structured outputs.
141
+
142
+ **options.structuredOutput.logger** (`IMastraLogger`): Optional logger instance for structured logging during output generation.
143
+
144
+ **options.structuredOutput.providerOptions** (`ProviderOptions`): Provider-specific options passed to the internal structuring agent. Use this to control model behavior like reasoning effort for thinking models (e.g., \`{ openai: { reasoningEffort: 'low' } }\`).
145
+
146
+ **options.outputProcessors** (`OutputProcessorOrWorkflow[]`): Output processors to use for this execution (overrides agent's default).
147
+
148
+ **options.maxProcessorRetries** (`number`): Maximum number of times processors can trigger a retry for this generation. Overrides agent's default maxProcessorRetries.
149
+
150
+ **options.inputProcessors** (`InputProcessorOrWorkflow[]`): Input processors to use for this execution (overrides agent's default).
151
+
152
+ **options.instructions** (`string | string[] | CoreSystemMessage | SystemModelMessage | CoreSystemMessage[] | SystemModelMessage[]`): Custom instructions that override the agent's default instructions for this execution. Can be a single string, message object, or array of either.
153
+
154
+ **options.system** (`string | string[] | CoreSystemMessage | SystemModelMessage | CoreSystemMessage[] | SystemModelMessage[]`): Custom system message(s) to include in the prompt. Can be a single string, message object, or array of either. System messages provide additional context or behavior instructions that supplement the agent's main instructions.
155
+
156
+ **options.output** (`Zod schema | JsonSchema7`): \*\*Deprecated.\*\* Use structuredOutput without a model to achieve the same thing. Defines the expected structure of the output. Can be a JSON Schema object or a Zod schema.
157
+
158
+ **options.memory** (`object`): Memory configuration for conversation persistence and retrieval.
159
+
160
+ **options.memory.thread** (`string | { id: string; metadata?: Record<string, any>, title?: string }`): Thread identifier for conversation continuity. Can be a string ID or an object with ID and optional metadata/title.
161
+
162
+ **options.memory.resource** (`string`): Resource identifier for organizing conversations by user, session, or context.
163
+
164
+ **options.memory.options** (`MemoryConfig`): Additional memory configuration options including lastMessages, readOnly, semanticRecall, and workingMemory.
165
+
166
+ **options.onFinish** (`LoopConfig['onFinish']`): Callback fired when generation completes.
167
+
168
+ **options.onStepFinish** (`LoopConfig['onStepFinish']`): Callback fired after each generation step.
169
+
170
+ **options.telemetry** (`TelemetrySettings`): Settings for OTLP telemetry collection during generation (not Tracing).
171
+
172
+ **options.telemetry.isEnabled** (`boolean`): Whether telemetry collection is enabled.
173
+
174
+ **options.telemetry.recordInputs** (`boolean`): Whether to record input data in telemetry.
175
+
176
+ **options.telemetry.recordOutputs** (`boolean`): Whether to record output data in telemetry.
177
+
178
+ **options.telemetry.functionId** (`string`): Identifier for the function being executed.
179
+
180
+ **options.modelSettings** (`CallSettings`): Model-specific settings like temperature, maxOutputTokens, topP, etc. These settings control how the language model generates responses.
181
+
182
+ **options.modelSettings.temperature** (`number`): Controls randomness in generation (0-2). Higher values make output more random.
183
+
184
+ **options.modelSettings.maxOutputTokens** (`number`): Maximum number of tokens to generate in the response. Note: Use maxOutputTokens (not maxTokens) as per AI SDK v5 convention.
185
+
186
+ **options.modelSettings.maxRetries** (`number`): Maximum number of retry attempts for failed requests.
187
+
188
+ **options.modelSettings.topP** (`number`): Nucleus sampling parameter (0-1). Controls diversity of generated text.
189
+
190
+ **options.modelSettings.topK** (`number`): Top-k sampling parameter. Limits vocabulary to k most likely tokens.
191
+
192
+ **options.modelSettings.presencePenalty** (`number`): Penalty for token presence (-2 to 2). Reduces repetition.
193
+
194
+ **options.modelSettings.frequencyPenalty** (`number`): Penalty for token frequency (-2 to 2). Reduces repetition of frequent tokens.
195
+
196
+ **options.modelSettings.stopSequences** (`string[]`): Stop sequences. If set, the model will stop generating text when one of the stop sequences is generated.
197
+
198
+ **options.toolChoice** (`'auto' | 'none' | 'required' | { type: 'tool'; toolName: string }`): Controls how tools are selected during generation.
199
+
200
+ **options.toolChoice.'auto'** (`string`): Let the model decide when to use tools (default).
201
+
202
+ **options.toolChoice.'none'** (`string`): Disable tool usage entirely.
203
+
204
+ **options.toolChoice.'required'** (`string`): Force the model to use at least one tool.
205
+
206
+ **options.toolChoice.{ type: 'tool'; toolName: string }** (`object`): Force the model to use a specific tool.
207
+
208
+ **options.toolsets** (`ToolsetsInput`): Additional tool sets that can be used for this execution.
209
+
210
+ **options.clientTools** (`ToolsInput`): Client-side tools available during execution.
211
+
212
+ **options.savePerStep** (`boolean`): Save messages incrementally after each generation step completes (default: false).
213
+
214
+ **options.providerOptions** (`Record<string, Record<string, JSONValue>>`): Provider-specific options passed to the language model.
215
+
216
+ **options.providerOptions.openai** (`Record<string, JSONValue>`): OpenAI-specific options like reasoningEffort, responseFormat, etc.
217
+
218
+ **options.providerOptions.anthropic** (`Record<string, JSONValue>`): Anthropic-specific options like maxTokens, etc.
219
+
220
+ **options.providerOptions.google** (`Record<string, JSONValue>`): Google-specific options.
221
+
222
+ **options.providerOptions.\[providerName]** (`Record<string, JSONValue>`): Any provider-specific options.
223
+
224
+ **options.runId** (`string`): Unique identifier for this execution run.
225
+
226
+ **options.requestContext** (`RequestContext`): Request Context containing dynamic configuration and state.
227
+
228
+ **options.tracingContext** (`TracingContext`): Tracing context for creating child spans and adding metadata. Automatically injected when using Mastra's tracing system.
229
+
230
+ **options.tracingContext.currentSpan** (`Span`): Current span for creating child spans and adding metadata. Use this to create custom child spans or update span attributes during execution.
231
+
232
+ **options.tracingOptions** (`TracingOptions`): Options for Tracing configuration.
233
+
234
+ **options.tracingOptions.metadata** (`Record<string, any>`): Metadata to add to the root trace span. Useful for adding custom attributes like user IDs, session IDs, or feature flags.
235
+
236
+ **options.tracingOptions.requestContextKeys** (`string[]`): Additional RequestContext keys to extract as metadata for this trace. Supports dot notation for nested values (e.g., 'user.id').
237
+
238
+ **options.tracingOptions.traceId** (`string`): Trace ID to use for this execution (1-32 hexadecimal characters). If provided, this trace will be part of the specified trace.
239
+
240
+ **options.tracingOptions.parentSpanId** (`string`): Parent span ID to use for this execution (1-16 hexadecimal characters). If provided, the root span will be created as a child of this span.
241
+
242
+ **options.tracingOptions.tags** (`string[]`): Tags to apply to this trace. String labels for categorizing and filtering traces.
243
+
244
+ **options.includeRawChunks** (`boolean`): Whether to include raw chunks in the stream output. Not available on all model providers.
131
245
 
132
246
  ## Returns
133
247
 
134
- **result:** (`Awaited<ReturnType<MastraModelOutput<Output>['getFullOutput']>>`): Returns the full output of the generation process including text, object (if structured output), tool calls, tool results, usage statistics, and step information.
248
+ **result** (`Awaited<ReturnType<MastraModelOutput<Output>['getFullOutput']>>`): Returns the full output of the generation process including text, object (if structured output), tool calls, tool results, usage statistics, and step information.
249
+
250
+ **text** (`string`): The generated text response from the agent.
251
+
252
+ **object** (`Output | undefined`): The structured output object if structuredOutput was provided, validated against the schema.
253
+
254
+ **toolCalls** (`ToolCall[]`): Array of tool calls made during generation.
255
+
256
+ **toolResults** (`ToolResult[]`): Array of results from tool executions.
257
+
258
+ **usage** (`TokenUsage`): Token usage statistics for the generation.
259
+
260
+ **steps** (`Step[]`): Array of execution steps, useful for debugging multi-step generations.
261
+
262
+ **finishReason** (`string`): The reason generation finished. Values include 'stop' (normal completion), 'tool-calls' (ended with tool calls), 'suspended' (waiting for tool approval), or 'error' (error occurred).
263
+
264
+ **response** (`object`): Response metadata from the model provider. Useful for accessing rate limit headers and request IDs.
265
+
266
+ **response.id** (`string`): Response ID from the model provider.
267
+
268
+ **response.timestamp** (`Date`): Timestamp when the response was generated.
135
269
 
136
- **text:** (`string`): The generated text response from the agent.
270
+ **response.modelId** (`string`): Model identifier used for this response.
137
271
 
138
- **object?:** (`Output | undefined`): The structured output object if structuredOutput was provided, validated against the schema.
272
+ **response.headers** (`Record<string, string>`): HTTP response headers from the model provider. Contains rate limit information (e.g., \`anthropic-ratelimit-requests-remaining\`, \`x-ratelimit-remaining-tokens\`) and other provider-specific metadata.
139
273
 
140
- **toolCalls:** (`ToolCall[]`): Array of tool calls made during generation.
274
+ **response.messages** (`ResponseMessage[]`): Response messages in model format.
141
275
 
142
- **toolResults:** (`ToolResult[]`): Array of results from tool executions.
276
+ **response.uiMessages** (`UIMessage[]`): Response messages in UI format, includes any metadata added by output processors.
143
277
 
144
- **usage:** (`TokenUsage`): Token usage statistics for the generation.
278
+ **request** (`object`): The request that was sent to the model.
145
279
 
146
- **steps:** (`Step[]`): Array of execution steps, useful for debugging multi-step generations.
280
+ **request.body** (`unknown`): The request body sent to the model provider.
147
281
 
148
- **finishReason:** (`string`): The reason generation finished. Values include 'stop' (normal completion), 'tool-calls' (ended with tool calls), 'suspended' (waiting for tool approval), or 'error' (error occurred).
282
+ **warnings** (`LanguageModelWarning[]`): Any warnings from the model provider during generation.
149
283
 
150
- **response:** (`object`): id?:stringResponse ID from the model provider.timestamp?:DateTimestamp when the response was generated.modelId?:stringModel identifier used for this response.headers?:Record\<string, string>HTTP response headers from the model provider. Contains rate limit information (e.g., \`anthropic-ratelimit-requests-remaining\`, \`x-ratelimit-remaining-tokens\`) and other provider-specific metadata.messages?:ResponseMessage\[]Response messages in model format.uiMessages?:UIMessage\[]Response messages in UI format, includes any metadata added by output processors.
284
+ **providerMetadata** (`Record<string, unknown>`): Provider-specific metadata returned with the response.
151
285
 
152
- **request?:** (`object`): body?:unknownThe request body sent to the model provider.
286
+ **reasoning** (`ReasoningChunk[]`): Reasoning details from models that support reasoning (e.g., OpenAI o1 series).
153
287
 
154
- **warnings?:** (`LanguageModelWarning[]`): Any warnings from the model provider during generation.
288
+ **reasoningText** (`string`): Combined reasoning text from reasoning models.
155
289
 
156
- **providerMetadata?:** (`Record<string, unknown>`): Provider-specific metadata returned with the response.
290
+ **sources** (`SourceChunk[]`): Sources referenced by the model during generation.
157
291
 
158
- **reasoning?:** (`ReasoningChunk[]`): Reasoning details from models that support reasoning (e.g., OpenAI o1 series).
292
+ **files** (`FileChunk[]`): Files generated by the model.
159
293
 
160
- **reasoningText?:** (`string`): Combined reasoning text from reasoning models.
294
+ **suspendPayload** (`object`): Present when \`finishReason\` is 'suspended'. Contains tool call details needed to approve or decline the pending tool call.
161
295
 
162
- **sources?:** (`SourceChunk[]`): Sources referenced by the model during generation.
296
+ **suspendPayload.toolCallId** (`string`): Unique identifier for the pending tool call.
163
297
 
164
- **files?:** (`FileChunk[]`): Files generated by the model.
298
+ **suspendPayload.toolName** (`string`): Name of the tool that requires approval.
165
299
 
166
- **suspendPayload?:** (`object`): toolCallId:stringUnique identifier for the pending tool call.toolName:stringName of the tool that requires approval.args:Record\<string, any>Arguments that will be passed to the tool.
300
+ **suspendPayload.args** (`Record<string, any>`): Arguments that will be passed to the tool.
167
301
 
168
- **runId?:** (`string`): Unique identifier for this execution run. Required when calling \`approveToolCallGenerate()\` or \`declineToolCallGenerate()\` to resume a suspended execution.
302
+ **runId** (`string`): Unique identifier for this execution run. Required when calling \`approveToolCallGenerate()\` or \`declineToolCallGenerate()\` to resume a suspended execution.
169
303
 
170
- **traceId?:** (`string`): The trace ID associated with this execution when Tracing is enabled. Use this to correlate logs and debug execution flow.
304
+ **traceId** (`string`): The trace ID associated with this execution when Tracing is enabled. Use this to correlate logs and debug execution flow.
171
305
 
172
- **messages:** (`MastraDBMessage[]`): All messages from this execution including input, memory history, and response.
306
+ **messages** (`MastraDBMessage[]`): All messages from this execution including input, memory history, and response.
173
307
 
174
- **rememberedMessages:** (`MastraDBMessage[]`): Only messages loaded from memory (conversation history).
308
+ **rememberedMessages** (`MastraDBMessage[]`): Only messages loaded from memory (conversation history).
175
309
 
176
- **error?:** (`Error`): Error object if the generation failed.
310
+ **error** (`Error`): Error object if the generation failed.
177
311
 
178
- **tripwire?:** (`StepTripwireData`): Tripwire data if content was blocked by a processor.
312
+ **tripwire** (`StepTripwireData`): Tripwire data if content was blocked by a processor.
179
313
 
180
- **scoringData?:** (`object`): Scoring data for evals when \`returnScorerData\` is enabled.
314
+ **scoringData** (`object`): Scoring data for evals when \`returnScorerData\` is enabled.
181
315
 
182
316
  ## Related
183
317
 
@@ -12,77 +12,119 @@ await agent.generateLegacy('message for agent')
12
12
 
13
13
  ## Parameters
14
14
 
15
- **messages:** (`string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[]`): The messages to send to the agent. Can be a single string, array of strings, or structured message objects with multimodal content (text, images, etc.).
15
+ **messages** (`string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[]`): The messages to send to the agent. Can be a single string, array of strings, or structured message objects with multimodal content (text, images, etc.).
16
16
 
17
- **options?:** (`AgentGenerateOptions`): Optional configuration for the generation process.
17
+ **options** (`AgentGenerateOptions`): Optional configuration for the generation process.
18
18
 
19
- ### Options parameters
19
+ **options.abortSignal** (`AbortSignal`): Signal object that allows you to abort the agent's execution. When the signal is aborted, all ongoing operations will be terminated.
20
20
 
21
- **abortSignal?:** (`AbortSignal`): Signal object that allows you to abort the agent's execution. When the signal is aborted, all ongoing operations will be terminated.
21
+ **options.context** (`CoreMessage[]`): Additional context messages to provide to the agent.
22
22
 
23
- **context?:** (`CoreMessage[]`): Additional context messages to provide to the agent.
23
+ **options.structuredOutput** (`StructuredOutputOptions<S extends ZodTypeAny = ZodTypeAny>`): Enables structured output generation with better developer experience. Automatically creates and uses a StructuredOutputProcessor internally.
24
24
 
25
- **structuredOutput?:** (`StructuredOutputOptions<S extends ZodTypeAny = ZodTypeAny>`): schema:z.ZodSchema\<S>Zod schema to validate the output against.model:MastraLanguageModelModel to use for the internal structuring agent.errorStrategy?:'strict' | 'warn' | 'fallback'Strategy when parsing or validation fails. Defaults to 'strict'.fallbackValue?:\<S extends ZodTypeAny>Fallback value when errorStrategy is 'fallback'.instructions?:stringCustom instructions for the structuring agent.
25
+ **options.structuredOutput.schema** (`z.ZodSchema<S>`): Zod schema to validate the output against.
26
26
 
27
- **outputProcessors?:** (`Processor[]`): Overrides the output processors set on the agent. Output processors that can modify or validate messages from the agent before they are returned to the user. Must implement either (or both) of the \`processOutputResult\` and \`processOutputStream\` functions.
27
+ **options.structuredOutput.model** (`MastraLanguageModel`): Model to use for the internal structuring agent.
28
28
 
29
- **inputProcessors?:** (`Processor[]`): Overrides the input processors set on the agent. Input processors that can modify or validate messages before they are processed by the agent. Must implement the \`processInput\` function.
29
+ **options.structuredOutput.errorStrategy** (`'strict' | 'warn' | 'fallback'`): Strategy when parsing or validation fails. Defaults to 'strict'.
30
30
 
31
- **experimental\_output?:** (`Zod schema | JsonSchema7`): Note, the preferred route is to use the \`structuredOutput\` property. Enables structured output generation alongside text generation and tool calls. The model will generate responses that conform to the provided schema.
31
+ **options.structuredOutput.fallbackValue** (`<S extends ZodTypeAny>`): Fallback value when errorStrategy is 'fallback'.
32
32
 
33
- **instructions?:** (`string`): Custom instructions that override the agent's default instructions for this specific generation. Useful for dynamically modifying agent behavior without creating a new agent instance.
33
+ **options.structuredOutput.instructions** (`string`): Custom instructions for the structuring agent.
34
34
 
35
- **output?:** (`Zod schema | JsonSchema7`): Defines the expected structure of the output. Can be a JSON Schema object or a Zod schema.
35
+ **options.outputProcessors** (`Processor[]`): Overrides the output processors set on the agent. Output processors that can modify or validate messages from the agent before they are returned to the user. Must implement either (or both) of the \`processOutputResult\` and \`processOutputStream\` functions.
36
36
 
37
- **memory?:** (`object`): thread:string | { id: string; metadata?: Record\<string, any>, title?: string }The conversation thread, as a string ID or an object with an \`id\` and optional \`metadata\`.resource:stringIdentifier for the user or resource associated with the thread.options?:MemoryConfigConfiguration for memory behavior, like message history and semantic recall. See \`MemoryConfig\` below.
37
+ **options.inputProcessors** (`Processor[]`): Overrides the input processors set on the agent. Input processors that can modify or validate messages before they are processed by the agent. Must implement the \`processInput\` function.
38
38
 
39
- **maxSteps?:** (`number`): Maximum number of execution steps allowed. (Default: `5`)
39
+ **options.experimental\_output** (`Zod schema | JsonSchema7`): Note, the preferred route is to use the \`structuredOutput\` property. Enables structured output generation alongside text generation and tool calls. The model will generate responses that conform to the provided schema.
40
40
 
41
- **maxRetries?:** (`number`): Maximum number of retries. Set to 0 to disable retries. (Default: `2`)
41
+ **options.instructions** (`string`): Custom instructions that override the agent's default instructions for this specific generation. Useful for dynamically modifying agent behavior without creating a new agent instance.
42
42
 
43
- **onStepFinish?:** (`GenerateTextOnStepFinishCallback<any> | never`): Callback function called after each execution step. Receives step details as a JSON string. Unavailable for structured output
43
+ **options.output** (`Zod schema | JsonSchema7`): Defines the expected structure of the output. Can be a JSON Schema object or a Zod schema.
44
44
 
45
- **runId?:** (`string`): Unique ID for this generation run. Useful for tracking and debugging purposes.
45
+ **options.memory** (`object`): Configuration for memory. This is the preferred way to manage memory.
46
46
 
47
- **telemetry?:** (`TelemetrySettings`): isEnabled?:booleanEnable or disable telemetry. Disabled by default while experimental.recordInputs?:booleanEnable or disable input recording. Enabled by default. You might want to disable input recording to avoid recording sensitive information.recordOutputs?:booleanEnable or disable output recording. Enabled by default. You might want to disable output recording to avoid recording sensitive information.functionId?:stringIdentifier for this function. Used to group telemetry data by function.
47
+ **options.memory.thread** (`string | { id: string; metadata?: Record<string, any>, title?: string }`): The conversation thread, as a string ID or an object with an \`id\` and optional \`metadata\`.
48
48
 
49
- **temperature?:** (`number`): Controls randomness in the model's output. Higher values (e.g., 0.8) make the output more random, lower values (e.g., 0.2) make it more focused and deterministic.
49
+ **options.memory.resource** (`string`): Identifier for the user or resource associated with the thread.
50
50
 
51
- **toolChoice?:** (`'auto' | 'none' | 'required' | { type: 'tool'; toolName: string }`): 'auto':stringLet the model decide whether to use tools (default).'none':stringDo not use any tools.'required':stringRequire the model to use at least one tool.{ type: 'tool'; toolName: string }:objectRequire the model to use a specific tool by name. (Default: `'auto'`)
51
+ **options.memory.options** (`MemoryConfig`): Configuration for memory behavior, like message history and semantic recall. See \`MemoryConfig\` below.
52
52
 
53
- **toolsets?:** (`ToolsetsInput`): Additional toolsets to make available to the agent during generation.
53
+ **options.maxSteps** (`number`): Maximum number of execution steps allowed.
54
54
 
55
- **clientTools?:** (`ToolsInput`): Tools that are executed on the 'client' side of the request. These tools do not have execute functions in the definition.
55
+ **options.maxRetries** (`number`): Maximum number of retries. Set to 0 to disable retries.
56
56
 
57
- **savePerStep?:** (`boolean`): Save messages incrementally after each stream step completes (default: false).
57
+ **options.onStepFinish** (`GenerateTextOnStepFinishCallback<any> | never`): Callback function called after each execution step. Receives step details as a JSON string. Unavailable for structured output
58
58
 
59
- **providerOptions?:** (`Record<string, Record<string, JSONValue>>`): openai?:Record\<string, JSONValue>OpenAI-specific options. Example: \`{ reasoningEffort: 'high' }\`anthropic?:Record\<string, JSONValue>Anthropic-specific options. Example: \`{ maxTokens: 1000 }\`google?:Record\<string, JSONValue>Google-specific options. Example: \`{ safetySettings: \[...] }\`\[providerName]?:Record\<string, JSONValue>Other provider-specific options. The key is the provider name and the value is a record of provider-specific options.
59
+ **options.runId** (`string`): Unique ID for this generation run. Useful for tracking and debugging purposes.
60
60
 
61
- **requestContext?:** (`RequestContext`): Request Context for dependency injection and contextual information.
61
+ **options.telemetry** (`TelemetrySettings`): Settings for telemetry collection during generation.
62
62
 
63
- **maxTokens?:** (`number`): Maximum number of tokens to generate.
63
+ **options.telemetry.isEnabled** (`boolean`): Enable or disable telemetry. Disabled by default while experimental.
64
64
 
65
- **topP?:** (`number`): Nucleus sampling. This is a number between 0 and 1. It is recommended to set either \`temperature\` or \`topP\`, but not both.
65
+ **options.telemetry.recordInputs** (`boolean`): Enable or disable input recording. Enabled by default. You might want to disable input recording to avoid recording sensitive information.
66
66
 
67
- **topK?:** (`number`): Only sample from the top K options for each subsequent token. Used to remove 'long tail' low probability responses.
67
+ **options.telemetry.recordOutputs** (`boolean`): Enable or disable output recording. Enabled by default. You might want to disable output recording to avoid recording sensitive information.
68
68
 
69
- **presencePenalty?:** (`number`): Presence penalty setting. It affects the likelihood of the model to repeat information that is already in the prompt. A number between -1 (increase repetition) and 1 (maximum penalty, decrease repetition).
69
+ **options.telemetry.functionId** (`string`): Identifier for this function. Used to group telemetry data by function.
70
70
 
71
- **frequencyPenalty?:** (`number`): Frequency penalty setting. It affects the likelihood of the model to repeatedly use the same words or phrases. A number between -1 (increase repetition) and 1 (maximum penalty, decrease repetition).
71
+ **options.temperature** (`number`): Controls randomness in the model's output. Higher values (e.g., 0.8) make the output more random, lower values (e.g., 0.2) make it more focused and deterministic.
72
72
 
73
- **stopSequences?:** (`string[]`): Stop sequences. If set, the model will stop generating text when one of the stop sequences is generated.
73
+ **options.toolChoice** (`'auto' | 'none' | 'required' | { type: 'tool'; toolName: string }`): Controls how the agent uses tools during generation.
74
74
 
75
- **seed?:** (`number`): The seed (integer) to use for random sampling. If set and supported by the model, calls will generate deterministic results.
75
+ **options.toolChoice.'auto'** (`string`): Let the model decide whether to use tools (default).
76
76
 
77
- **headers?:** (`Record<string, string | undefined>`): Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
77
+ **options.toolChoice.'none'** (`string`): Do not use any tools.
78
+
79
+ **options.toolChoice.'required'** (`string`): Require the model to use at least one tool.
80
+
81
+ **options.toolChoice.{ type: 'tool'; toolName: string }** (`object`): Require the model to use a specific tool by name.
82
+
83
+ **options.toolsets** (`ToolsetsInput`): Additional toolsets to make available to the agent during generation.
84
+
85
+ **options.clientTools** (`ToolsInput`): Tools that are executed on the 'client' side of the request. These tools do not have execute functions in the definition.
86
+
87
+ **options.savePerStep** (`boolean`): Save messages incrementally after each stream step completes (default: false).
88
+
89
+ **options.providerOptions** (`Record<string, Record<string, JSONValue>>`): Additional provider-specific options that are passed through to the underlying LLM provider. The structure is \`{ providerName: { optionKey: value } }\`. Since Mastra extends AI SDK, see the \[AI SDK documentation]\(https\://sdk.vercel.ai/docs/providers/ai-sdk-providers) for complete provider options.
90
+
91
+ **options.providerOptions.openai** (`Record<string, JSONValue>`): OpenAI-specific options. Example: \`{ reasoningEffort: 'high' }\`
92
+
93
+ **options.providerOptions.anthropic** (`Record<string, JSONValue>`): Anthropic-specific options. Example: \`{ maxTokens: 1000 }\`
94
+
95
+ **options.providerOptions.google** (`Record<string, JSONValue>`): Google-specific options. Example: \`{ safetySettings: \[...] }\`
96
+
97
+ **options.providerOptions.\[providerName]** (`Record<string, JSONValue>`): Other provider-specific options. The key is the provider name and the value is a record of provider-specific options.
98
+
99
+ **options.requestContext** (`RequestContext`): Request Context for dependency injection and contextual information.
100
+
101
+ **options.maxTokens** (`number`): Maximum number of tokens to generate.
102
+
103
+ **options.topP** (`number`): Nucleus sampling. This is a number between 0 and 1. It is recommended to set either \`temperature\` or \`topP\`, but not both.
104
+
105
+ **options.topK** (`number`): Only sample from the top K options for each subsequent token. Used to remove 'long tail' low probability responses.
106
+
107
+ **options.presencePenalty** (`number`): Presence penalty setting. It affects the likelihood of the model to repeat information that is already in the prompt. A number between -1 (increase repetition) and 1 (maximum penalty, decrease repetition).
108
+
109
+ **options.frequencyPenalty** (`number`): Frequency penalty setting. It affects the likelihood of the model to repeatedly use the same words or phrases. A number between -1 (increase repetition) and 1 (maximum penalty, decrease repetition).
110
+
111
+ **options.stopSequences** (`string[]`): Stop sequences. If set, the model will stop generating text when one of the stop sequences is generated.
112
+
113
+ **options.seed** (`number`): The seed (integer) to use for random sampling. If set and supported by the model, calls will generate deterministic results.
114
+
115
+ **options.headers** (`Record<string, string | undefined>`): Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
78
116
 
79
117
  ## Returns
80
118
 
81
- **text?:** (`string`): The generated text response. Present when output is 'text' (no schema provided).
119
+ **text** (`string`): The generated text response. Present when output is 'text' (no schema provided).
120
+
121
+ **object** (`object`): The generated structured response. Present when a schema is provided via \`output\`, \`structuredOutput\`, or \`experimental\_output\`.
122
+
123
+ **toolCalls** (`Array<ToolCall>`): The tool calls made during the generation process. Present in both text and object modes.
82
124
 
83
- **object?:** (`object`): The generated structured response. Present when a schema is provided via \`output\`, \`structuredOutput\`, or \`experimental\_output\`.
125
+ **toolCalls.toolName** (`string`): The name of the tool invoked.
84
126
 
85
- **toolCalls?:** (`Array<ToolCall>`): toolName:stringThe name of the tool invoked.args:anyThe arguments passed to the tool.
127
+ **toolCalls.args** (`any`): The arguments passed to the tool.
86
128
 
87
129
  ## Migration to New API
88
130
 
@@ -12,11 +12,13 @@ await agent.getDefaultGenerateOptionsLegacy()
12
12
 
13
13
  ## Parameters
14
14
 
15
- **options?:** (`{ requestContext?: RequestContext }`): Optional configuration object containing request context. (Default: `{}`)
15
+ **options** (`{ requestContext?: RequestContext }`): Optional configuration object containing request context. (Default: `{}`)
16
+
17
+ **options.requestContext** (`RequestContext`): Request Context for dependency injection and contextual information.
16
18
 
17
19
  ## Returns
18
20
 
19
- **defaultOptions:** (`AgentGenerateOptions | Promise<AgentGenerateOptions>`): The default generation options configured for the agent, either as a direct object or a promise that resolves to the options.
21
+ **defaultOptions** (`AgentGenerateOptions | Promise<AgentGenerateOptions>`): The default generation options configured for the agent, either as a direct object or a promise that resolves to the options.
20
22
 
21
23
  ## Extended usage example
22
24
 
@@ -26,10 +28,6 @@ await agent.getDefaultGenerateOptionsLegacy({
26
28
  })
27
29
  ```
28
30
 
29
- ### Options parameters
30
-
31
- **requestContext?:** (`RequestContext`): Request Context for dependency injection and contextual information. (Default: `new RequestContext()`)
32
-
33
31
  ## Related
34
32
 
35
33
  - [Agent generation](https://mastra.ai/docs/agents/overview)