A tool that reads the contents of a file and returns it as a string.
Usage
tool_read_file(path, pages = NULL)
Arguments
- path
Path to the file to read (tool argument, not R function argument)
- pages
Optional PDF page selection. Accepts comma-separated pages and
ranges (e.g. "1,3-5"). Only supported for PDF files.
Value
When called directly, a character string with the file contents, or
a structured list when selected PDF pages are requested.
Examples
if (FALSE) { # \dontrun{
agent <- Agent$new(
chat = ellmer::chat("openai/gpt-5.6-luna"),
tools = list(tool_read_file)
)
} # }