Mastra.getAgentById()
.getAgentById() 方法用于通过其 ID 检索代理。该方法接受一个用于代理 ID 的 string 参数。
🌐 The .getAgentById() method is used to retrieve an agent by its ID. The method accepts a single string parameter for the agent's ID.
使用示例Direct link to 使用示例
🌐 Usage example
mastra.getAgentById("test-agent-123");
参数Direct link to 参数
🌐 Parameters
id:
string
The ID of the agent to retrieve. The method will first search for an agent with this ID, and if not found, will attempt to use it as a name to call getAgent().
返回Direct link to 返回
🌐 Returns
agent:
Agent
The agent instance with the specified ID. Throws an error if the agent is not found.
相关Direct link to 相关
🌐 Related