@mastra/mcp-docs-server 0.13.26 → 0.13.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +9 -9
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +11 -0
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +23 -23
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +61 -61
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +22 -22
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Flance.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +65 -65
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Frag.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Freact.md +18 -0
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +12 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +9 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +10 -10
- package/.docs/organized/changelogs/create-mastra.md +47 -47
- package/.docs/organized/changelogs/mastra.md +63 -63
- package/.docs/organized/code-examples/agent.md +19 -14
- package/.docs/organized/code-examples/heads-up-game.md +5 -5
- package/.docs/raw/agents/agent-memory.mdx +86 -125
- package/.docs/raw/agents/input-processors.mdx +3 -3
- package/.docs/raw/agents/output-processors.mdx +4 -4
- package/.docs/raw/agents/overview.mdx +11 -52
- package/.docs/raw/agents/using-tools-and-mcp.mdx +34 -29
- package/.docs/raw/deployment/serverless-platforms/vercel-deployer.mdx +18 -0
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +4 -8
- package/.docs/raw/getting-started/installation.mdx +2 -3
- package/.docs/raw/getting-started/model-providers.mdx +28 -123
- package/.docs/raw/memory/semantic-recall.mdx +1 -1
- package/.docs/raw/reference/agents/agent.mdx +1 -1
- package/.docs/raw/reference/agents/generate.mdx +255 -218
- package/.docs/raw/reference/agents/generateLegacy.mdx +528 -0
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +3 -4
- package/.docs/raw/reference/agents/migration-guide.mdx +291 -0
- package/.docs/raw/reference/client-js/agents.mdx +14 -8
- package/.docs/raw/reference/deployer/vercel.mdx +26 -0
- package/.docs/raw/reference/streaming/ChunkType.mdx +4 -4
- package/.docs/raw/reference/streaming/agents/MastraModelOutput.mdx +13 -13
- package/.docs/raw/reference/streaming/agents/stream.mdx +351 -178
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +515 -0
- package/.docs/raw/reference/{rag → vectors}/astra.mdx +2 -2
- package/.docs/raw/reference/{rag → vectors}/chroma.mdx +2 -2
- package/.docs/raw/reference/{rag → vectors}/couchbase.mdx +2 -2
- package/.docs/raw/reference/{rag → vectors}/lance.mdx +2 -2
- package/.docs/raw/reference/{rag → vectors}/libsql.mdx +2 -4
- package/.docs/raw/reference/{rag → vectors}/mongodb.mdx +2 -2
- package/.docs/raw/reference/{rag → vectors}/opensearch.mdx +2 -2
- package/.docs/raw/reference/{rag → vectors}/pg.mdx +2 -2
- package/.docs/raw/reference/{rag → vectors}/pinecone.mdx +2 -2
- package/.docs/raw/reference/{rag → vectors}/qdrant.mdx +2 -2
- package/.docs/raw/reference/{rag → vectors}/s3vectors.mdx +2 -2
- package/.docs/raw/reference/{rag → vectors}/turbopuffer.mdx +2 -2
- package/.docs/raw/reference/{rag → vectors}/upstash.mdx +2 -2
- package/.docs/raw/reference/{rag → vectors}/vectorize.mdx +2 -2
- package/.docs/raw/streaming/events.mdx +4 -4
- package/.docs/raw/streaming/overview.mdx +9 -11
- package/.docs/raw/streaming/tool-streaming.mdx +3 -3
- package/.docs/raw/streaming/workflow-streaming.mdx +3 -3
- package/CHANGELOG.md +16 -0
- package/package.json +5 -5
- package/.docs/organized/code-examples/agent-network.md +0 -322
- package/.docs/raw/getting-started/model-capability.mdx +0 -11
- package/.docs/raw/reference/agents/generateVNext.mdx +0 -557
- package/.docs/raw/reference/agents/getDefaultVNextStreamOptions.mdx +0 -67
- package/.docs/raw/reference/streaming/agents/streamVNext.mdx +0 -673
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Agent.generateLegacy() (Legacy) | Agents | Mastra Docs"
|
|
3
|
+
description: "Documentation for the legacy `Agent.generateLegacy()` method in Mastra agents. This method is deprecated and will be removed in a future version."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { Callout } from 'nextra/components';
|
|
7
|
+
|
|
8
|
+
# Agent.generateLegacy() (Legacy)
|
|
9
|
+
|
|
10
|
+
<Callout type="warning">
|
|
11
|
+
**Deprecated**: This method is deprecated and only works with V1 models. For V2 models, use the new [`.generate()`](./generate.mdx) method instead. See the [migration guide](./migration-guide.mdx) for details on upgrading.
|
|
12
|
+
</Callout>
|
|
13
|
+
|
|
14
|
+
The `.generateLegacy()` method is the legacy version of the agent generation API, used to interact with V1 model agents to produce text or structured responses. This method accepts messages and optional generation options.
|
|
15
|
+
|
|
16
|
+
## Usage example
|
|
17
|
+
|
|
18
|
+
```typescript copy
|
|
19
|
+
await agent.generateLegacy("message for agent");
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Parameters
|
|
23
|
+
|
|
24
|
+
<PropertiesTable
|
|
25
|
+
content={[
|
|
26
|
+
{
|
|
27
|
+
name: "messages",
|
|
28
|
+
type: "string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[]",
|
|
29
|
+
description: "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.).",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "options",
|
|
33
|
+
type: "AgentGenerateOptions",
|
|
34
|
+
isOptional: true,
|
|
35
|
+
description: "Optional configuration for the generation process.",
|
|
36
|
+
},
|
|
37
|
+
]}
|
|
38
|
+
/>
|
|
39
|
+
|
|
40
|
+
### Options parameters
|
|
41
|
+
|
|
42
|
+
<PropertiesTable
|
|
43
|
+
content={[
|
|
44
|
+
{
|
|
45
|
+
name: "abortSignal",
|
|
46
|
+
type: "AbortSignal",
|
|
47
|
+
isOptional: true,
|
|
48
|
+
description:
|
|
49
|
+
"Signal object that allows you to abort the agent's execution. When the signal is aborted, all ongoing operations will be terminated.",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "context",
|
|
53
|
+
type: "CoreMessage[]",
|
|
54
|
+
isOptional: true,
|
|
55
|
+
description: "Additional context messages to provide to the agent.",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "structuredOutput",
|
|
59
|
+
type: "StructuredOutputOptions<S extends ZodTypeAny = ZodTypeAny>",
|
|
60
|
+
isOptional: true,
|
|
61
|
+
description: "Enables structured output generation with better developer experience. Automatically creates and uses a StructuredOutputProcessor internally.",
|
|
62
|
+
properties: [
|
|
63
|
+
{
|
|
64
|
+
parameters: [{
|
|
65
|
+
name: "schema",
|
|
66
|
+
type: "z.ZodSchema<S>",
|
|
67
|
+
isOptional: false,
|
|
68
|
+
description: "Zod schema to validate the output against."
|
|
69
|
+
}]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
parameters: [{
|
|
73
|
+
name: "model",
|
|
74
|
+
type: "MastraLanguageModel",
|
|
75
|
+
isOptional: false,
|
|
76
|
+
description: "Model to use for the internal structuring agent."
|
|
77
|
+
}]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
parameters: [{
|
|
81
|
+
name: "errorStrategy",
|
|
82
|
+
type: "'strict' | 'warn' | 'fallback'",
|
|
83
|
+
isOptional: true,
|
|
84
|
+
description: "Strategy when parsing or validation fails. Defaults to 'strict'."
|
|
85
|
+
}]
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
parameters: [{
|
|
89
|
+
name: "fallbackValue",
|
|
90
|
+
type: "<S extends ZodTypeAny>",
|
|
91
|
+
isOptional: true,
|
|
92
|
+
description: "Fallback value when errorStrategy is 'fallback'."
|
|
93
|
+
}]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
parameters: [{
|
|
97
|
+
name: "instructions",
|
|
98
|
+
type: "string",
|
|
99
|
+
isOptional: true,
|
|
100
|
+
description: "Custom instructions for the structuring agent."
|
|
101
|
+
}]
|
|
102
|
+
},
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "outputProcessors",
|
|
107
|
+
type: "Processor[]",
|
|
108
|
+
isOptional: true,
|
|
109
|
+
description: "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.",
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "inputProcessors",
|
|
113
|
+
type: "Processor[]",
|
|
114
|
+
isOptional: true,
|
|
115
|
+
description: "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.",
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: "experimental_output",
|
|
119
|
+
type: "Zod schema | JsonSchema7",
|
|
120
|
+
isOptional: true,
|
|
121
|
+
description:
|
|
122
|
+
"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.",
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "instructions",
|
|
126
|
+
type: "string",
|
|
127
|
+
isOptional: true,
|
|
128
|
+
description:
|
|
129
|
+
"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.",
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "output",
|
|
133
|
+
type: "Zod schema | JsonSchema7",
|
|
134
|
+
isOptional: true,
|
|
135
|
+
description:
|
|
136
|
+
"Defines the expected structure of the output. Can be a JSON Schema object or a Zod schema.",
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "memory",
|
|
140
|
+
type: "object",
|
|
141
|
+
isOptional: true,
|
|
142
|
+
description: "Configuration for memory. This is the preferred way to manage memory.",
|
|
143
|
+
properties: [
|
|
144
|
+
{
|
|
145
|
+
parameters: [{
|
|
146
|
+
name: "thread",
|
|
147
|
+
type: "string | { id: string; metadata?: Record<string, any>, title?: string }",
|
|
148
|
+
isOptional: false,
|
|
149
|
+
description: "The conversation thread, as a string ID or an object with an `id` and optional `metadata`."
|
|
150
|
+
}]
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
parameters: [{
|
|
154
|
+
name: "resource",
|
|
155
|
+
type: "string",
|
|
156
|
+
isOptional: false,
|
|
157
|
+
description: "Identifier for the user or resource associated with the thread."
|
|
158
|
+
}]
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
parameters: [{
|
|
162
|
+
name: "options",
|
|
163
|
+
type: "MemoryConfig",
|
|
164
|
+
isOptional: true,
|
|
165
|
+
description: "Configuration for memory behavior, like message history and semantic recall. See `MemoryConfig` below."
|
|
166
|
+
}]
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: "maxSteps",
|
|
172
|
+
type: "number",
|
|
173
|
+
isOptional: true,
|
|
174
|
+
defaultValue: "5",
|
|
175
|
+
description: "Maximum number of execution steps allowed.",
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "maxRetries",
|
|
179
|
+
type: "number",
|
|
180
|
+
isOptional: true,
|
|
181
|
+
defaultValue: "2",
|
|
182
|
+
description: "Maximum number of retries. Set to 0 to disable retries.",
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: "onStepFinish",
|
|
186
|
+
type: "GenerateTextOnStepFinishCallback<any> | never",
|
|
187
|
+
isOptional: true,
|
|
188
|
+
description:
|
|
189
|
+
"Callback function called after each execution step. Receives step details as a JSON string. Unavailable for structured output",
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "runId",
|
|
193
|
+
type: "string",
|
|
194
|
+
isOptional: true,
|
|
195
|
+
description: "Unique ID for this generation run. Useful for tracking and debugging purposes.",
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: "telemetry",
|
|
199
|
+
type: "TelemetrySettings",
|
|
200
|
+
isOptional: true,
|
|
201
|
+
description:
|
|
202
|
+
"Settings for telemetry collection during generation.",
|
|
203
|
+
properties: [
|
|
204
|
+
{
|
|
205
|
+
parameters: [{
|
|
206
|
+
name: "isEnabled",
|
|
207
|
+
type: "boolean",
|
|
208
|
+
isOptional: true,
|
|
209
|
+
description: "Enable or disable telemetry. Disabled by default while experimental."
|
|
210
|
+
}]
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
parameters: [{
|
|
214
|
+
name: "recordInputs",
|
|
215
|
+
type: "boolean",
|
|
216
|
+
isOptional: true,
|
|
217
|
+
description: "Enable or disable input recording. Enabled by default. You might want to disable input recording to avoid recording sensitive information."
|
|
218
|
+
}]
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
parameters: [{
|
|
222
|
+
name: "recordOutputs",
|
|
223
|
+
type: "boolean",
|
|
224
|
+
isOptional: true,
|
|
225
|
+
description: "Enable or disable output recording. Enabled by default. You might want to disable output recording to avoid recording sensitive information."
|
|
226
|
+
}]
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
parameters: [{
|
|
230
|
+
name: "functionId",
|
|
231
|
+
type: "string",
|
|
232
|
+
isOptional: true,
|
|
233
|
+
description: "Identifier for this function. Used to group telemetry data by function."
|
|
234
|
+
}]
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
name: "temperature",
|
|
240
|
+
type: "number",
|
|
241
|
+
isOptional: true,
|
|
242
|
+
description:
|
|
243
|
+
"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.",
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: "toolChoice",
|
|
247
|
+
type: "'auto' | 'none' | 'required' | { type: 'tool'; toolName: string }",
|
|
248
|
+
isOptional: true,
|
|
249
|
+
defaultValue: "'auto'",
|
|
250
|
+
description: "Controls how the agent uses tools during generation.",
|
|
251
|
+
properties: [
|
|
252
|
+
{
|
|
253
|
+
parameters: [{
|
|
254
|
+
name: "'auto'",
|
|
255
|
+
type: "string",
|
|
256
|
+
description: "Let the model decide whether to use tools (default)."
|
|
257
|
+
}]
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
parameters: [{
|
|
261
|
+
name: "'none'",
|
|
262
|
+
type: "string",
|
|
263
|
+
description: "Do not use any tools."
|
|
264
|
+
}]
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
parameters: [{
|
|
268
|
+
name: "'required'",
|
|
269
|
+
type: "string",
|
|
270
|
+
description: "Require the model to use at least one tool."
|
|
271
|
+
}]
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
parameters: [{
|
|
275
|
+
name: "{ type: 'tool'; toolName: string }",
|
|
276
|
+
type: "object",
|
|
277
|
+
description: "Require the model to use a specific tool by name."
|
|
278
|
+
}]
|
|
279
|
+
}
|
|
280
|
+
]
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: "toolsets",
|
|
284
|
+
type: "ToolsetsInput",
|
|
285
|
+
isOptional: true,
|
|
286
|
+
description:
|
|
287
|
+
"Additional toolsets to make available to the agent during generation.",
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
name: "clientTools",
|
|
291
|
+
type: "ToolsInput",
|
|
292
|
+
isOptional: true,
|
|
293
|
+
description:
|
|
294
|
+
"Tools that are executed on the 'client' side of the request. These tools do not have execute functions in the definition.",
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
name: "savePerStep",
|
|
298
|
+
type: "boolean",
|
|
299
|
+
isOptional: true,
|
|
300
|
+
description: "Save messages incrementally after each stream step completes (default: false).",
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
name: "providerOptions",
|
|
304
|
+
type: "Record<string, Record<string, JSONValue>>",
|
|
305
|
+
isOptional: true,
|
|
306
|
+
description: "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.",
|
|
307
|
+
properties: [
|
|
308
|
+
{
|
|
309
|
+
parameters: [{
|
|
310
|
+
name: "openai",
|
|
311
|
+
type: "Record<string, JSONValue>",
|
|
312
|
+
isOptional: true,
|
|
313
|
+
description: "OpenAI-specific options. Example: `{ reasoningEffort: 'high' }`"
|
|
314
|
+
}]
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
parameters: [{
|
|
318
|
+
name: "anthropic",
|
|
319
|
+
type: "Record<string, JSONValue>",
|
|
320
|
+
isOptional: true,
|
|
321
|
+
description: "Anthropic-specific options. Example: `{ maxTokens: 1000 }`"
|
|
322
|
+
}]
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
parameters: [{
|
|
326
|
+
name: "google",
|
|
327
|
+
type: "Record<string, JSONValue>",
|
|
328
|
+
isOptional: true,
|
|
329
|
+
description: "Google-specific options. Example: `{ safetySettings: [...] }`"
|
|
330
|
+
}]
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
parameters: [{
|
|
334
|
+
name: "[providerName]",
|
|
335
|
+
type: "Record<string, JSONValue>",
|
|
336
|
+
isOptional: true,
|
|
337
|
+
description: "Other provider-specific options. The key is the provider name and the value is a record of provider-specific options."
|
|
338
|
+
}]
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
name: "runtimeContext",
|
|
344
|
+
type: "RuntimeContext",
|
|
345
|
+
isOptional: true,
|
|
346
|
+
description: "Runtime context for dependency injection and contextual information.",
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
name: "maxTokens",
|
|
350
|
+
type: "number",
|
|
351
|
+
isOptional: true,
|
|
352
|
+
description: "Maximum number of tokens to generate.",
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
name: "topP",
|
|
356
|
+
type: "number",
|
|
357
|
+
isOptional: true,
|
|
358
|
+
description: "Nucleus sampling. This is a number between 0 and 1. It is recommended to set either `temperature` or `topP`, but not both.",
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
name: "topK",
|
|
362
|
+
type: "number",
|
|
363
|
+
isOptional: true,
|
|
364
|
+
description: "Only sample from the top K options for each subsequent token. Used to remove 'long tail' low probability responses.",
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
name: "presencePenalty",
|
|
368
|
+
type: "number",
|
|
369
|
+
isOptional: true,
|
|
370
|
+
description: "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).",
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
name: "frequencyPenalty",
|
|
374
|
+
type: "number",
|
|
375
|
+
isOptional: true,
|
|
376
|
+
description: "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).",
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
name: "stopSequences",
|
|
380
|
+
type: "string[]",
|
|
381
|
+
isOptional: true,
|
|
382
|
+
description: "Stop sequences. If set, the model will stop generating text when one of the stop sequences is generated.",
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
name: "seed",
|
|
386
|
+
type: "number",
|
|
387
|
+
isOptional: true,
|
|
388
|
+
description: "The seed (integer) to use for random sampling. If set and supported by the model, calls will generate deterministic results.",
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
name: "headers",
|
|
392
|
+
type: "Record<string, string | undefined>",
|
|
393
|
+
isOptional: true,
|
|
394
|
+
description: "Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.",
|
|
395
|
+
}
|
|
396
|
+
]}
|
|
397
|
+
/>
|
|
398
|
+
|
|
399
|
+
## Returns
|
|
400
|
+
|
|
401
|
+
<PropertiesTable
|
|
402
|
+
content={[
|
|
403
|
+
{
|
|
404
|
+
name: "text",
|
|
405
|
+
type: "string",
|
|
406
|
+
isOptional: true,
|
|
407
|
+
description: "The generated text response. Present when output is 'text' (no schema provided).",
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
name: "object",
|
|
411
|
+
type: "object",
|
|
412
|
+
isOptional: true,
|
|
413
|
+
description: "The generated structured response. Present when a schema is provided via `output`, `structuredOutput`, or `experimental_output`.",
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
name: "toolCalls",
|
|
417
|
+
type: "Array<ToolCall>",
|
|
418
|
+
isOptional: true,
|
|
419
|
+
description: "The tool calls made during the generation process. Present in both text and object modes.",
|
|
420
|
+
properties: [
|
|
421
|
+
{
|
|
422
|
+
parameters: [{
|
|
423
|
+
name: "toolName",
|
|
424
|
+
type: "string",
|
|
425
|
+
required: true,
|
|
426
|
+
description: "The name of the tool invoked."
|
|
427
|
+
}]
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
parameters: [{
|
|
431
|
+
name: "args",
|
|
432
|
+
type: "any",
|
|
433
|
+
required: true,
|
|
434
|
+
description: "The arguments passed to the tool."
|
|
435
|
+
}]
|
|
436
|
+
}
|
|
437
|
+
]
|
|
438
|
+
},
|
|
439
|
+
]}
|
|
440
|
+
/>
|
|
441
|
+
|
|
442
|
+
## Migration to New API
|
|
443
|
+
|
|
444
|
+
<Callout type="info">
|
|
445
|
+
The new `.generate()` method offers enhanced capabilities including AI SDK v5 compatibility, better structured output handling, and improved streaming support. See the [migration guide](./migration-guide.mdx) for detailed migration instructions.
|
|
446
|
+
</Callout>
|
|
447
|
+
|
|
448
|
+
### Quick Migration Example
|
|
449
|
+
|
|
450
|
+
#### Before (Legacy)
|
|
451
|
+
```typescript
|
|
452
|
+
const result = await agent.generateLegacy("message", {
|
|
453
|
+
temperature: 0.7,
|
|
454
|
+
maxSteps: 3
|
|
455
|
+
});
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
#### After (New API)
|
|
459
|
+
```typescript
|
|
460
|
+
const result = await agent.generate("message", {
|
|
461
|
+
modelSettings: {
|
|
462
|
+
temperature: 0.7
|
|
463
|
+
},
|
|
464
|
+
maxSteps: 3
|
|
465
|
+
});
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
## Extended usage example
|
|
469
|
+
|
|
470
|
+
```typescript showLineNumbers copy
|
|
471
|
+
import { z } from "zod";
|
|
472
|
+
import { ModerationProcessor, TokenLimiterProcessor } from "@mastra/core/processors";
|
|
473
|
+
|
|
474
|
+
await agent.generateLegacy(
|
|
475
|
+
[
|
|
476
|
+
{ role: "user", content: "message for agent" },
|
|
477
|
+
{
|
|
478
|
+
role: "user",
|
|
479
|
+
content: [
|
|
480
|
+
{
|
|
481
|
+
type: "text",
|
|
482
|
+
text: "message for agent"
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
type: "image",
|
|
486
|
+
imageUrl: "https://example.com/image.jpg",
|
|
487
|
+
mimeType: "image/jpeg"
|
|
488
|
+
}
|
|
489
|
+
]
|
|
490
|
+
}
|
|
491
|
+
],
|
|
492
|
+
{
|
|
493
|
+
temperature: 0.7,
|
|
494
|
+
maxSteps: 3,
|
|
495
|
+
memory: {
|
|
496
|
+
thread: "user-123",
|
|
497
|
+
resource: "test-app"
|
|
498
|
+
},
|
|
499
|
+
toolChoice: "auto",
|
|
500
|
+
providerOptions: {
|
|
501
|
+
openai: {
|
|
502
|
+
reasoningEffort: "high"
|
|
503
|
+
}
|
|
504
|
+
},
|
|
505
|
+
// Structured output with better DX
|
|
506
|
+
structuredOutput: {
|
|
507
|
+
schema: z.object({
|
|
508
|
+
sentiment: z.enum(['positive', 'negative', 'neutral']),
|
|
509
|
+
confidence: z.number(),
|
|
510
|
+
}),
|
|
511
|
+
model: openai("gpt-4o-mini"),
|
|
512
|
+
errorStrategy: 'warn',
|
|
513
|
+
},
|
|
514
|
+
// Output processors for response validation
|
|
515
|
+
outputProcessors: [
|
|
516
|
+
new ModerationProcessor({ model: openai("gpt-4.1-nano") }),
|
|
517
|
+
new TokenLimiterProcessor({ maxTokens: 1000 }),
|
|
518
|
+
],
|
|
519
|
+
}
|
|
520
|
+
);
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
## Related
|
|
524
|
+
|
|
525
|
+
- [Migration Guide](./migration-guide.mdx)
|
|
526
|
+
- [New .generate() method](./generate.mdx)
|
|
527
|
+
- [Generating responses](../../docs/agents/overview.mdx#generating-responses)
|
|
528
|
+
- [Streaming responses](../../docs/agents/overview.mdx#streaming-responses)
|
|
@@ -33,8 +33,8 @@ await agent.getDefaultStreamOptions();
|
|
|
33
33
|
content={[
|
|
34
34
|
{
|
|
35
35
|
name: "defaultOptions",
|
|
36
|
-
type: "
|
|
37
|
-
description: "The default streaming options configured for the agent, either as a direct object or a promise that resolves to the options.",
|
|
36
|
+
type: "AgentExecutionOptions<Output, StructuredOutput> | Promise<AgentExecutionOptions<Output, StructuredOutput>>",
|
|
37
|
+
description: "The default vNext streaming options configured for the agent, either as a direct object or a promise that resolves to the options.",
|
|
38
38
|
},
|
|
39
39
|
]}
|
|
40
40
|
/>
|
|
@@ -63,6 +63,5 @@ await agent.getDefaultStreamOptions({
|
|
|
63
63
|
|
|
64
64
|
## Related
|
|
65
65
|
|
|
66
|
-
- [
|
|
67
|
-
- [Streaming responses](../../docs/agents/overview.mdx#streaming-responses)
|
|
66
|
+
- [Streaming with agents](../../docs/streaming/overview.mdx#streaming-with-agents)
|
|
68
67
|
- [Agent Runtime Context](../../docs/agents/runtime-context.mdx)
|