create_file_agent: Create a FileAgent

View source: R/stdlib_agents.R

create_file_agentR Documentation

Create a FileAgent

Description

Creates an agent specialized in file system operations using fs and readr. The agent can read, write, and manage files with safety guardrails.

Usage

create_file_agent(
  name = "FileAgent",
  allowed_dirs = ".",
  allowed_extensions = c("csv", "tsv", "txt", "json", "rds", "rda", "xlsx", "xls")
)

Arguments

name

Agent name. Default "FileAgent".

allowed_dirs

Character vector of allowed directories. Default current dir.

allowed_extensions

Character vector of allowed file extensions.

Value

An Agent object configured for file operations.

Examples


if (interactive()) {
  file_agent <- create_file_agent(
    allowed_dirs = c("./data", "./output"),
    allowed_extensions = c("csv", "json", "txt", "rds")
  )
  result <- file_agent$run(
    "Read the sales.csv file and store it as 'sales_data'",
    session = session,
    model = "openai:gpt-4o"
  )
}


aisdk documentation built on May 29, 2026, 9:07 a.m.