finalize_conversation
End a conversation session and retrieve a tailored summary in formats like detailed, concise, or actionable, aiding in final code analysis and decision-making.
Instructions
Complete the conversation and get final analysis results
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes | ID of the conversation session | |
| summary_format | No | Format for the final summary |
Implementation Reference
- src/index.ts:118-121 (schema)Zod schema definition for validating the input parameters of the finalize_conversation tool (session_id required, summary_format optional).const FinalizeConversationSchema = z.object({ session_id: z.string(), summary_format: z.enum(['detailed', 'concise', 'actionable']).optional(), });
- src/index.ts:384-402 (registration)Registration of the finalize_conversation tool in the MCP server's list of tools, including name, description, and input schema.{ name: 'finalize_conversation', description: 'Complete the conversation and get final analysis results', inputSchema: { type: 'object', properties: { session_id: { type: 'string', description: 'ID of the conversation session', }, summary_format: { type: 'string', enum: ['detailed', 'concise', 'actionable'], description: 'Format for the final summary', }, }, required: ['session_id'], }, },
- src/index.ts:697-712 (handler)MCP server request handler for call_tool requests: parses args with schema, delegates to DeepCodeReasonerV2.finalizeConversation, returns result as text content.case 'finalize_conversation': { const parsed = FinalizeConversationSchema.parse(args); const result = await deepReasoner.finalizeConversation( parsed.session_id, parsed.summary_format, ); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- Intermediate handler in DeepCodeReasonerV2: acquires conversation lock, validates session, delegates to ConversationalGeminiService.finalizeConversation, merges results with conversation metadata.async finalizeConversation( sessionId: string, summaryFormat?: 'detailed' | 'concise' | 'actionable', ): Promise<DeepAnalysisResult> { // Acquire lock before processing const lockAcquired = this.conversationManager.acquireLock(sessionId); if (!lockAcquired) { throw new ConversationLockedError(sessionId); } try { // Validate session const session = this.conversationManager.getSession(sessionId); if (!session) { throw new SessionNotFoundError(sessionId); } // Get final analysis from Gemini const result = await this.conversationalGemini.finalizeConversation( sessionId, summaryFormat || 'detailed', ); // Extract additional insights from conversation manager const conversationResults = this.conversationManager.extractResults(sessionId); // Merge results return { ...result, metadata: { ...result.metadata, ...conversationResults.metadata, }, }; } catch (error) { console.error('Failed to finalize conversation:', error); throw error; } finally { // Always release lock this.conversationManager.releaseLock(sessionId); } }
- Core implementation: retrieves Gemini chat session, sends synthesis prompt for final summary based on conversation history, parses response into structured DeepAnalysisResult, cleans up session.async finalizeConversation( sessionId: string, summaryFormat: 'detailed' | 'concise' | 'actionable' = 'detailed', ): Promise<DeepAnalysisResult> { const chat = this.activeSessions.get(sessionId); const context = this.sessionContexts.get(sessionId); if (!chat || !context) { throw new SessionNotFoundError(sessionId); } // Request final synthesis const synthesisPrompt = this.buildSynthesisPrompt(summaryFormat); const result = await chat.sendMessage(synthesisPrompt); const finalAnalysis = result.response.text(); // Parse and structure the final results const structuredResult = this.parseConversationalAnalysis( finalAnalysis, context.claudeContext, ); // Clean up session this.activeSessions.delete(sessionId); this.sessionContexts.delete(sessionId); return structuredResult; }