create_ask_user_tool: Create an ask_user Tool

View source: R/tool_ask_user.R

create_ask_user_toolR Documentation

Create an ask_user Tool

Description

Creates a tool that allows an agent to pause execution and ask the user for help, clarification, or guidance. This is reserved for real user decisions such as destructive actions, credentials, cost/permission gates, ambiguous requirements, or information only the user can provide.

Usage

create_ask_user_tool()

Details

The ask_user tool lets agents pause for genuine user decisions instead of guessing through risks or missing requirements.

The tool accepts:

  • question: The main question or explanation to show the user (required)

  • context: Optional context about why the agent is asking (what was tried, what failed)

  • options: Optional list of suggested responses for the user to choose from

When options are provided, the user can either select a numbered option or type their own custom response.

Value

A Tool object that can be used with agents

Examples

## Not run: 
# Create the tool
ask_tool <- create_ask_user_tool()

# Use in an agent
agent <- Agent$new(
  name = "helper",
  tools = list(ask_tool, other_tools...)
)

# The agent can then use it when user input is required:
# ask_user(
#   question = "This will overwrite report.html. Should I continue?",
#   context = "The target file already exists in the project directory.",
#   options = ["Overwrite it", "Choose another path", "Cancel"]
# )

## End(Not run)


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