Specialized AI tool for systematic reasoning and analysis.
  • TypeScript 84.4%
  • JavaScript 15.6%
Find a file
James Peret 926ec55f70
Upgrade to AI SDK V6: bump ai/ai-sdk packages to V6
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-09 17:21:21 -03:00
src Add experimental_telemetry support to reasoning tool 2025-09-18 21:51:11 -03:00
tests Initial implementation of reasoning tool for systematic AI analysis 2025-09-14 23:07:54 -03:00
.gitignore Initial implementation of reasoning tool for systematic AI analysis 2025-09-14 23:07:54 -03:00
package-lock.json Upgrade to AI SDK V6: bump ai/ai-sdk packages to V6 2026-03-09 17:21:21 -03:00
package.json Upgrade to AI SDK V6: bump ai/ai-sdk packages to V6 2026-03-09 17:21:21 -03:00
README.md Initial implementation of reasoning tool for systematic AI analysis 2025-09-14 23:07:54 -03:00
tsconfig.json Initial implementation of reasoning tool for systematic AI analysis 2025-09-14 23:07:54 -03:00

Reasoning Tool

A specialized AI tool for systematic reasoning and analysis using dedicated reasoning models like o1, o3-mini, and Claude 4. This tool follows the ReWOO (Reasoning Without Observation) pattern to provide cost-efficient, strategic reasoning capabilities for complex problems.

Overview

The reasoning tool allows AI agents to perform deep analysis and multi-step reasoning only when needed, rather than using expensive reasoning models for all operations. It's designed to improve performance on complex tasks like those in the GAIA benchmark while maintaining cost efficiency.

Key Features

  • Strategic Model Selection: Automatically selects the best reasoning model based on task type
  • Multiple Reasoning Types: Supports general, STEM, coding, and analysis reasoning
  • Confidence Scoring: Provides confidence metrics for reasoning quality
  • Structured Output: Returns step-by-step reasoning breakdown
  • Error Handling: Robust error handling with detailed feedback
  • Cost Optimization: Uses reasoning models only when complex analysis is required

Usage

Basic Usage

import { reasoningToolDefinition } from 'reasoning-tool';

// Register with agent
toolRegistry.registerTool('reasoning', reasoningToolDefinition);

Input Parameters

  • problem (required): The problem or question requiring reasoning
  • context (optional): Additional context or background information
  • reasoningType (optional): Type of reasoning - 'general', 'stem', 'coding', 'analysis'
  • modelPreference (optional): Specific reasoning model to use
  • maxSteps (optional): Maximum number of reasoning steps
  • outputFormat (optional): Desired output format - 'plan', 'analysis', 'solution'

Output Structure

{
  reasoning: string;              // The complete reasoning process
  conclusion: string;             // Final conclusion or recommendation
  confidence: number;             // Confidence score (0-1)
  reasoningSteps: string[];       // Step-by-step breakdown
  recommendedActions?: string[];  // Suggested next actions
  metadata: {
    modelUsed: string;           // Model that performed reasoning
    tokenUsage: number;          // Tokens consumed
    reasoningTime: number;       // Processing time in ms
  }
}

Model Selection Strategy

The tool automatically selects appropriate models based on reasoning type:

  • STEM Problems: o3-mini → o1 → default model
  • Coding Tasks: Claude 4 → o1 → default model
  • Analysis Tasks: Claude 3.7 Sonnet → default model
  • General Reasoning: o1 → default model

When to Use

The reasoning tool is particularly effective for:

  • Complex Multi-step Problems: Architecture design, system planning
  • Failed Initial Approaches: When standard responses aren't sufficient
  • GAIA-style Benchmark Tasks: Research and analysis problems
  • Novel Problem Solving: Creative solutions requiring systematic thinking
  • Decision Making: Weighing multiple complex options

Agent Integration

When integrated with an agent, it should be used for complex scenarios:

const agentDefinition = new AgentDefinition(
  'Agent with Reasoning',
  'AI agent with systematic reasoning capabilities',
  'When faced with complex problems, multi-step tasks, or when initial approaches fail, use the reasoning tool to think through them systematically.',
  ['reasoning', 'other-tools...'],
  'openai-gpt-4o'
);

Examples

Example 1: Architecture Design

Input: "Design a microservices architecture for an e-commerce platform handling 10M users"
Output: Systematic breakdown of scalability, data flow, service boundaries, and technology recommendations

Example 2: Problem Debugging

Input: "My React app is slow and users are complaining about performance"
Output: Step-by-step analysis of potential bottlenecks, measurement strategies, and optimization approaches

Performance Metrics

Success is measured by:

  • GAIA Benchmark Improvement: Better scores on complex reasoning tasks
  • Cost Efficiency: Reduced token usage vs. all-reasoning approaches
  • Problem-solving Accuracy: Higher success rates on multi-step problems
  • Appropriate Usage: Correct tool selection by agents

Development

Building

npm run build

Testing

node tests/test.js

Development Mode

npm run dev

Architecture

The tool consists of:

  • types.ts: TypeScript interfaces for inputs and outputs
  • reasoning-tool.ts: Core reasoning logic and model selection
  • index.ts: AI SDK tool definition and agent integration
  • tests/test.js: Basic functionality tests

Dependencies

  • ai: AI SDK for model interaction
  • zod/v3: Schema validation
  • agent-core: Core agent functionality

Notes

  • Requires model registry access through experimental_context
  • Uses zod/v3 for compatibility with AI SDK
  • Tool definition uses as any type assertion for TypeScript compatibility
  • Designed for cost-efficient reasoning in agent workflows