@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
32 lines (20 loc) • 1.15 kB
Markdown
# 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
```typescript
await agent.getInstructions()
```
## Parameters
**options** (`{ requestContext?: RequestContext }`): Optional configuration object containing request context. (Default: `{}`)
**options.requestContext** (`RequestContext`): Request Context for dependency injection and contextual information.
## 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
```typescript
await agent.getInstructions({
requestContext: new RequestContext(),
})
```
## Related
- [Agents overview](https://mastra.ai/docs/agents/overview)
- [Request Context](https://mastra.ai/docs/server/request-context)