Agent.listAgents()
The .listAgents()
method retrieves the sub-agents configured for an agent, resolving them if they’re a function. These sub-agents enable the agent to access other agents and perform complex actions.
Usage example
await agent.listAgents();
Parameters
options?:
{ runtimeContext?: RuntimeContext }
= {}
Optional configuration object containing runtime context.
Returns
agents:
Promise<Record<string, Agent>>
A promise that resolves to a record of agent names to their corresponding Agent instances.
Extended usage example
import { RuntimeContext } from "@mastra/core/runtime-context";
await agent.listAgents({
runtimeContext: new RuntimeContext()
});
Options parameters
runtimeContext?:
RuntimeContext
= new RuntimeContext()
Runtime context for dependency injection and contextual information.