View source: R/tool_ask_user.R
| create_ask_user_tool | R Documentation |
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.
create_ask_user_tool()
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.
A Tool object that can be used with agents
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.