Skip to main content
Mastra v1 is coming in January 2026. Get ahead by starting new projects with the beta or upgrade your existing project today.

Agent.getInstructions()

The .getInstructions() method retrieves the instructions configured for an agent, resolving them if they're a function. These instructions guide the agent's behavior and define its capabilities and constraints.

Usage exampleDirect link to Usage example

await agent.getInstructions();

ParametersDirect link to Parameters

options?:

{ runtimeContext?: RuntimeContext }
= {}
Optional configuration object containing runtime context.

ReturnsDirect link to Returns

instructions:

SystemMessage | Promise<SystemMessage>
The instructions configured for the agent. SystemMessage can be: string | string[] | CoreSystemMessage | CoreSystemMessage[] | SystemModelMessage | SystemModelMessage[]. Returns either directly or as a promise that resolves to the instructions.

Extended usage exampleDirect link to Extended usage example

await agent.getInstructions({
runtimeContext: new RuntimeContext(),
});

Options parametersDirect link to Options parameters

runtimeContext?:

RuntimeContext
= undefined
Runtime context for dependency injection and contextual information.

On this page