R6 class representing an AI agent. Agents are the worker units in the multi-agent architecture. Each agent has a name, description (for semantic routing), system prompt (persona), and a set of tools it can use.
Key design principle: Agents are stateless regarding conversation history. The ChatSession holds the shared state (history, memory, environment).
nameUnique identifier for this agent.
descriptionDescription of the agent's capability. This is the "API" that the LLM Manager uses for semantic routing.
system_promptThe agent's persona/instructions.
toolsList of Tool objects this agent can use.
modelDefault model ID for this agent.
new()Initialize a new Agent.
Agent$new(
name,
description,
system_prompt = NULL,
tools = NULL,
skills = NULL,
model = NULL
)nameUnique name for this agent (e.g., "DataCleaner", "Visualizer").
descriptionA clear description of what this agent does. This is used by the Manager LLM to decide which agent to delegate to.
system_promptOptional system prompt defining the agent's persona.
toolsOptional list of Tool objects the agent can use.
skillsOptional character vector of skill paths or "auto" to discover skills. When provided, this automatically loads skills, creates tools, and updates the system prompt.
modelOptional default model ID for this agent.
An Agent object.
run()Run the agent with a given task.
Agent$run(
task,
session = NULL,
context = NULL,
model = NULL,
max_steps = 10,
...
)taskThe task instruction (natural language).
sessionOptional ChatSession for shared state. If NULL, a temporary session is created.
contextOptional additional context to inject (e.g., from parent agent).
modelOptional model override. Uses session's model if not provided.
max_stepsMaximum ReAct loop iterations. Default 10.
...Additional arguments passed to generate_text.
A GenerateResult object from generate_text.
stream()Run the agent with streaming output.
Agent$stream(
task,
callback = NULL,
session = NULL,
context = NULL,
model = NULL,
max_steps = 10,
...
)taskThe task instruction (natural language).
callbackFunction to handle streaming chunks: callback(text, done).
sessionOptional ChatSession for shared state.
contextOptional additional context to inject.
modelOptional model override.
max_stepsMaximum ReAct loop iterations. Default 10.
...Additional arguments passed to stream_text.
A GenerateResult object (accumulated).
as_tool()Convert this agent to a Tool.
Agent$as_tool()This allows the agent to be used as a delegate target by a Manager agent. The tool wraps the agent's run() method and uses the agent's description for semantic routing.
A Tool object that wraps this agent.
create_session()Create a stateful ChatSession from this agent.
Agent$create_session(model = NULL, ...)modelOptional model override.
...Additional arguments passed to ChatSession$new.
A ChatSession object initialized with this agent's config.
clone()The objects of this class are cloneable with this method.
Agent$clone(deep = FALSE)deepWhether to make a deep clone.