跳到主要内容
非官方简体中文翻译,内容版权归 Mastra 所有,遵循 Apache-2.0 许可。

Mastra.getAgent()

The .getAgent() method is used to retrieve an agent. The method accepts a single string parameter for the agent's name.

Usage example
Usage example的直接链接

mastra.getAgent('testAgent')

Parameters
Parameters的直接链接

name:

TAgentName extends keyof TAgents
The name of the agent to retrieve. Must be a valid agent name that exists in the Mastra configuration.

Returns
Returns的直接链接

agent:

TAgents[TAgentName]
The agent instance with the specified name. Throws an error if the agent is not found.
On this page