Skip to main content

vtcode_core/tools/
request_user_input.rs

1use anyhow::{Result, anyhow};
2use async_trait::async_trait;
3use serde_json::Value;
4use vtcode_utility_tool_specs::{request_user_input_description, request_user_input_parameters};
5
6use crate::config::constants::tools;
7use crate::tool_policy::ToolPolicy;
8use crate::tools::traits::Tool;
9
10/// Tool declaration for requesting structured user input mid-turn.
11///
12/// This tool allows the LLM to ask 1-3 short questions with optional multiple-choice
13/// options.
14///
15/// The actual interactive UI implementation is provided by the VT Code front-end
16/// (TUI runloop) which can intercept this tool call and present a modal.
17pub struct RequestUserInputTool;
18
19#[async_trait]
20impl Tool for RequestUserInputTool {
21    async fn execute(&self, _args: Value) -> Result<Value> {
22        Err(anyhow!(
23            "request_user_input requires an interactive UI session and is handled by the VT Code front-end"
24        ))
25    }
26
27    fn name(&self) -> &str {
28        tools::REQUEST_USER_INPUT
29    }
30
31    fn description(&self) -> &str {
32        request_user_input_description()
33    }
34
35    fn parameter_schema(&self) -> Option<Value> {
36        Some(request_user_input_parameters())
37    }
38
39    fn default_permission(&self) -> ToolPolicy {
40        // Asking the user is always safe; it is still gated by interactive availability.
41        ToolPolicy::Allow
42    }
43
44    fn is_mutating(&self) -> bool {
45        false
46    }
47
48    fn is_parallel_safe(&self) -> bool {
49        false
50    }
51
52    fn kind(&self) -> &'static str {
53        "hitl"
54    }
55}