Home
Back to Overview

Reasoning & Problem-Solving Agents

Teaching AI to think logically and solve complex problems

Configure LLMs for logical reasoning and multi-step problem-solving

What is a Reasoning Agent?

A reasoning agent is an LLM configured to perform logical analysis, mathematical computation, and multi-step problem-solving through careful system prompt design.

Regular Chat

"Can you help me?"
"Sure! What do you need?"

Reasoning Agent

"I am a mathematician.
I analyze problems methodically
and compute exact answers."

Why Reasoning is Hard for LLMs

LLMs are trained on text prediction, not explicit reasoning:

LLM Training:
"Predict next word in text"
NOT explicitly trained for:
  • • Step-by-step logic
  • • Arithmetic computation
  • • Tracking multiple variables
  • • Systematic problem decomposition

However, they can learn reasoning patterns from training data and be guided by system prompts.

The Reasoning Process

Input: Complex Word Problem

"A family has 3 children. Each child has 2 pets. Each pet eats 1.5 meals per day. How many meals total?"
↓

1. Parse

Understanding

Identify entities, relationships, and key information from the problem statement.

Extracted:
• 3 children
• 2 pets per child
• 1.5 meals per pet per day
↓

2. Decompose

Breakdown

Break the complex problem into smaller, manageable sub-problems.

Sub-problems:
• Step 1: Calculate total pets (3 × 2)
• Step 2: Calculate total meals (pets × 1.5)
↓

3. Calculate

Computation

Apply arithmetic operations to solve each sub-problem systematically.

Step 1: 3 × 2 = 6 pets
Step 2: 6 × 1.5 = 9 meals
↓

4. Synthesize

Integration

Combine the results from all sub-problems into a coherent final answer.

Combined result:
All calculations complete → Ready for final answer
↓

5. Final Answer

Result

Present the complete solution with verification and explanation.

Answer: 9 meals per day
Verification: 3 children × 2 pets × 1.5 meals = 9 ✓

Key Insight

Each step builds on the previous one. The system prompt guides the LLM through this structured reasoning process, ensuring logical progression from problem understanding to final solution.

Problem Complexity Hierarchy

Easy Hard
Simple Arithmetic Multi-step Logic Nested Conditions Implicit Reasoning

Easy

"What is 5 + 3?"

Medium

"If 3 apples cost $2 each, what's the total?"

Hard

"Count family members with complex relationships"

✅ When to Use Reasoning Agents

Good Use Cases

  • ✓ Word problems with clear steps
  • ✓ Logical puzzles
  • ✓ Multi-step calculations
  • ✓ Analysis tasks
  • ✓ Planning problems

Not Ideal For

  • ✗ Real-time calculations (use tools!)
  • ✗ Complex arithmetic (prone to errors)
  • ✗ Tasks requiring external data
  • ✗ Creative writing
  • ✗ Open-ended exploration

💡 Tip: For production systems, combine reasoning prompts with tools for accuracy!

Limitations of Pure LLM Reasoning

Problem: No External Tools

LLM must hold everything in "mental" context:

  • • All entity counts
  • • Intermediate calculations
  • • Conversion factors
  • • Final arithmetic

Result: Prone to errors

Counting Errors

"Count 15 people" → LLM: "14" or "16" (off by one)

Arithmetic Mistakes

"13 × 1.5 + 3 × 0.5" → May get intermediate steps wrong

Lost Context

Multi-step with many facts → Forgets earlier information

Improving Reasoning: Evolution Path

Level 1: Pure Prompting (This Example)

User → LLM → Answer

All reasoning internal to LLM, no verification, no tools

Level 2: Chain-of-Thought

User → LLM → Show Work → Answer

Visible reasoning steps, can catch some errors, still no tools

Level 3: Tool-Augmented (simple-agent)

User → LLM ⟷ Tools → Answer

External computation, reduced errors, verifiable steps

Level 4: ReAct Pattern (react-agent)

User → LLM → Think → Act → Observe → Iterate

Explicit reasoning loop, tool use at each step, self-correction possible

Comparison: Different Agent Types

Example Reasoning Tools Memory Multi-turn
intro.js ✗ ✗ ✗ ✗
think.js (here) ✓ ✗ ✗ ~
simple-agent.js ✓ ✓ ✗ ~
react-agent.js ✓✓ ✓ ~ ✓

Legend: ✗ = Not present, ~ = Limited/implicit, ✓ = Present, ✓✓ = Advanced/explicit

Key Takeaways

🧠

System prompts enable reasoning: Proper configuration transforms an LLM into a reasoning agent

⚠️

Limitations exist: Pure LLM reasoning is prone to errors on complex problems

🔧

Tools help: External computation (calculators, etc.) improves accuracy

🔄

Iteration matters: Multi-step reasoning patterns (like ReAct) work better

Next: Parallel Processing