Each agent receives the previous agent's output as its message (the first
receives input), transforms it according to its persona, and hands the
result on. A common use is a fixed sequence of narrow specialists:
extract, then translate, then critique. Each stage is easy to inspect,
test, and swap.
Arguments
- agents
A list of Agents, in order. A single agent is allowed.
- input
The text handed to the first agent.
- quiet
If FALSE (default), each stage's output prints as it arrives.
- ...
Passed to each agent's underlying LLMR call.
Value
An object of class agent_pipeline_run: a list with steps
(tibble: step, agent, input, output) and output (the final
text). as.data.frame() returns the steps.
Details
Stages are stateless (reply()), so the same agents can serve in several
pipelines, and a pipeline can run many inputs without cross-contamination.
Every intermediate product is kept: the returned steps tibble has one
row per stage with the exact input and output of each agent.
See also
agent_as_tool() for model-directed (rather than fixed) routing.
Examples
if (FALSE) { # \dontrun{
cfg <- LLMR::llm_config("groq", "openai/gpt-oss-20b", temperature = 0.3)
run <- agent_pipeline(
list(
agent("Extractor", cfg, persona =
"Extract every factual claim as a numbered list. Nothing else."),
agent("Checker", cfg, persona =
"For each numbered claim, mark VERIFIABLE or VAGUE, one line each."),
agent("Editor", cfg, persona =
"Rewrite the original message keeping only VERIFIABLE claims.")
),
input = "Our app doubled retention, won three awards, and users love it."
)
run$output # the final text
run$steps # every intermediate product
} # }