Agents that remember, use tools, stay on budget and hand work to each other, on any chat model ellmer supports.
install.packages("mini007")
Five R6 classes, each usable on its own or combined with the others. Pick one to see it in code.
library(mini007)
llm <- ellmer::chat("openai/gpt-4.1-mini", echo = "none")
guide <- Agent$new(
name = "guide",
instruction = "You are a concise guide to Algerian history.",
llm_object = llm
)
guide$set_budget(0.50) # stop before spending more than $0.50
guide$invoke("When did Algeria gain its independence?")
guide$invoke("Which agreement led to it?") # it remembers# wilayas: a data frame with one row per Algerian province
population <- ellmer::tool(
function(wilaya) {
wilayas$population[wilayas$name == wilaya]
},
name = "population",
description = "Population of one Algerian wilaya.",
arguments = list(wilaya = ellmer::type_string())
)
analyst <- ReActAgent$new(
name = "analyst",
instruction = "Answer questions about Algerian wilayas.",
llm_object = llm,
tools = list(population)
)
analyst$invoke("Which is larger: Oran or Constantine?")
analyst$print_trace() # think, act, observe, answerhistorian <- Agent$new(
name = "historian",
instruction = "Summarise the topic in three bullet points.",
llm_object = llm
)
translator <- Agent$new(
name = "translator",
instruction = "Translate the text into German.",
llm_object = llm
)
lead <- LeadAgent$new(name = "lead", llm_object = llm)
lead$register_agents(c(historian, translator))
lead$invoke("Summarise the Casbah's history, then translate it.")historian <- Agent$new(
name = "historian",
instruction = "Answer questions on Algerian history.",
llm_object = llm
)
travel <- Agent$new(
name = "travel",
instruction = "Plan trips across Algeria's 58 wilayas.",
llm_object = llm
)
router <- RouterAgent$new(name = "desk", llm_object = llm)
router$register_agents(list(historian, travel))
router$invoke("When is the best season to visit Djanet?")
router$route("Who founded the city of Tlemcen?")$reasonclean <- function(text) trimws(gsub("\\s+", " ", text))
writer <- Agent$new("writer", "Write one paragraph.", llm)
editor <- Agent$new("editor", "Polish the text.", llm)
wf <- Workflow$new(name = "travel-article", use_cache = TRUE)
wf$add_station("clean", clean)
wf$add_station("write", writer)
wf$add_station("edit", editor)
wf$add_route("clean", "write")
wf$add_route("write", "edit")
wf$run(" Tassili n'Ajjer: rock art, sandstone forests ")Spending caps, human review, validation and tests live on the objects you already have. Nothing extra to install or wire up.
Abort, warn or ask when an agent reaches its USD limit.
Pause at chosen steps to review, edit or stop.
Score each delegated step, reassign weak ones and keep lessons across sessions.
Tokens, tool calls and progress events as they happen.
Workflow stations skip work they have already done.
LLM-as-judge checks that run under testthat.
Bring an API key for any provider ellmer supports.