Skip to main content
Mastra v1 is coming in January 2026. Get ahead by starting new projects with the beta or upgrade your existing project today.

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 exampleDirect link to Usage example

await agent.listAgents();

ParametersDirect link to Parameters

options?:

{ runtimeContext?: RuntimeContext }
= {}
Optional configuration object containing runtime context.

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 { RuntimeContext } from "@mastra/core/runtime-context";

await agent.listAgents({
runtimeContext: new RuntimeContext(),
});

Options parametersDirect link to Options parameters

runtimeContext?:

RuntimeContext
= new RuntimeContext()
Runtime context for dependency injection and contextual information.

On this page