Skip to contents

Agents

Create an agent, run a task, and inspect what happened.

Agent
Agent that runs tasks with tools
AgentResult()
Create an agent run result
result_is_success()
Check whether a run completed
result_n_turns()
Count the turns in a result
result_text_chunks()
Get the streamed text chunks from a result
result_tool_calls()
Get the tool calls from a result
result_tool_results()
Get the finished tool calls from a result
AgentEvent()
Create an agent event
AgentUsage()
Create a usage record
UsageLimits()
Set usage limits for a run

Conversations and context

Keep long conversations within the model’s context window.

ContextPolicy()
Configure automatic context management
DeputyCompaction()
Create a compaction result

Built-in tools

Tools for files, data, the web and code, and presets that bundle them.

tools_preset()
Get a tool preset by name
tools_file()
Get the basic file tools
tools_code()
Get the code execution tools
tools_data()
Get the data reading tools
tools_web()
Get web tools
tools_all()
Get all built-in tools
tool_read_file()
Read file contents
tool_read_markdown()
Convert a file to Markdown using MarkItDown
tool_write_file()
Write content to a file
tool_edit_file()
Edit file contents by replacing text
tool_multi_edit()
Apply multiple text edits to a file
tool_list_files()
List files in a directory
tool_glob_files()
Find files using a glob pattern
tool_grep_files()
Search file contents with grep-like matching
tool_read_csv()
Read a CSV file
tool_run_r_code()
Execute R code
tool_run_bash()
Execute bash commands
tool_web_fetch()
Fetch web page content
tool_web_search()
Search the web
tool_metadata()
Inspect a tool's origin and annotations

Running code

Persistent R sessions and OS-sandboxed interpreters.

RSession
Persistent R session for a conversation
tools_mcp_repl()
Load sandboxed R tools from mcp-repl
mcp_repl_connection()
Connect an agent to a sandboxed mcp-repl session
mcp_repl_control()
Interrupt or reset an mcp-repl session
mcp_console_connection()
Connect an agent to a sandboxed MCP Console session
mcp_console_control()
Interrupt or restart an MCP Console session

MCP servers

Use tools, resources and prompts from Model Context Protocol servers.

tools_mcp()
Get tools from MCP servers
McpConnection
MCP server connection

Permissions

Decide which tool calls an agent may make.

Permissions()
Create a permission policy
permissions_standard()
Create a standard permission policy
permissions_readonly()
Create a read-only permission policy
permissions_plan()
Create a planning permission policy
permissions_full()
Create a full access permission policy
PermissionMode
Permission modes
permissions_check()
Check a tool call against a permission policy
PermissionResultAllow()
Create an allow permission result
PermissionResultDeny()
Create a deny permission result
PermissionResultPending()
Pause a tool call for approval

Human input and approvals

Ask a person questions, and hold tool calls until someone approves them.

tools_interactive()
Create an ask_user tool with its own handler
tool_ask_user()
Ask the user questions
AskUserDeferred()
Defer answers to a later user turn
set_ask_user_callback()
Set a process-wide handler for ask_user
approval_read()
Read a pending approval
ApprovalContinuation()
Pending approval record
approval_review_ui() approval_review_server()
Review a pending tool call in Shiny
tool_input_review()
Tabulate a tool call's arguments for review

Trusted results

Make one tool the only source of each kind of result.

TrustedResults()
Designate trusted tools
result_trusted_results()
Get the trusted results from a run

Hooks

Run R code at fixed points in an agent’s lifecycle.

HookEvent
Hook events
HookMatcher()
Create a hook
hook_matches()
Test whether a hook matches a tool name
hook_log_tools()
Create a hook that logs tool calls
hook_block_dangerous_bash()
Create a hook that blocks dangerous bash commands
hook_limit_file_writes()
Create a hook that limits file writes to a directory
HookResultPreToolUse()
Create a PreToolUse hook result
HookResultPostToolUse()
Create a PostToolUse hook result
HookResultPreCompact()
Create a PreCompact hook result
HookResult() PermissionResult()
Hook and permission results

Skills

Package instructions and tools for reuse.

Skill()
Reusable instructions and tools
skill_create()
Create a skill in code
skill_load()
Load a skill from a directory
skills_list()
List available skills in a directory
skill_check_requirements()
Check a skill's requirements

Subagents

Delegate parts of a task from a lead agent to specialists.

LeadAgent
Agent that delegates to subagents
AgentDefinition() agent_definition()
Define a subagent
agent_definition_read() agent_definition_write() agent_definitions()
Read and write agent definition files
DelegationInput()
Describe a task for a subagent
DelegationPolicy()
Configure subagent tools, hooks and user input
DelegationResources()
Return tools from a resource factory
DelegationManifest()
Record what a subagent started with
DelegationOutcome()
Result of a delegation
DelegationDisclosure()
Control who can inspect subagents
delegation_history()
Replay saved subagent history
DelegationObservation()
Set limits for the subagent event buffer
DelegationSubscription
Subscription to subagent events
subagent_chat_ui() subagent_chat_server()
Show subagent conversations in a Shiny panel

Retained specialists

Keep a specialist’s conversation across several delegations.

adopt_chat()
Turn an ellmer chat into a retained agent
delegation_tool()
Create a tool that calls a retained agent
ContextFork()
Capture conversation turns for a fork
fork_agent()
Start a retained agent from a conversation fork

Background jobs

Queue work in one R process and run it in another.

job_create()
Create a background job
job_run()
Run a background job
job_read()
Read a background job
job_cancel()
Cancel a background job
AgentJob()
Background job record

Errors

Catch Deputy errors by class.

deputy-errors DeputyError
Deputy error classes
is_deputy_error()
Check whether a condition is a Deputy error