| ArchitectAgent | R Documentation |
An 'ArchitectAgent' interviews you about what you need, then designs and builds the agents and the [Workflow] that does it. It works in three steps:
1. **Interview** ($interview()): it asks one question at a time
about the task and the prompts the workflow will receive, the expected
output, what matters most (low cost, reliability, speed or a balance),
which of your models it may use, how many agents you want, a budget,
whether a review step is wanted and whether steps may run in parallel.
It skips what you have already answered and stops once it knows enough.
2. **Blueprint** ($draft_blueprint()): it designs the agents. Each
one gets a name, a system prompt, its task in the workflow, one of your
models, an effort level ('"low"', '"medium"' or '"high"'), its tools
and the agents whose results it needs. Agents that do not depend on
each other are put in the same stage and can run in parallel. When no
tool you gave fits a need, it proposes a new one.
3. **Build** ($build()): it writes the R code of the new tools,
creates the agents (a [ReActAgent] for each agent with tools, an
[Agent] otherwise) and wires them into a [Workflow], stage by stage.
$design() runs the three steps in a row. It shows you the
blueprint, and then the code of any new tool, before building, so you can
ask for changes first.
**Models.** The architect can only assign the models you give it in 'models', a named list of ellmer chat objects; the names are the labels it chooses from. It reads each model's provider, name and price (from [set_prices()] or ellmer's price table) to weigh cost against capability, plus any note you give in 'model_notes'.
**Effort.** An agent's effort level shapes its system prompt: a '"low"' effort agent is told to answer directly and briefly, a '"high"' effort agent to reason step by step and check its work. Effort also guides the choice of model: when cost matters most, the architect favours cheap models and low effort; when reliability matters most, strong models and high effort for the critical steps. To also set a provider-level reasoning effort, pass the same model several times with different 'params', eg. '"gpt-5-mini (low)" = ellmer::chat_openai(model = "gpt-5-mini", params = ellmer::params(reasoning_effort = "low"))', and describe them in 'model_notes'.
**Tools.** The architect assigns the ellmer tools you give it in
'toolbox', reading their names, descriptions and arguments. When a task
needs a tool that is not there (fetching data, computing, reading a file),
it proposes a new one in the blueprint: a name, what it does, its
arguments and what it returns. $write_tools() then writes each new
tool's R code, a function wrapped in 'ellmer::tool()', into '$tool_code'.
The code only runs when $build() creates the tools, and
$design() shows it to you and asks first. You can edit
'$tool_code' before building. Created tools are added to '$toolbox', so
later designs can reuse them. Set 'allow_new_tools = FALSE' to restrict
the architect to your 'toolbox'.
**The built workflow.** Its first station, '"intake"', receives your request. Every agent is then sent the request, its own task and the results of the agents it depends on, and nothing else. A stage of several agents runs as a parallel group (between a '"fork_<n>"' and a '"join_<n>"' station) when 'parallel = TRUE', and one agent after another otherwise. The workflow's result is the last stage's output. It is built with 'use_cache = FALSE', since each agent reads the current request rather than only its station input.
The interview and design calls go through the architect's own 'llm_object', so they add to its turn history and its cost, like any [Agent]'s.
mini007::Agent -> ArchitectAgent
modelsNamed list of ellmer chat objects the architect may assign to the agents it designs.
model_notesNamed character vector of notes about the models (eg. '"fast but weak at reasoning"'), keyed by model label.
toolboxNamed list of ellmer tools the architect may assign, including the new tools it created.
allow_new_toolsWhether the architect may propose and write new tools.
tool_codeNamed character vector: the R code of each new tool,
written by $write_tools().
transcriptThe interview so far: a list of question/answer pairs, each with 'question', 'options' and 'answer'.
blueprintThe latest design, a 'mini007_blueprint', or 'NULL'.
workflowThe latest [Workflow] built by $build(), or
'NULL'.
built_agentsNamed list of the [Agent]s created by the latest
$build().
mini007::Agent$add_message()mini007::Agent$as_tool()mini007::Agent$clear_and_summarise_messages()mini007::Agent$clear_tools()mini007::Agent$clone_agent()mini007::Agent$export_messages_history()mini007::Agent$generate_and_register_tool()mini007::Agent$generate_execute_r_code()mini007::Agent$get_usage_stats()mini007::Agent$invoke()mini007::Agent$keep_last_n_messages()mini007::Agent$learn()mini007::Agent$list_tools()mini007::Agent$load_messages_history()mini007::Agent$plan_and_execute()mini007::Agent$register_tools()mini007::Agent$remove_tools()mini007::Agent$reset_conversation_history()mini007::Agent$set_budget()mini007::Agent$set_budget_policy()mini007::Agent$set_code_mode()mini007::Agent$set_memory()mini007::Agent$share_context_with()mini007::Agent$update_instruction()mini007::Agent$validate_response()new()Creates a new ArchitectAgent.
ArchitectAgent$new( name, llm_object, models = NULL, model_notes = NULL, toolbox = NULL, allow_new_tools = TRUE, budget = NA )
nameA short name for the architect (eg. '"architect"').
llm_objectThe ellmer chat object the architect itself uses to interview and design. It must support structured output.
modelsA named list of ellmer chat objects that the designed agents may use. Each name is the label the architect sees and assigns. Defaults to 'llm_object' alone, labelled with its model name.
model_notesOptional named character vector of notes about the models, keyed by label: strengths, limits, speed, reasoning effort.
toolboxOptional list of ellmer tools ('ellmer::tool()') the designed agents may use, or a single one.
allow_new_tools'[logical(1)]' Whether the architect may propose new tools and write their code. Defaults to 'TRUE'.
budgetBudget in US$ for the architect's own calls, as in [Agent].
\dontrun{
architect <- ArchitectAgent$new(
name = "architect",
llm_object = ellmer::chat_openai(model = "gpt-4.1", echo = "none"),
models = list(
"gpt-4.1-mini" = ellmer::chat_openai(model = "gpt-4.1-mini", echo = "none"),
"gpt-4.1" = ellmer::chat_openai(model = "gpt-4.1", echo = "none")
),
toolbox = list(
ellmer::tool(
function(wilaya) paste("Population data for", wilaya),
name = "wilaya_population",
description = "Population of an Algerian wilaya.",
arguments = list(wilaya = ellmer::type_string("The wilaya's name."))
)
)
)
# Asks its questions in the console, shows the blueprint and the code of
# any new tool, then builds it
wf <- architect$design(
"Write a short, well-sourced travel guide for any Algerian wilaya."
)
wf$visualize()
wf$run("Tamanrasset, with a focus on the Hoggar mountains")
}
add_tools()Adds ellmer tools to the toolbox the architect assigns from.
ArchitectAgent$add_tools(tools)
toolsAn ellmer tool ('ellmer::tool()') or a list of them.
The architect, invisibly.
design()Runs the whole design: interviews you, drafts a blueprint, shows it and, once you approve it, builds the workflow.
After showing the blueprint, it asks whether to build it. Answer '"yes"' to build, '"cancel"' to stop without building, or describe the changes you want and it revises the blueprint and asks again. When the blueprint has new tools, it then writes their code, shows it and asks again in the same way before running it.
ArchitectAgent$design( goal = NULL, max_questions = 8, ask = NULL, confirm = TRUE, parallel = TRUE )
goalOptional description of what the workflow should do. When 'NULL', the interview starts by asking for it.
max_questions'[integer(1)]' The largest number of interview questions. Defaults to 8.
ask'[function | NULL]' How questions are put to you: a
function(question, options) returning the answer as a string.
'options' is a character vector of suggested answers, possibly empty.
Defaults to a console prompt, which needs an interactive session.
confirm'[logical(1)]' Whether to show the blueprint and the code of new tools, and ask before building. With 'FALSE', the new tools' code runs without review. Defaults to 'TRUE'.
parallel'[logical(1)]' Passed to $build().
The built [Workflow], or 'NULL' (invisibly) when cancelled.
interview()Interviews you about the workflow you need, one question at a time, until the architect knows enough or 'max_questions' is reached. Answer '"done"' to stop early; an empty answer leaves that choice to the architect. Calling it again continues the same interview.
ArchitectAgent$interview(goal = NULL, max_questions = 8, ask = NULL)
goalOptional description of what the workflow should do.
max_questions'[integer(1)]' The largest number of questions.
ask'[function | NULL]' See $design().
The transcript (a list of question/answer pairs), invisibly.
draft_blueprint()Designs the agents and their stages from the interview.
ArchitectAgent$draft_blueprint()
The blueprint, a 'mini007_blueprint': a list with 'name', 'summary', 'priority', 'rationale', 'agents' (one list per agent, with 'name', 'instruction', 'task', 'model', 'effort', 'budget', 'tools', 'depends_on' and 'reason'), 'new_tools' (one list per tool to create, with 'name', 'description', 'arguments' and 'returns') and 'stages' (a list of character vectors of agent names; the agents of one stage can run in parallel).
revise()Revises the blueprint following your feedback (eg. '"use only two agents"' or '"put the reviewer on the strongest model"').
ArchitectAgent$revise(feedback)
feedbackWhat to change, in plain words.
The revised blueprint.
write_tools()Writes the R code of the blueprint's new tools into '$tool_code', without running it. Each tool is a function wrapped in 'ellmer::tool()'. Tools already in '$toolbox' are skipped.
ArchitectAgent$write_tools(feedback = NULL)
feedbackOptional changes to make to the code already written, in plain words. All the new tools are then rewritten.
'$tool_code', invisibly.
build()Creates the blueprint's agents and wires them into a [Workflow].
New tools are created first: their code is written with
$write_tools() if it has not been yet, then run, and each tool
is added to ‘$toolbox'. When a tool’s code fails to run, the
architect is given the error and rewrites it, up to twice. Agents with
tools are built as [ReActAgent]s.
ArchitectAgent$build(blueprint = self$blueprint, parallel = TRUE)
blueprintThe blueprint to build. Defaults to '$blueprint'.
parallel'[logical(1)]' Whether a stage of several agents runs
as a parallel group. If so, daemons are started (one per agent of
the widest stage) unless the session already has enough; shut them
down with wf$set_daemons(0). With 'FALSE', its agents run one after
another. Defaults to 'TRUE'.
The [Workflow]. The agents are in '$built_agents'.
clone()The objects of this class are cloneable with this method.
ArchitectAgent$clone(deep = FALSE)
deepWhether to make a deep clone.
## ------------------------------------------------
## Method `ArchitectAgent$new`
## ------------------------------------------------
## Not run:
architect <- ArchitectAgent$new(
name = "architect",
llm_object = ellmer::chat_openai(model = "gpt-4.1", echo = "none"),
models = list(
"gpt-4.1-mini" = ellmer::chat_openai(model = "gpt-4.1-mini", echo = "none"),
"gpt-4.1" = ellmer::chat_openai(model = "gpt-4.1", echo = "none")
),
toolbox = list(
ellmer::tool(
function(wilaya) paste("Population data for", wilaya),
name = "wilaya_population",
description = "Population of an Algerian wilaya.",
arguments = list(wilaya = ellmer::type_string("The wilaya's name."))
)
)
)
# Asks its questions in the console, shows the blueprint and the code of
# any new tool, then builds it
wf <- architect$design(
"Write a short, well-sourced travel guide for any Algerian wilaya."
)
wf$visualize()
wf$run("Tamanrasset, with a focus on the Hoggar mountains")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.