A LeadAgent is an agent that can delegate tasks to specialized sub-agents.
It automatically has a delegate_to_agent tool that allows it to spawn
sub-agents based on registered AgentDefinitions.
Super class
Agent -> LeadAgent
Methods
Inherited methods
Agent$add_hook()Agent$checkpoint()Agent$compact()Agent$cost()Agent$get_permission_mode()Agent$interrupt()Agent$last_turn()Agent$list_checkpoints()Agent$load_mcp()Agent$load_session()Agent$load_skill()Agent$mcp_status()Agent$mcp_tools()Agent$provider()Agent$register_tool()Agent$register_tools()Agent$rewind_files()Agent$run()Agent$run_async()Agent$run_shiny()Agent$run_sync()Agent$save_session()Agent$session_id()Agent$set_permission_mode()Agent$skills()Agent$turns()Agent$usage()
LeadAgent$new()
Create a new LeadAgent.
Usage
LeadAgent$new(
chat,
sub_agents = list(),
tools = list(),
system_prompt = NULL,
permissions = NULL,
usage_limits = NULL,
enable_file_checkpointing = FALSE,
file_checkpoint_max_file_bytes = 50 * 1024^2,
file_checkpoint_max_journal_bytes = 250 * 1024^2,
working_dir = getwd(),
session_id = NULL,
run_context = list(),
agent_id = NULL,
agent_name = NULL
)Arguments
chatAn ellmer Chat object
sub_agentsList of
agent_definition()objectstoolsAdditional tools for the lead agent
system_promptSystem prompt for the lead agent
permissionsPermissions for the lead agent (also applied to sub-agents)
usage_limitsOptional UsageLimits for each lead-agent run.
enable_file_checkpointingWhether to journal reversible file preimages in one workspace journal shared by the lead agent and its delegated agents.
file_checkpoint_max_file_bytesMaximum bytes captured for one file preimage. Defaults to 50 MiB.
file_checkpoint_max_journal_bytesMaximum aggregate serialized bytes for workspace checkpoint records, markers, metadata, and pending captures. Defaults to 250 MiB.
working_dirWorking directory
session_idOptional stable session identifier used for correlation. A unique identifier is generated by default.
run_contextImmutable canonical product context inherited by lead runs and delegated agents.
agent_idOptional stable identifier for this LeadAgent instance.
agent_nameOptional human-readable LeadAgent name.
LeadAgent$register_sub_agent()
Register a new sub-agent definition.
Arguments
definitionAn
agent_definition()object
LeadAgent$get_subagent_results()
Get retained results from delegated sub-agent runs.
Arguments
agent_nameOptional sub-agent name filter
delegation_idOptional delegation identifier filter
Returns
List of AgentResult objects or NULL entries for failed runs