R6 class for managing a collection of Agent objects. Provides storage,
lookup, and automatic delegation tool generation for multi-agent systems.
Methods
Method new()
Initialize a new AgentRegistry.
Arguments
agents
Optional list of Agent objects to register immediately.
Method register()
Register an agent.
Usage
AgentRegistry$register(agent)
Arguments
agent
An Agent object to register.
Returns
Invisible self for chaining.
Get an agent by name.
Returns
The Agent object, or NULL if not found.
Method has()
Check if an agent is registered.
Returns
TRUE if registered, FALSE otherwise.
Method list_agents()
List all registered agent names.
Usage
AgentRegistry$list_agents()
Returns
Character vector of agent names.
Method get_all()
Get all registered agents.
Returns
List of Agent objects.
Method unregister()
Unregister an agent.
Usage
AgentRegistry$unregister(name)
Arguments
name
The agent name to remove.
Returns
Invisible self for chaining.
Generate delegation tools for all registered agents.
Usage
AgentRegistry$generate_delegate_tools(
flow = NULL,
session = NULL,
model = NULL
)
Arguments
flow
Optional Flow object for context-aware execution.
session
Optional ChatSession for shared state.
model
Optional model ID for agent execution.
Details
Creates a list of Tool objects that wrap each agent's run() method.
These tools can be given to a Manager agent for semantic routing.
Returns
A list of Tool objects.
Method generate_prompt_section()
Generate a prompt section describing available agents.
Usage
AgentRegistry$generate_prompt_section()
Details
Creates a formatted string listing all agents and their descriptions.
Useful for injecting into a Manager's system prompt.
Returns
A character string.
Print method for AgentRegistry.
Method clone()
The objects of this class are cloneable with this method.
Usage
AgentRegistry$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.