Skip to contents

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

Public fields

sub_agent_defs

List of AgentDefinition objects

Methods

Inherited methods


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

chat

An ellmer Chat object

sub_agents

List of agent_definition() objects

tools

Additional tools for the lead agent

system_prompt

System prompt for the lead agent

permissions

Permissions for the lead agent (also applied to sub-agents)

usage_limits

Optional UsageLimits for each lead-agent run.

enable_file_checkpointing

Whether to journal reversible file preimages in one workspace journal shared by the lead agent and its delegated agents.

file_checkpoint_max_file_bytes

Maximum bytes captured for one file preimage. Defaults to 50 MiB.

file_checkpoint_max_journal_bytes

Maximum aggregate serialized bytes for workspace checkpoint records, markers, metadata, and pending captures. Defaults to 250 MiB.

working_dir

Working directory

session_id

Optional stable session identifier used for correlation. A unique identifier is generated by default.

run_context

Immutable canonical product context inherited by lead runs and delegated agents.

agent_id

Optional stable identifier for this LeadAgent instance.

agent_name

Optional human-readable LeadAgent name.

Returns

A new LeadAgent object


LeadAgent$register_sub_agent()

Register a new sub-agent definition.

Usage

LeadAgent$register_sub_agent(definition)

Arguments

definition

An agent_definition() object

Returns

Invisible self


LeadAgent$available_sub_agents()

Get available sub-agent names.

Usage

LeadAgent$available_sub_agents()

Returns

Character vector of sub-agent names


LeadAgent$list_subagents()

List delegated sub-agent runs, including failures.

Usage

LeadAgent$list_subagents()

Returns

Data frame with one row per sub-agent run


LeadAgent$get_subagent_results()

Get retained results from delegated sub-agent runs.

Usage

LeadAgent$get_subagent_results(agent_name = NULL, delegation_id = NULL)

Arguments

agent_name

Optional sub-agent name filter

delegation_id

Optional delegation identifier filter

Returns

List of AgentResult objects or NULL entries for failed runs


LeadAgent$get_subagent_messages()

Get stored turn history for delegated sub-agent runs.

Usage

LeadAgent$get_subagent_messages(agent_name = NULL, session_id = NULL)

Arguments

agent_name

Optional sub-agent name filter

session_id

Optional sub-agent session id filter

Returns

List of turn histories


LeadAgent$print()

Print the lead agent.

Usage

LeadAgent$print()


LeadAgent$clone()

The objects of this class are cloneable with this method.

Usage

LeadAgent$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.