askFollowUp
Ask follow-up questions about the previous terminal command's execution and output without re-running the command. Requires prior use of runAndExtract.
Instructions
Ask follow-up questions about the previous terminal command execution without re-running the command. Only available after using runAndExtract tool.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| question | Yes | Follow-up question about the previous terminal command execution and its output |
Implementation Reference
- src/tools/askFollowUp.ts:21-51 (handler)The execute() method is the main handler for the askFollowUp tool. It validates the 'question' parameter, loads the previous terminal session via SessionManager, and delegates to processFollowUpQuestion(). If no session exists, it returns an error instructing the user to run runAndExtract first.
async execute(args: any): Promise<MCPToolResponse> { try { this.logOperation('Follow-up question started', { question: args.question }); // Validate required fields const fieldError = this.validateRequiredFields(args, ['question']); if (fieldError) { return this.createErrorResponse(fieldError); } // Load previous terminal session const session = await SessionManager.loadTerminalSession(); if (!session) { return this.createErrorResponse( 'No recent terminal execution found. Please use the runAndExtract tool first to execute a command, then you can ask follow-up questions about its output.' ); } // Process follow-up question with LLM const answer = await this.processFollowUpQuestion(session, args.question); this.logOperation('Follow-up question completed successfully'); return this.createSuccessResponse(answer); } catch (error) { this.logOperation('Follow-up question failed', { error }); return this.createErrorResponse( `Follow-up question failed: ${error instanceof Error ? error.message : String(error)}` ); } } - src/tools/askFollowUp.ts:53-69 (helper)processFollowUpQuestion() is a private helper that retrieves LLM configuration, creates an LLM provider, builds a prompt via createFollowUpPrompt(), sends it to the LLM, and returns the response content.
private async processFollowUpQuestion( session: any, question: string ): Promise<string> { const config = ConfigurationManager.getConfig(); const provider = LLMProviderFactory.createProvider(config.llm.provider); const apiKey = this.getApiKey(config.llm.provider, config.llm); const prompt = this.createFollowUpPrompt(session, question); const response = await provider.processRequest(prompt, config.llm.model, apiKey); if (!response.success) { throw new Error(`LLM processing failed: ${response.error}`); } return response.content; } - src/tools/askFollowUp.ts:71-92 (helper)createFollowUpPrompt() builds the system prompt for the LLM. It includes the previous command, working directory, exit code, extraction prompt, previously extracted info, the follow-up question, and the original command output. It instructs the LLM to be specific, reference original output, and use markdown.
private createFollowUpPrompt(session: any, question: string): string { return `You are answering a follow-up question about a previous terminal command execution. Previous command: ${session.command} Working directory: ${session.workingDirectory} Exit code: ${session.exitCode} Original extraction request: ${session.extractionPrompt} Previously extracted information: ${session.extractedInfo} Follow-up question: ${question} Context - Original command output: ${session.output} Instructions: - Answer the follow-up question based on the command output and context - Reference the original output when needed - Be specific and helpful - If the question cannot be answered from the available information, say so clearly - Use markdown formatting for better readability - Be concise but thorough in your response`; } - src/tools/askFollowUp.ts:94-101 (helper)getApiKey() retrieves the API key for the configured LLM provider from the config object, throwing an error if not found.
private getApiKey(provider: string, llmConfig: any): string { const keyField = `${provider}Key`; const key = llmConfig[keyField]; if (!key) { throw new Error(`API key not configured for provider: ${provider}`); } return key; } - src/tools/askFollowUp.ts:10-19 (schema)The inputSchema defines the tool's input: a required 'question' string describing the follow-up question about the previous terminal command execution.
readonly inputSchema = { type: 'object', properties: { question: { type: 'string', description: 'Follow-up question about the previous terminal command execution and its output' } }, required: ['question'] }; - src/server.ts:64-64 (registration)The AskFollowUpTool is instantiated and registered in the server's tools map alongside other tools (AskAboutFileTool, RunAndExtractTool, ResearchTopicTool, DeepResearchTool).
new AskFollowUpTool(), - src/server.ts:33-33 (registration)Import statement for the AskFollowUpTool class in src/server.ts.
import { AskFollowUpTool } from './tools/askFollowUp';