HydraR is built with
a provider-agnostic architecture. While it ships with drivers for
Gemini, Claude, and OpenAI, you can extend the framework by subclassing
the AgentDriver R6 class.
AgentDriver Base ClassEvery driver must implement the call() method, which
sends a prompt to the LLM and returns the text response.
When developing workflows, you often want to avoid the cost and latency of real LLM calls. A Mock Driver provides deterministic responses.
Once you’ve created your custom driver, the modern way to use it is through a Node Factory and a declarative YAML file.
extending_hydrar.yml)library(HydraR)
# Define a factory that resolves your custom driver
my_node_factory <- function(id, label, params) {
driver_obj <- if (params[["driver"]] == "custom") {
# CustomCLIDriver$new(id = "my-bot")
} else {
NULL
}
AgentLLMNode$new(
id = id,
label = label,
driver = driver_obj,
role = "Specialized AI Assistant",
prompt_builder = function(state) "Analyze the data"
)
}
# 3. Load and Spawn
# wf <- load_workflow("extending_hydrar.yml")
# dag <- spawn_dag(wf, node_factory = my_node_factory)ollama or
local Python scripts.