Preferred constructor for creating Agent objects. Wraps the
Agent R6 class.
Usage
agent(
name,
chat,
tools = list(),
system_prompt = NULL,
secure = FALSE,
sandbox = TRUE,
memory = NULL
)Chat Protocol
The chat object must implement these methods:
$chat(prompt)- Send a message and return the response text$get_turns()- Return the conversation history$set_turns(turns)- Replace the conversation history$clone(deep = TRUE)- Deep clone the chat object
See also
Other agents:
react_graph()
Examples
if (FALSE) { # \dontrun{
chat <- ellmer::chat_openai(model = "gpt-4o")
a <- agent("researcher", chat)
a$invoke("What is R?")
} # }