Expand description
User interaction types and tools.
This module provides types and tools for agent-user interaction:
ConfirmationRequest/ConfirmationResponse- For tool confirmationsQuestionRequest/QuestionResponse- For agent-initiated questionsAskUserQuestionTool- Tool that allows agents to ask questions
§Confirmation Flow
When an agent needs to execute a tool that requires confirmation:
- Agent hooks create a
ConfirmationRequest - UI displays the request to the user
- User responds with
ConfirmationResponse - Agent proceeds based on the response
§Question Flow
When an agent needs to ask the user a question:
- Agent calls
ask_usertool with aQuestionRequest - UI displays the question to the user
- User responds with
QuestionResponse - Agent receives the answer and continues
§Example
use agent_sdk::user_interaction::{AskUserQuestionTool, QuestionRequest, QuestionResponse};
use tokio::sync::mpsc;
// Create channels for communication
let (tool, mut request_rx, response_tx) = AskUserQuestionTool::with_channels(10);
// The tool can be registered with the agent's tool registry
// The UI handles requests and responses through the channelsStructs§
- AskUser
Question Tool - Tool that allows the agent to ask questions to the user.
- Confirmation
Request - Request for user confirmation of a tool execution.
- Question
Option - An option in a multiple-choice question.
- Question
Request - Request for user to answer a question from the agent.
- Question
Response - Response to a question request.
Enums§
- Confirmation
Response - Response to a confirmation request.