ask_yes_no
Enables LLMs to seek user clarification or verification by prompting a yes/no question, ensuring accurate responses and intent alignment.
Instructions
Ask a yes/no confirmation question to the user when the AI needs clarification or verification
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| question | Yes | The yes/no confirmation question to ask the user |
Implementation Reference
- src/index.ts:945-995 (handler)The main handler function for the 'ask_yes_no' tool. It extracts the question from args, creates an elicitation schema for a boolean answer, sends the request via sendElicitationRequest, and returns the user's yes/no response.private async handleAskYesNo(args: Record<string, unknown>) { const question = typeof args.question === "string" ? args.question : "Please answer yes or no"; const elicitationParams: ElicitationParams = { message: question, requestedSchema: { type: "object", properties: { answer: { type: "boolean", title: "Your Answer", description: "Please select yes or no", }, }, required: ["answer"], }, // Use default timeout instead of hardcoded short timeout timeoutMs: this.config.defaultTimeoutMs, }; try { const response = await this.sendElicitationRequest(elicitationParams); if (response.action === "accept" && response.content) { return { content: [ { type: "text", text: `User answered: ${response.content.answer ? "Yes" : "No"}`, }, ], }; } else { return { content: [ { type: "text", text: `User ${response.action}ed the question.`, }, ], }; } } catch (error) { return this.createErrorResponse( `Elicitation request failed: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/index.ts:244-260 (schema)Defines the tool schema including name, description, and inputSchema requiring a 'question' string.private createAskYesNoTool(): Tool { return { name: "ask_yes_no", description: "Ask a yes/no confirmation question to the user when the AI needs clarification or verification", inputSchema: { type: "object", properties: { question: { type: "string", description: "The yes/no confirmation question to ask the user", }, }, required: ["question"], }, }; }
- src/index.ts:232-241 (registration)Registers the ask_yes_no tool by including createAskYesNoTool() in the list of available tools returned by getToolDefinitions().return [ this.createAskYesNoTool(), this.createConfirmActionTool(), this.createClarifyIntentTool(), this.createVerifyUnderstandingTool(), this.createCollectRatingTool(), this.createElicitCustomTool(), this.createSearchLogsTool(), this.createAnalyzeLogsTool(), ];
- src/index.ts:518-519 (registration)Registers the handler for 'ask_yes_no' in the tool dispatch switch statement within executeToolCall.case "ask_yes_no": return await this.handleAskYesNo(args);