Skip to main content

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 example

await agent.getInstructions();

Parameters

options?:

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

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 example

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

Options parameters

runtimeContext?:

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