From 9e056bdcf0123d256eb5cbedf03a6322006db9d1 Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Mon, 16 Mar 2026 12:37:47 -0600 Subject: [PATCH] feat: Added support for specifying a custom response to multiple-choice prompts when nothing suits the user's needs --- src/function/user_interaction.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/function/user_interaction.rs b/src/function/user_interaction.rs index 501e069..e9af532 100644 --- a/src/function/user_interaction.rs +++ b/src/function/user_interaction.rs @@ -12,6 +12,7 @@ use tokio::sync::oneshot; pub const USER_FUNCTION_PREFIX: &str = "user__"; const DEFAULT_ESCALATION_TIMEOUT_SECS: u64 = 300; +const CUSTOM_MULTI_CHOICE_ANSWER_OPTION: &str = "Other (custom)"; pub fn user_interaction_function_declarations() -> Vec { vec![ @@ -151,9 +152,14 @@ fn handle_direct_ask(args: &Value) -> Result { .get("question") .and_then(Value::as_str) .ok_or_else(|| anyhow!("'question' is required"))?; - let options = parse_options(args)?; + let mut options = parse_options(args)?; + options.push(CUSTOM_MULTI_CHOICE_ANSWER_OPTION.to_string()); - let answer = Select::new(question, options).prompt()?; + let mut answer = Select::new(question, options).prompt()?; + + if answer == CUSTOM_MULTI_CHOICE_ANSWER_OPTION { + answer = Text::new("Custom response:").prompt()? + } Ok(json!({ "answer": answer })) }