advanced_reasoning
Enhance complex reasoning with meta-cognitive assessment, hypothesis testing, and graph-based memory. Track confidence, validate evidence, and manage session context for systematic problem-solving and decision-making.
Instructions
Advanced cognitive reasoning tool that builds on sequential thinking with meta-cognition, hypothesis testing, and integrated memory.
Key Features:
Meta-cognitive assessment and confidence tracking
Hypothesis formulation and testing capabilities
Integrated graph-based memory system
Dynamic reasoning quality evaluation
Session-based context management
Evidence tracking and validation
Enhanced Parameters:
thought: Your reasoning step (required)
thoughtNumber/totalThoughts: Sequential tracking (required)
nextThoughtNeeded: Continue flag (required)
confidence: Self-assessment 0.0-1.0 (default: 0.5)
reasoning_quality: 'low'|'medium'|'high' (default: 'medium')
meta_thought: Reflection on your reasoning process
hypothesis: Current working hypothesis
test_plan: How to validate the hypothesis
test_result: Outcome of testing
evidence: Supporting/contradicting evidence
session_id: Link to reasoning session
goal: Overall objective
progress: 0.0-1.0 completion estimate
Branching (inherited from sequential thinking):
isRevision/revisesThought: Revise previous thoughts
branchFromThought/branchId: Explore alternatives
Use this tool for complex reasoning that benefits from:
Self-reflection and confidence tracking
Systematic hypothesis development
Memory of previous insights
Quality assessment of reasoning
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| branchFromThought | No | Branching point thought number | |
| branchId | No | Branch identifier | |
| builds_on | No | Previous thoughts this builds on | |
| challenges | No | Ideas this challenges or contradicts | |
| confidence | No | Confidence in this reasoning step (0.0-1.0) | |
| evidence | No | Evidence for/against hypothesis | |
| goal | No | Overall goal or objective | |
| hypothesis | No | Current working hypothesis | |
| isRevision | No | Whether this revises previous thinking | |
| meta_thought | No | Meta-cognitive reflection on your reasoning process | |
| needsMoreThoughts | No | If more thoughts are needed | |
| nextThoughtNeeded | Yes | Whether another thought step is needed | |
| progress | No | Progress toward goal (0.0-1.0) | |
| reasoning_quality | No | Assessment of reasoning quality | |
| revisesThought | No | Which thought is being reconsidered | |
| session_id | No | Reasoning session identifier | |
| test_plan | No | Plan for testing the hypothesis | |
| test_result | No | Result of hypothesis testing | |
| thought | Yes | Your current reasoning step | |
| thoughtNumber | Yes | Current thought number | |
| totalThoughts | Yes | Estimated total thoughts needed |
Implementation Reference
- src/index.ts:676-760 (handler)Main handler function that executes the advanced_reasoning tool logic: validates input, stores thoughts in memory, handles branching, logs formatted output, and returns structured response with memory stats.public processAdvancedThought(input: unknown): { content: Array<{ type: string; text: string }>; isError?: boolean } { try { const validatedInput = this.validateThoughtData(input); // Auto-adjust total thoughts if needed if (validatedInput.thoughtNumber > validatedInput.totalThoughts) { validatedInput.totalThoughts = validatedInput.thoughtNumber; } // Store in memory if session provided if (validatedInput.session_id) { const nodeId = this.memory.addNode( validatedInput.thought, 'thought', { confidence: validatedInput.confidence, reasoning_quality: validatedInput.reasoning_quality, thoughtNumber: validatedInput.thoughtNumber, hypothesis: validatedInput.hypothesis } ); // Update session context this.memory.updateSession(validatedInput.session_id, { currentFocus: validatedInput.thought, confidence: validatedInput.confidence, reasoning_quality: validatedInput.reasoning_quality, meta_assessment: validatedInput.meta_thought }); } // Add to history this.thoughtHistory.push(validatedInput); // Handle branching if (validatedInput.branchFromThought && validatedInput.branchId) { if (!this.branches[validatedInput.branchId]) { this.branches[validatedInput.branchId] = []; } this.branches[validatedInput.branchId].push(validatedInput); } // Format and log if (!this.disableLogging) { const formattedThought = this.formatAdvancedThought(validatedInput); console.error(formattedThought); } // Generate related memories if session provided let relatedMemories: MemoryNode[] = []; if (validatedInput.session_id) { relatedMemories = this.memory.queryRelated(validatedInput.thought, 3); } return { content: [{ type: "text", text: JSON.stringify({ thoughtNumber: validatedInput.thoughtNumber, totalThoughts: validatedInput.totalThoughts, nextThoughtNeeded: validatedInput.nextThoughtNeeded, confidence: validatedInput.confidence, reasoning_quality: validatedInput.reasoning_quality, meta_assessment: validatedInput.meta_thought, hypothesis: validatedInput.hypothesis, branches: Object.keys(this.branches), thoughtHistoryLength: this.thoughtHistory.length, memoryStats: this.memory.getMemoryStats(), relatedMemories: relatedMemories.map(m => ({ content: m.content, confidence: m.confidence })) }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ error: error instanceof Error ? error.message : String(error), status: 'failed' }, null, 2) }], isError: true }; } }
- src/index.ts:1045-1117 (schema)Tool schema definition including detailed input validation schema, description, and required parameters for the advanced_reasoning tool.const ADVANCED_REASONING_TOOL: Tool = { name: "advanced_reasoning", description: `Advanced cognitive reasoning tool that builds on sequential thinking with meta-cognition, hypothesis testing, and integrated memory. Key Features: - Meta-cognitive assessment and confidence tracking - Hypothesis formulation and testing capabilities - Integrated graph-based memory system - Dynamic reasoning quality evaluation - Session-based context management - Evidence tracking and validation Enhanced Parameters: - thought: Your reasoning step (required) - thoughtNumber/totalThoughts: Sequential tracking (required) - nextThoughtNeeded: Continue flag (required) - confidence: Self-assessment 0.0-1.0 (default: 0.5) - reasoning_quality: 'low'|'medium'|'high' (default: 'medium') - meta_thought: Reflection on your reasoning process - hypothesis: Current working hypothesis - test_plan: How to validate the hypothesis - test_result: Outcome of testing - evidence: Supporting/contradicting evidence - session_id: Link to reasoning session - goal: Overall objective - progress: 0.0-1.0 completion estimate Branching (inherited from sequential thinking): - isRevision/revisesThought: Revise previous thoughts - branchFromThought/branchId: Explore alternatives Use this tool for complex reasoning that benefits from: - Self-reflection and confidence tracking - Systematic hypothesis development - Memory of previous insights - Quality assessment of reasoning`, inputSchema: { type: "object", properties: { // Core sequential thinking fields thought: { type: "string", description: "Your current reasoning step" }, nextThoughtNeeded: { type: "boolean", description: "Whether another thought step is needed" }, thoughtNumber: { type: "integer", description: "Current thought number", minimum: 1 }, totalThoughts: { type: "integer", description: "Estimated total thoughts needed", minimum: 1 }, // Advanced cognitive fields confidence: { type: "number", description: "Confidence in this reasoning step (0.0-1.0)", minimum: 0, maximum: 1 }, reasoning_quality: { type: "string", description: "Assessment of reasoning quality", enum: ["low", "medium", "high"] }, meta_thought: { type: "string", description: "Meta-cognitive reflection on your reasoning process" }, goal: { type: "string", description: "Overall goal or objective" }, progress: { type: "number", description: "Progress toward goal (0.0-1.0)", minimum: 0, maximum: 1 }, // Hypothesis testing hypothesis: { type: "string", description: "Current working hypothesis" }, test_plan: { type: "string", description: "Plan for testing the hypothesis" }, test_result: { type: "string", description: "Result of hypothesis testing" }, evidence: { type: "array", items: { type: "string" }, description: "Evidence for/against hypothesis" }, // Memory and context session_id: { type: "string", description: "Reasoning session identifier" }, builds_on: { type: "array", items: { type: "string" }, description: "Previous thoughts this builds on" }, challenges: { type: "array", items: { type: "string" }, description: "Ideas this challenges or contradicts" }, // Branching (inherited) isRevision: { type: "boolean", description: "Whether this revises previous thinking" }, revisesThought: { type: "integer", description: "Which thought is being reconsidered", minimum: 1 }, branchFromThought: { type: "integer", description: "Branching point thought number", minimum: 1 }, branchId: { type: "string", description: "Branch identifier" }, needsMoreThoughts: { type: "boolean", description: "If more thoughts are needed" } }, required: ["thought", "nextThoughtNeeded", "thoughtNumber", "totalThoughts"] } };
- src/index.ts:1302-1315 (registration)Registration of the advanced_reasoning tool in the list of available tools returned by the ListToolsRequestSchema handler.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ ADVANCED_REASONING_TOOL, QUERY_MEMORY_TOOL, CREATE_LIBRARY_TOOL, LIST_LIBRARIES_TOOL, SWITCH_LIBRARY_TOOL, GET_LIBRARY_INFO_TOOL, CREATE_SYSTEM_JSON_TOOL, GET_SYSTEM_JSON_TOOL, SEARCH_SYSTEM_JSON_TOOL, LIST_SYSTEM_JSON_TOOL ], }));
- src/index.ts:1321-1323 (registration)Tool dispatch registration in the CallToolRequestSchema switch statement, routing calls to the handler method.case "advanced_reasoning": return reasoningServer.processAdvancedThought(args);
- src/index.ts:570-616 (helper)Helper function for input validation and normalization used by the handler.private validateThoughtData(input: unknown): AdvancedThoughtData { const data = input as Record<string, unknown>; // Validate core fields if (!data.thought || typeof data.thought !== 'string') { throw new Error('Invalid thought: must be a string'); } if (!data.thoughtNumber || typeof data.thoughtNumber !== 'number') { throw new Error('Invalid thoughtNumber: must be a number'); } if (!data.totalThoughts || typeof data.totalThoughts !== 'number') { throw new Error('Invalid totalThoughts: must be a number'); } if (typeof data.nextThoughtNeeded !== 'boolean') { throw new Error('Invalid nextThoughtNeeded: must be a boolean'); } // Validate advanced fields with defaults const confidence = typeof data.confidence === 'number' ? data.confidence : 0.5; const reasoning_quality = ['low', 'medium', 'high'].includes(data.reasoning_quality as string) ? data.reasoning_quality as 'low' | 'medium' | 'high' : 'medium'; return { thought: data.thought, thoughtNumber: data.thoughtNumber, totalThoughts: data.totalThoughts, nextThoughtNeeded: data.nextThoughtNeeded, confidence, reasoning_quality, meta_thought: data.meta_thought as string || '', goal: data.goal as string, progress: data.progress as number, hypothesis: data.hypothesis as string, test_plan: data.test_plan as string, test_result: data.test_result as string, evidence: data.evidence as string[], session_id: data.session_id as string, builds_on: data.builds_on as string[], challenges: data.challenges as string[], isRevision: data.isRevision as boolean, revisesThought: data.revisesThought as number, branchFromThought: data.branchFromThought as number, branchId: data.branchId as string, needsMoreThoughts: data.needsMoreThoughts as boolean, }; }