mini007

retrieve_open_ai_credential <- function() {
  Sys.getenv("OPENAI_API_KEY")
}

llm <- ellmer::chat(
  name        = "openai/gpt-4.1-mini",
  credentials = retrieve_open_ai_credential,
  echo        = "none"
)

Welcome to mini007

mini007 is a lightweight and extensible R framework for building multi-agent AI systems. It provides three complementary components β€” Agent, LeadAgent, and Workflow β€” that can be used independently or combined to tackle complex tasks that benefit from specialised, collaborating LLM workers.

mini007 relies heavily on the excellent ellmer package and is compatible with any chat model it supports: OpenAI, Anthropic, Google, Ollama, and more.

Highlights

  • 🧠 Persistent memory: every agent maintains its full conversation history with export, import, and summarisation support.
  • βš™οΈ Task decomposition: LeadAgent automatically splits a complex prompt into subtasks and delegates each one to the most suitable agent.
  • πŸ”€ Sequential pipelines: Workflow gives you explicit control over execution order, branching logic, and which handler runs at each step.
  • πŸ’Ύ Caching: workflow station results are cached by input so subsequent runs skip redundant LLM calls.
  • πŸ”§ Tool support: register ellmer tools on any agent, or generate new ones from a natural-language description.
  • πŸ’° Budget control: set a USD spending cap on any agent with a configurable policy (abort, warn, or ask).
  • πŸ§‘ Human In The Loop: pause at specific steps so a human can review, edit, or stop the response before it continues.
  • 🌐 Model-agnostic: swap the underlying LLM without changing any orchestration logic.

Installation

install.packages("mini007")

Key components

Agent

An Agent wraps an ellmer chat object and adds identity (UUID), persistent message history, budget tracking, and tool support. It is the fundamental building block of the framework.

researcher <- Agent$new(
  name        = "researcher",
  instruction = "Answer factual questions concisely and accurately.",
  llm_object  = llm
)

researcher$invoke("What is the boiling point of water at high altitude?")

Agents remember the conversation, so follow-up questions work naturally:

researcher$invoke("Why does it change with altitude?")

Notable methods:

Method Purpose
$invoke(prompt) Send a prompt and get a response
$keep_last_n_messages(n) Trim history to the last n turns
$share_context_with(agent) Copy recent messages to another agent
$set_budget(amount) Set a USD spending limit
$register_tools(...) Attach ellmer tool objects
$generate_and_register_tool(desc) Generate a tool from plain English
$generate_execute_r_code() Write, validate, and run R code
$validate_response(response, criteria) LLM-based output verification
$clone_agent() Create an independent copy with a new UUID
$export_messages_history(path) Save conversation to JSON
$load_messages_history(path) Restore conversation from JSON

LeadAgent

A LeadAgent extends Agent with multi-agent orchestration: it decomposes a complex prompt into subtasks and routes each one to the most suitable registered agent, collecting and chaining the results.

summariser <- Agent$new(
  name        = "summariser",
  instruction = "Summarise the text you receive into three bullet points.",
  llm_object  = llm
)

translator <- Agent$new(
  name        = "translator",
  instruction = "Translate the text you receive from English to French.",
  llm_object  = llm
)

lead <- LeadAgent$new(name = "Lead", llm_object = llm)
lead$register_agents(c(summariser, translator))

lead$invoke("Summarise the history of the Sahara Desert, then translate it into French.")

Notable methods:

Method Purpose
$register_agents(agents) Add agents to the pool
$generate_plan(prompt) Preview task-to-agent assignments before running
$visualize_plan() Render the plan as an interactive directed graph
$invoke(prompt) Decompose, delegate, and return the final answer
$broadcast(prompt) Send one prompt to all agents and collect every response
$judge_and_choose_best_response(prompt) Let the lead pick the best answer from all agents
$agents_dialog(prompt, id1, id2) Run an iterative negotiation between two agents
$set_hitl(steps) Pause at specified steps for human review or editing

Workflow

A Workflow is a predefined, sequential pipeline of Stations connected by Routes. Each Station’s output feeds directly into the next one’s input. You decide the order, the branching conditions, and what runs at each step β€” the handler can be an Agent, a WorkflowAgent, or a plain R function.

# Plain R function as a station β€” no LLM needed
clean <- function(text) trimws(gsub("\\s+", " ", text))

wf <- Workflow$new(name = "article-pipeline", use_cache = TRUE)

wf$add_station("clean",    clean)
wf$add_station("write",    Agent$new(
  name        = "writer",
  instruction = "Turn the notes you receive into an engaging paragraph.",
  llm_object  = llm
))
wf$add_station("edit",     Agent$new(
  name        = "editor",
  instruction = "Polish the paragraph for grammar and conciseness.",
  llm_object  = llm
))

wf$add_route("clean", "write")
wf$add_route("write", "edit")

wf$run("  The  history  of   the  printing   press  ")

Routes can carry a condition function to create branching pipelines:

wf$add_route(
  from      = "classify",
  to        = "positive_reply",
  condition = function(out) grepl("positive", tolower(out))
)

A finished Workflow can be wrapped as a WorkflowAgent and registered with a LeadAgent or nested inside another Workflow:

wa <- wf$as_agent(name = "article_agent")
lead$register_agents(list(wa))

Notable methods:

Method Purpose
$add_station(name, handler) Register a Station (agent or function)
$add_route(from, to, condition) Connect two Stations, optionally gated by a condition
$set_entry(name) Set the starting Station
$run(input) Execute the pipeline sequentially
$clear_cache() Invalidate cached Station results
$set_hitl(steps) Pause at specified steps for human review or editing
$as_agent(name, instruction) Wrap the workflow as a WorkflowAgent
$visualize() Render the pipeline as an interactive directed graph

Get started

Navigate through the pages in the top navigation bar:

  • Agents β€” individual agent creation, memory, tools, budgets, and code generation.
  • LeadAgent β€” multi-agent orchestration, broadcasting, HITL, and agent dialog.
  • Tools β€” building and registering custom tools.
  • Workflow β€” sequential pipelines, conditional routing, caching, and nesting.
  • Testing β€” utilities for writing tests against LLM responses.