Factory function to create a CodeActModule that can use both tools and
R code execution to solve problems.
Use run() to execute it. run_async() supports factory-backed modules;
async streaming and module $stream() reject CodeAct. run_stream()
preserves the synchronous forward() fallback unless a matching
token-stream request is active; that request is rejected first.
Arguments
- signature
A Signature object or string notation defining inputs/outputs
- tools
List of ellmer ToolDef objects for the agent to use. Non-empty list element names become the registered tool names; unnamed elements keep their ToolDef name. Effective names may contain only letters, numbers, hyphens, and underscores.
- runner
Optional caller-owned code runner implementing
execute()andpolicy(). It is retained, never automatically shut down, and must not be shared concurrently when persistent.- interpreter_factory
Optional zero-argument function returning a fresh runner with
execute(),policy(), optionalstart(), and idempotent terminalshutdown(). Supply exactly one ofrunnerandinterpreter_factory.- max_iterations
Maximum outer agent iterations and maximum tool calls within one invocation (default 10). Exceeding the inner tool-call budget raises a
dsprrr_codeact_iteration_limiterror.- config
Optional prediction configuration.
- chat
Optional ellmer Chat object.
- ...
Must be empty.
Examples
if (FALSE) { # \dontrun{
runner <- r_code_runner(timeout = 30)
agent <- code_act(
"question -> answer",
tools = list(),
runner = runner
)
result <- run(agent, question = "Calculate 2^10", .llm = llm)
} # }