A ReAct-style module that can call tools during execution. Use this to build tool-using agents that alternate between reasoning, tool calls, and observations before producing a final structured answer.
Details
Create a ReAct module with module(type = "react", tools = list(...)).
If you pass tools with type = "predict", the module automatically
upgrades to react. The module runs a loop of tool calls up to
max_iterations, then produces output based on the module signature.
See also
modulefor creating modulesragnar_toolandcreate_search_toolfor search toolscode_actfor tool + code execution agents
Examples
if (FALSE) { # \dontrun{
library(dsprrr)
library(ellmer)
search_tool <- ellmer::tool(
function(query) "Search results...",
description = "Search for information",
arguments = list(query = ellmer::type_string())
)
agent <- module(
signature("question -> answer"),
type = "react",
tools = list(search_tool),
max_iterations = 8L
)
result <- run(agent, question = "What is ReAct?", .llm = llm)
# Batch execution
questions <- tibble::tibble(question = c("Q1", "Q2"))
results <- run_dataset(agent, questions, .llm = llm)
} # }