clarify_intent
Identify and resolve ambiguity in user requests by presenting clear options for clarification, ensuring accurate interpretation and response from the AI system.
Instructions
Ask user to clarify their intent when the request is ambiguous or could be interpreted multiple ways
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ambiguity | Yes | Description of what is unclear or ambiguous | |
| options | No | Possible interpretations or options for the user to choose from | |
| request_summary | Yes | Summary of what the AI understood from the user's request |
Implementation Reference
- src/index.ts:756-823 (handler)The handler function that implements the core logic for the "clarify_intent" tool. It constructs an elicitation message and schema based on input args (request_summary, ambiguity, options), sends an elicitation request to the user via sendElicitationRequest, and returns the formatted user response or error.private async handleClarifyIntent(args: Record<string, unknown>) { const request_summary = typeof args.request_summary === "string" ? args.request_summary : "Unknown request"; const ambiguity = typeof args.ambiguity === "string" ? args.ambiguity : "Unknown ambiguity"; const options = Array.isArray(args.options) ? args.options : undefined; let message = `I need to clarify your intent:\n\n**My understanding**: ${request_summary}\n\n**What's unclear**: ${ambiguity}`; const schema: ElicitationSchema = { type: "object", properties: {}, required: ["clarification"], }; // Add selected_option FIRST if options exist (for better UX - selection before free text) if (options && options.length > 0) { message += `\n\n**Options**:\n${options.map((opt: unknown, i: number) => `${i + 1}. ${String(opt)}`).join("\n")}`; schema.properties.selected_option = { type: "string", title: "Select Option", description: "Which option best matches your intent?", enum: options.map((opt) => String(opt)), }; } // Add clarification field AFTER options (better UX - free text input comes after selection) schema.properties.clarification = { type: "string", title: "Additional clarification", description: "Please provide any additional details or explanation", }; const elicitationParams: ElicitationParams = { message, requestedSchema: schema, }; try { const response = await this.sendElicitationRequest(elicitationParams); if (response.action === "accept") { return { content: [ { type: "text", text: `User clarification:\n${JSON.stringify(response.content, null, 2)}`, }, ], }; } else { return { content: [ { type: "text", text: `User ${response.action}ed the clarification request.`, }, ], }; } } catch (error) { return this.createErrorResponse( `Clarification request failed: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/index.ts:293-315 (schema)Input schema defining the parameters for the clarify_intent tool: required request_summary and ambiguity (strings), optional options array of strings.inputSchema: { type: "object", properties: { request_summary: { type: "string", description: "Summary of what the AI understood from the user's request", }, ambiguity: { type: "string", description: "Description of what is unclear or ambiguous", }, options: { type: "array", items: { type: "string", }, description: "Possible interpretations or options for the user to choose from", }, }, required: ["request_summary", "ambiguity"], },
- src/index.ts:288-317 (registration)Factory method that creates and returns the Tool definition for "clarify_intent", including name, description, and inputSchema. This is returned in the tool list.private createClarifyIntentTool(): Tool { return { name: "clarify_intent", description: "Ask user to clarify their intent when the request is ambiguous or could be interpreted multiple ways", inputSchema: { type: "object", properties: { request_summary: { type: "string", description: "Summary of what the AI understood from the user's request", }, ambiguity: { type: "string", description: "Description of what is unclear or ambiguous", }, options: { type: "array", items: { type: "string", }, description: "Possible interpretations or options for the user to choose from", }, }, required: ["request_summary", "ambiguity"], }, }; }
- src/index.ts:522-523 (registration)Switch case in the executeToolCall dispatcher that registers and routes calls to the clarify_intent handler.case "clarify_intent": return await this.handleClarifyIntent(args);
- src/index.ts:235-235 (registration)Call to createClarifyIntentTool() within getToolDefinitions(), which includes it in the list of available tools returned by the list tools handler.this.createClarifyIntentTool(),