logic_solve
Solve logic problems efficiently using Chain of Draft reasoning, reducing token usage while maintaining accuracy by generating minimalistic intermediate outputs.
Instructions
Solve a logic problem using Chain of Draft reasoning
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| approach | No | Force 'CoD' or 'CoT' approach | |
| max_words_per_step | No | Maximum words per reasoning step | |
| problem | Yes | The logic problem to solve |
Implementation Reference
- server.py:122-140 (handler)Handler function for the logic_solve tool. Decorated with @app.tool() for registration in FastMCP. Delegates to chain_of_draft_solve with domain='logic'.@app.tool() async def logic_solve( problem: str, approach: str = None, max_words_per_step: int = None ) -> str: """Solve a logic problem using Chain of Draft reasoning. Args: problem: The logic problem to solve approach: Force "CoD" or "CoT" approach (default: auto-select) max_words_per_step: Maximum words per step (default: adaptive) """ return await chain_of_draft_solve( problem=problem, domain="logic", approach=approach, max_words_per_step=max_words_per_step )
- index.js:661-681 (handler)Handler dispatch block for logic_solve tool call. Calls chainOfDraftClient.solveWithReasoning with domain='logic' and formats the response.// Logic solver if (name === "logic_solve") { const result = await chainOfDraftClient.solveWithReasoning({ ...args, domain: "logic" }); const formattedResponse = `Chain of ${result.approach} reasoning (${result.word_limit} word limit):\n\n` + `${result.reasoning_steps}\n\n` + `Final answer: ${result.final_answer}\n\n` + `Stats: ${result.token_count} tokens, ${result.execution_time_ms.toFixed(0)}ms, ` + `complexity score: ${result.complexity}`; return { content: [{ type: "text", text: formattedResponse }] }; }
- index.js:505-526 (schema)Explicit input schema definition for the logic_solve tool.const LOGIC_TOOL = { name: "logic_solve", description: "Solve a logic problem using Chain of Draft reasoning", inputSchema: { type: "object", properties: { problem: { type: "string", description: "The logic problem to solve" }, approach: { type: "string", description: "Force 'CoD' or 'CoT' approach" }, max_words_per_step: { type: "number", description: "Maximum words per reasoning step" } }, required: ["problem"] } };
- index.js:581-591 (registration)Registration of available tools list including logic_solve (LOGIC_TOOL) in the ListToolsRequestSchema handler.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ CHAIN_OF_DRAFT_TOOL, MATH_TOOL, CODE_TOOL, LOGIC_TOOL, PERFORMANCE_TOOL, TOKEN_TOOL, COMPLEXITY_TOOL ], }));
- server.py:36-80 (handler)Core handler logic shared by logic_solve and other domain-specific tools. Performs the actual Chain of Draft reasoning via cod_client.@app.tool() async def chain_of_draft_solve( problem: str, domain: str = "general", max_words_per_step: int = None, approach: str = None, enforce_format: bool = True, adaptive_word_limit: bool = True ) -> str: """Solve a reasoning problem using Chain of Draft approach. Args: problem: The problem to solve domain: Domain for context (math, logic, code, common-sense, etc.) max_words_per_step: Maximum words per reasoning step (default: adaptive) approach: Force "CoD" or "CoT" approach (default: auto-select) enforce_format: Whether to enforce the word limit (default: True) adaptive_word_limit: Adjust word limits based on complexity (default: True) """ # Track execution time start_time = time.time() # Process the request with the client result = await cod_client.solve_with_reasoning( problem=problem, domain=domain, max_words_per_step=max_words_per_step, approach=approach, enforce_format=enforce_format, adaptive_word_limit=adaptive_word_limit ) # Calculate execution time execution_time = (time.time() - start_time) * 1000 # ms # Format the response formatted_response = ( f"Chain of {result['approach']} reasoning ({result['word_limit']} word limit):\n\n" f"{result['reasoning_steps']}\n\n" f"Final answer: {result['final_answer']}\n\n" f"Stats: {result['token_count']} tokens, {execution_time:.0f}ms, " f"complexity score: {result['complexity']}" ) return formatted_response