A specialized AgentNode that leverages a Large Language Model (LLM)
to generate outputs from prompts. It manages prompt construction by combining
a persistent role (system prompt) with dynamic context from the
AgentState. It also handles tool injection and automatic context
discovery from local files (e.g., agents.md, skills.md).
Super class
HydraR::AgentNode -> AgentLLMNode
Public fields
roleString. System prompt/role for the agent.
modelString. Default model.
driverAgentDriver object.
output_formatString. Output expectation.
cli_optsList. Default CLI options for the driver.
prompt_builderFunction(state) -> String.
toolsList of AgentTool objects.
agents_filesCharacter vector. Paths to agents context files.
skills_filesCharacter vector. Paths to skills context files.
Methods
Method new()
Initialize AgentLLMNode
Usage
AgentLLMNode$new(
id,
role,
driver,
model = NULL,
cli_opts = list(),
prompt_builder = NULL,
tools = list(),
label = NULL,
params = list(),
agents_files = NULL,
skills_files = NULL
)Arguments
idString. Unique identifier for the node.
roleString. The primary system prompt or persona the LLM should assume.
driverAgentDriver. An instance of an
AgentDriversubclass (CLI or API based).modelString. Optional. The specific model to use (overrides driver default).
cli_optsList. Optional. Named list of parameters for the LLM call (e.g., temperature).
prompt_builderFunction. Optional. A function that takes an
AgentStateand returns a string prompt. If omitted, the node serializes the entire state as JSON.toolsList. A list of
AgentToolobjects available for the agent to use.labelString. Human-readable name for visualization.
paramsList. Additional configuration (e.g.,
output_format="r").agents_filesCharacter vector. Optional paths to markdown files containing agent interaction guidelines.
skills_filesCharacter vector. Optional paths to markdown files containing specialized tool instructions. Run the LLM Node
Method run()
Executes the LLM call. This method handles prompt construction, tool injection, context file discovery, and driver invocation.
Arguments
stateAgentState. The centralized state object for the workflow.
...Additional arguments. Passed through to the driver's
call()method.
Examples
if (FALSE) { # \dontrun{
# NOTE: Set ANTHROPIC_API_KEY in your .Renviron file
driver <- AnthropicAPIDriver$new()
# Create a node with a prompt builder that pulls from state
node <- AgentLLMNode$new(
id = "summarizer",
role = "You are a concise summarizer.",
driver = driver,
prompt_builder = function(state) {
sprintf("Summarise this text: %s", state$get("input_text"))
}
)
} # }