Skip to content

Interface: MastraAgentDefinition

A code-defined Mastra agent. Mirrors the shape AppKit’s agents plugin uses for AgentDefinition. The registry key under config.agents is the agentId the client streams against; name is purely informational (defaults to the key).

optional description?: string

Optional long-form description; surfaced as Agent.description.


instructions: string

System prompt body.


optional memory?: boolean | MastraMemoryConfigOverride

Per-agent semantic recall (PgVector) override. Cascades from config.memory; the agent value wins when set.

  • undefined (default): inherit config.memory. When that’s enabled, the agent shares the plugin-level singleton PgVector instance (cross-agent semantic recall across the same index).
  • false: disable semantic recall for this agent only.
  • true: enable using the shared singleton (same as default when plugin memory is enabled; useful to opt in when plugin disabled).
  • MastraMemoryConfig object: dedicated PgVector for this agent (private recall index). Bypasses the shared singleton.

optional model?: string | LanguageModelV1 | LanguageModelV2 | LanguageModelV3 | LanguageModelV4 | string & object | { apiKey?: string; headers?: Record<string, string>; id: `${string}/${string}`; url?: string; } | { apiKey?: string; headers?: Record<string, string>; modelId: string; providerId: string; url?: string; } | MastraLanguageModelV2 | MastraLanguageModelV3 | MastraLanguageModelV4 | ModelWithRetries[] | ((__namedParameters) => MastraModelConfig | ModelWithRetries[] | Promise<MastraModelConfig | ModelWithRetries[]>)

Per-agent model override.

  • undefined (default): falls back to the workspace /serving-endpoints resolver that buildModel configures from the per-request WorkspaceClient.
  • string: shorthand for “use the default resolver but swap the modelId” (e.g. "databricks-meta-llama-3-3-70b-instruct").
  • Any other Mastra DynamicArgument<MastraModelConfig>: passed straight through to Agent.model. Use this when you need full control over auth or providerId.

optional name?: string

Display name used as Agent.name. Defaults to the registry key.


optional storage?: boolean | MastraStorageConfigOverride

Per-agent thread/message storage (PostgresStore) override. Cascades from config.storage; the agent value wins when set.

  • undefined (default): inherit config.storage. When that’s enabled, the agent gets its own per-agent PostgresStore keyed by agentStorageSchemaName so threads and messages stay isolated between agents in the same database.
  • false: disable storage for this agent only (purely in-memory).
  • true: enable with the per-agent default schema.
  • MastraStorageConfigOverride object: dedicated PostgresStore config (custom schema, connection, etc.).

optional tools?: ToolsInput | MastraToolsFn

Per-agent tool record. Either a plain map or a callback that receives the typed MastraPlugins sibling-plugin index and returns a map. The callback runs exactly once at agent setup; the result is cached for the agent’s lifetime.


optional workspace?: MastraAgentWorkspaceResolver | Workspace<WorkspaceFilesystem | undefined, WorkspaceSandbox | undefined, undefined>

Mastra Workspace for this agent (filesystem, sandbox, or other providers). Assistant skills from Databricks workspace paths are wired via createWorkspace.