Create an RLM whose implementation can adaptively explore R objects at inference time. Use RLM when the inspection path is not known in advance; use ordinary R when that path becomes stable, or Flex when labeled examples should discover a reusable implementation.
Arguments
- signature
A Signature object or string notation defining inputs/outputs with explicit ellmer string, number, integer, boolean, enum, array, or object output types. Opaque
TypeJsonSchemaoutputs are unsupported.- runner
Optional caller-owned code runner implementing
execute()andpolicy(). Its policy must declarepersistent = TRUE. It is retained, never automatically shut down, and must not be shared concurrently. For the trusted callr backend, user_code_runner(persistent = TRUE).- interpreter_factory
Optional zero-argument function returning a fresh runner with
execute(),policy(), optionalstart(), and idempotent terminalshutdown(). Its policy must advertisepersistent = TRUEfor RLM. Supply exactly one ofrunnerandinterpreter_factory.- max_iterations
Maximum REPL iterations before fallback (default 20)
- max_llm_calls
Maximum recursive LLM calls allowed (default 50)
- max_output_chars
Maximum model-visible characters per execution output. Longer output is shown as a head-and-tail excerpt. Default 10000.
- sub_lm
Optional ellmer Chat for recursive queries.
NULLinherits the invocation's outer Chat. Setmax_llm_calls = 0to disable recursion.- verbose
Logical. Print execution progress (default FALSE)
- tools
Named list of user-defined host functions or ellmer ToolDef objects. Guest code emits an invocation-bound request, dsprrr validates it and invokes the original function in the host, and the guest is replayed with the response. Closures are never deparsed or serialized into generated code. These tools execute in the host process, outside the guest runner sandbox, with the host's permissions. ToolDef schemas guide generation; the callable must still enforce semantic constraints beyond the bridge's lossless JSON-compatible value checks. A protocol safety ceiling permits at most 1,000 host-tool calls in one generated R step.
- config
Optional prediction configuration.
- chat
Optional ellmer Chat object.
- generate_action
Optional advanced action predictor.
- extract
Optional advanced extraction predictor.
- ...
Must be empty.
Examples
if (FALSE) { # \dontrun{
analyst <- rlm_module(
"document, question -> answer",
interpreter_factory = function() mcp_repl_runner(timeout = 30)
)
result <- run(
analyst,
document = "Owner: team-a\nObligation: rotate keys quarterly",
question = "Which obligations have no owner?",
.llm = ellmer::chat_openai()
)
} # }