Agent.listAgents()
The .listAgents() method retrieves the subagents configured for an agent, resolving them if they're a function. These subagents enable the agent to access other agents and perform complex actions.
Usage exampleDirect link to Usage example
await agent.listAgents()
ParametersDirect link to Parameters
options?:
{ requestContext?: RequestContext }
= {}
Optional configuration object containing request context.
{ requestContext?: RequestContext }
requestContext?:
RequestContext
Request Context for dependency injection and contextual information.
ReturnsDirect link to Returns
agents:
Promise<Record<string, Agent>>
A promise that resolves to a record of agent names to their corresponding Agent instances.
Extended usage exampleDirect link to Extended usage example
import { RequestContext } from '@mastra/core/request-context'
await agent.listAgents({
requestContext: new RequestContext(),
})