Module user_interaction

Module user_interaction 

Source
Expand description

User interaction types and tools.

This module provides types and tools for agent-user interaction:

§Confirmation Flow

When an agent needs to execute a tool that requires confirmation:

  1. Agent hooks create a ConfirmationRequest
  2. UI displays the request to the user
  3. User responds with ConfirmationResponse
  4. Agent proceeds based on the response

§Question Flow

When an agent needs to ask the user a question:

  1. Agent calls ask_user tool with a QuestionRequest
  2. UI displays the question to the user
  3. User responds with QuestionResponse
  4. 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 channels

Structs§

AskUserQuestionTool
Tool that allows the agent to ask questions to the user.
ConfirmationRequest
Request for user confirmation of a tool execution.
QuestionOption
An option in a multiple-choice question.
QuestionRequest
Request for user to answer a question from the agent.
QuestionResponse
Response to a question request.

Enums§

ConfirmationResponse
Response to a confirmation request.