advanced_reasoning
Solve complex mathematical, algorithmic, and scientific problems with rigorous methodology and optimal solutions for computational challenges.
Instructions
Consult GLM-4.6 for advanced mathematical, algorithmic, and scientific reasoning tasks. Delivers world-class innovative solutions with rigorous methodology, optimal algorithms, and enterprise-grade quality. Use for: complex algorithms, mathematical proofs, performance optimization, advanced data structures, computational problems, scientific analysis. Response optimized for Claude 4.5 Sonnet with XML structure.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task | Yes | The specific mathematical, algorithmic, or scientific task requiring advanced reasoning | |
| context | Yes | Comprehensive context including: problem domain, constraints, requirements, current approach (if any), performance requirements, business logic | |
| expected_outcome | Yes | Detailed description of expected outcome: solution characteristics, performance targets, quality metrics, innovation requirements |
Implementation Reference
- src/glm-client.ts:180-284 (handler)Core implementation of the advanced_reasoning tool. Constructs a highly structured prompt for GLM-4.6 API tailored for advanced mathematical, algorithmic, and scientific reasoning, handles the API call, and formats the response using XML for Claude compatibility.async advancedReasoning(task: string, context: string, expectedOutcome: string): Promise<string> { const enhancedPrompt = `<task_specification> You are an elite computational mathematician and algorithm architect. Your mission is to deliver world-class innovative solutions using rigorous scientific methodology. </task_specification> <problem_context> ${context} </problem_context> <primary_task> ${task} </primary_task> <expected_outcome> ${expectedOutcome} </expected_outcome> <execution_requirements> 1. MATHEMATICAL RIGOR: Apply formal mathematical proofs, complexity analysis, and theoretical foundations 2. ALGORITHMIC EXCELLENCE: Design optimal algorithms with detailed time/space complexity analysis 3. INNOVATION: Present breakthrough approaches beyond conventional solutions 4. ENTERPRISE QUALITY: Ensure production-grade implementation readiness 5. PERFORMANCE OPTIMIZATION: Focus on maximum efficiency and scalability 6. SCIENTIFIC METHOD: Use data-driven analysis with quantitative reasoning </execution_requirements> <response_structure> Structure your response using XML tags for Claude 4.5 Sonnet: <analysis> - Problem decomposition - Mathematical formulation - Complexity analysis - Constraint identification </analysis> <solution_design> - Core algorithm/approach - Innovation highlights - Optimization strategies - Scalability considerations </solution_design> <implementation_blueprint> - Pseudocode with annotations - Key implementation patterns - Performance characteristics - Edge case handling </implementation_blueprint> <validation_strategy> - Correctness proofs - Test scenarios - Benchmark expectations - Quality metrics </validation_strategy> <production_guidance> - Integration recommendations - Monitoring strategies - Maintenance considerations - Documentation requirements </production_guidance> </response_structure> <quality_standards> - Target: Top 1% industry solutions - Approach: Research-grade rigor - Output: Enterprise production-ready - Innovation: Breakthrough-level thinking </quality_standards> Deliver a comprehensive, scientifically rigorous solution that represents the pinnacle of computational thinking and software engineering excellence.`; const messages: GLMMessage[] = [ { role: 'user', content: enhancedPrompt }, ]; const request: GLMRequest = { model: this.model, messages, temperature: 0.8, // Higher for innovation top_p: 0.95, max_tokens: 8192, // Extended for comprehensive analysis stream: false, }; try { const response = await this.client.post<GLMResponse>('/chat/completions', request); if (!response.data.choices || response.data.choices.length === 0) { throw new Error('GLM-4.6 returned empty response'); } const rawContent = response.data.choices[0].message.content; return this.formatForClaude(rawContent, 'advanced_reasoning'); } catch (error) { if (axios.isAxiosError(error)) { const status = error.response?.status; const message = error.response?.data?.error?.message || error.message; throw new Error(`GLM-4.6 API Error (${status}): ${message}`); } throw error; } }
- src/index.ts:100-117 (schema)Input schema definition for the advanced_reasoning tool, specifying parameters task, context, and expected_outcome as required strings.inputSchema: { type: 'object', properties: { task: { type: 'string', description: 'The specific mathematical, algorithmic, or scientific task requiring advanced reasoning', }, context: { type: 'string', description: 'Comprehensive context including: problem domain, constraints, requirements, current approach (if any), performance requirements, business logic', }, expected_outcome: { type: 'string', description: 'Detailed description of expected outcome: solution characteristics, performance targets, quality metrics, innovation requirements', }, }, required: ['task', 'context', 'expected_outcome'], },
- src/index.ts:97-118 (registration)Registration of the advanced_reasoning tool in the MCP tools array, including name, description, and input schema.{ name: 'advanced_reasoning', description: 'Consult GLM-4.6 for advanced mathematical, algorithmic, and scientific reasoning tasks. Delivers world-class innovative solutions with rigorous methodology, optimal algorithms, and enterprise-grade quality. Use for: complex algorithms, mathematical proofs, performance optimization, advanced data structures, computational problems, scientific analysis. Response optimized for Claude 4.5 Sonnet with XML structure.', inputSchema: { type: 'object', properties: { task: { type: 'string', description: 'The specific mathematical, algorithmic, or scientific task requiring advanced reasoning', }, context: { type: 'string', description: 'Comprehensive context including: problem domain, constraints, requirements, current approach (if any), performance requirements, business logic', }, expected_outcome: { type: 'string', description: 'Detailed description of expected outcome: solution characteristics, performance targets, quality metrics, innovation requirements', }, }, required: ['task', 'context', 'expected_outcome'], }, },
- src/index.ts:198-213 (handler)MCP server dispatch handler for advanced_reasoning tool, which extracts arguments and delegates to GLMClient.advancedReasoning.case 'advanced_reasoning': { const { task, context, expected_outcome } = args as { task: string; context: string; expected_outcome: string; }; const response = await glmClient.advancedReasoning(task, context, expected_outcome); return { content: [ { type: 'text', text: response, }, ], }; }
- src/glm-client.ts:52-66 (helper)Helper function used by advanced_reasoning (and others) to format GLM responses into XML structure optimized for Claude 4.5 Sonnet.private formatForClaude(content: string, taskType: string): string { return `<glm_response type="${taskType}"> <analysis> ${content} </analysis> <implementation_guidance> This response has been optimized for Claude 4.5 Sonnet with: - Structured XML format for easy parsing - Clear separation of concepts - Actionable implementation steps - Enterprise-grade quality standards </implementation_guidance> </glm_response>`; }