Back to Mastra

Reference: Agent.getDefaultGenerateOptionsLegacy() | Agents

docs/src/content/en/reference/agents/getDefaultGenerateOptions.mdx

2025-12-181.9 KB
Original Source

Agent.getDefaultGenerateOptionsLegacy()

:::warning

Deprecated: This method is deprecated and only works with V1 models. For V2 models, use the new .getDefaultOptions() method instead.

:::

Agents can be configured with default generation options for controlling model behavior, output formatting and tool and workflow calls. The .getDefaultGenerateOptionsLegacy() method retrieves these defaults, resolving them if they're functions. These options apply to all generateLegacy() calls unless overridden and are useful for inspecting an agent’s unknown defaults.

Usage example

typescript
await agent.getDefaultGenerateOptionsLegacy()

Parameters

<PropertiesTable content={[ { name: 'options', type: '{ requestContext?: RequestContext }', isOptional: true, defaultValue: '{}', description: 'Optional configuration object containing request context.', properties: [ { type: '{ requestContext?: RequestContext }', parameters: [ { name: 'requestContext', type: 'RequestContext', isOptional: true, defaultValue: 'new RequestContext()', description: 'Request Context for dependency injection and contextual information.', }, ], }, ], }, ]} />

Returns

<PropertiesTable content={[ { name: 'defaultOptions', type: 'AgentGenerateOptions | Promise<AgentGenerateOptions>', description: 'The default generation options configured for the agent, either as a direct object or a promise that resolves to the options.', }, ]} />

Extended usage example

typescript
await agent.getDefaultGenerateOptionsLegacy({
  requestContext: new RequestContext(),
})