(
&self,
args: serde_json::Value,
_ctx: ToolContext,
)
| 97 | } |
| 98 | |
| 99 | async fn execute( |
| 100 | &self, |
| 101 | args: serde_json::Value, |
| 102 | _ctx: ToolContext, |
| 103 | ) -> Result<ToolResult, ToolError> { |
| 104 | let input: QuestionInput = |
| 105 | serde_json::from_value(args).map_err(|e| ToolError::InvalidArguments(e.to_string()))?; |
| 106 | |
| 107 | let mut all_answers: Vec<String> = Vec::new(); |
| 108 | |
| 109 | for q in input.questions.iter() { |
| 110 | let answer = ask_question(q)?; |
| 111 | all_answers.extend(answer); |
| 112 | } |
| 113 | |
| 114 | let response = QuestionResponse { |
| 115 | answers: all_answers, |
| 116 | }; |
| 117 | |
| 118 | let output = serde_json::to_string_pretty(&response) |
| 119 | .unwrap_or_else(|_| format!("{:?}", response.answers)); |
| 120 | |
| 121 | Ok(ToolResult { |
| 122 | title: "User response received".to_string(), |
| 123 | output, |
| 124 | metadata: std::collections::HashMap::new(), |
| 125 | truncated: false, |
| 126 | }) |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | fn ask_question(q: &QuestionDef) -> Result<Vec<String>, ToolError> { |
nothing calls this directly
no test coverage detected