Skip to main content

Mastra.getAgent()

.getAgent() 方法用于检索代理。该方法接受一个 string 参数,用于指定代理的名称。

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

使用示例
Direct link to 使用示例

🌐 Usage example

mastra.getAgent("testAgent");

参数
Direct link to 参数

🌐 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.

返回
Direct link to 返回

🌐 Returns

agent:

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

🌐 Related