Skip to contents

Thin wrapper that shells out to the rmorie command-line agent (a separate, optional binary from rmorie-cli). The agent can run R, read/write files, remember notes, and use any configured model backend (Anthropic, OpenAI-compatible, Google Gemini, or a local Ollama model). The CLI is the single implementation; this function only forwards to it, so every MORIE package can offer agentic help without duplicating logic.

Usage

agent(task, model = NULL, backend = "auto", dry_run = FALSE)

Arguments

task

Character scalar. The task/prompt for the agent.

model

Optional model id, e.g. "claude-sonnet-5", "gpt-4o", "gemini-2.5-flash", or any tag your Ollama server serves. Defaults to the CLI's default model.

backend

Optional backend: "auto" (route on the model id), "anthropic", "openai", "gemini", or "ollama".

dry_run

Logical; if TRUE the agent only plans (no network).

Value

Character scalar: the agent's combined stdout/stderr.

Details

Requires the rmorie binary on PATH. Cloud backends read RMORIE_AGENT_API_KEY from the environment (the key is never passed through R). If the binary is absent a clear message is returned instead of an error.

Examples

# \donttest{
agent("use R to compute the mean of 1:10")
#> [1] "rmorie CLI not found on PATH. Install rmorie-cli to use agent()."
agent("summarize mtcars", model = "gemini-2.5-flash", backend = "gemini")
#> [1] "rmorie CLI not found on PATH. Install rmorie-cli to use agent()."
# }