/**
* Suggest Follow-up Questions Prompt
*
* A prompt template for generating intelligent follow-up questions
* based on human responses in human-in-the-loop workflows.
*/
import {
type PromptMessage,
type GetPromptResult,
type PromptArgument
} from '@modelcontextprotocol/sdk/types.js';
/**
* Arguments for the suggest follow-up questions prompt template
*/
export interface SuggestFollowUpArgs {
originalQuestion: string;
response: string;
goal?: string;
responseType?: 'open' | 'multiple-choice' | 'hypothesis';
}
/**
* Prompt definition for suggesting follow-up questions
*/
export const SUGGEST_FOLLOW_UP_PROMPT = {
name: 'suggest-follow-up-questions',
description: 'Generate intelligent follow-up questions based on human responses to maintain effective conversation flow',
arguments: [
{
name: 'originalQuestion',
description: 'The initial question that was asked to the human',
required: true
},
{
name: 'response',
description: 'The human response that was received',
required: true
},
{
name: 'goal',
description: 'The ultimate objective or purpose of the questioning (optional)',
required: false
},
{
name: 'responseType',
description: 'Type of response received: open, multiple-choice, or hypothesis',
required: false
}
] as PromptArgument[]
} as const;
/**
* Generate follow-up questions based on human response
*
* @param args Arguments for prompt generation
* @returns Formatted prompt with suggested follow-up questions
*
* @example
* ```typescript
* const result = await generateSuggestFollowUpPrompt({
* originalQuestion: "What features should we prioritize for the next release?",
* response: "User authentication and dashboard improvements are most important",
* goal: "Create a product roadmap",
* responseType: "open"
* });
* ```
*/
export async function generateSuggestFollowUpPrompt(args: SuggestFollowUpArgs): Promise<GetPromptResult> {
const { originalQuestion, response, goal, responseType = 'open' } = args;
let promptText = `Based on the following human interaction, please suggest intelligent follow-up questions to gather more detailed information:
**Original Question:** ${originalQuestion}
**Human Response:** ${response}`;
if (goal) {
promptText += `\n\n**Overall Goal:** ${goal}`;
}
promptText += `\n\n**Response Type:** ${responseType}`;
promptText += `\n\nPlease analyze the response and suggest 3-5 prioritized follow-up questions that would:
1. **Clarify ambiguities** - Address any unclear or vague aspects of the response
2. **Drill deeper** - Explore important details that weren't fully explained
3. **Explore implications** - Understand the broader context and consequences
4. **Validate assumptions** - Confirm any implicit assumptions in the response
5. **Gather specifics** - Collect concrete details, timelines, or metrics
For each suggested question, provide:
- The question text (formatted appropriately for the response type)
- Priority level (High/Medium/Low)
- Reasoning for why this question is important
- Suggested question type (open-ended, multiple-choice, or hypothesis)
Format your response as:
## Suggested Follow-up Questions
### Question 1 (Priority: High)
**Question:** [question text]
**Type:** [open-ended/multiple-choice/hypothesis]
**Reasoning:** [why this question is important]
### Question 2 (Priority: Medium)
...
## Analysis Summary
Briefly explain what additional information would be most valuable to gather and why.`;
const messages: PromptMessage[] = [
{
role: 'user',
content: {
type: 'text',
text: promptText
}
}
];
return {
description: `Follow-up question suggestions for: "${originalQuestion.substring(0, 80)}${originalQuestion.length > 80 ? '...' : ''}"`,
messages
};
}