Reasoning Optimization: Variable Depth Thinking¶
Overview¶
Not all problems need deep thinking. Simple questions need fast answers. Hard problems need time to think.
Optimal agents adapt their reasoning depth to problem difficulty.
The Thinking Budget¶
Allocating Thinking Resources¶
class ThinkingBudget:
"""Allocate tokens to reasoning vs computation"""
def __init__(self, total_budget=100000):
self.total_budget = total_budget
self.used = 0
def allocate_for_task(self, task):
"""How much thinking for this task?"""
# Estimate difficulty
difficulty = self.estimate_difficulty(task)
# Allocate proportionally
if difficulty < 0.2:
# Easy: minimal thinking
reasoning_budget = int(self.total_budget * 0.1)
elif difficulty < 0.5:
# Medium: moderate thinking
reasoning_budget = int(self.total_budget * 0.4)
elif difficulty < 0.8:
# Hard: deep thinking
reasoning_budget = int(self.total_budget * 0.7)
else:
# Very hard: maximum thinking
reasoning_budget = int(self.total_budget * 0.95)
return reasoning_budget
def estimate_difficulty(self, task) -> float:
"""Score 0-1 for task difficulty"""
factors = {
'length': len(task.text) / 10000,
'vocabulary': self.rare_word_density(task),
'domain_specific': self.has_specialized_terms(task),
'ambiguity': self.measure_ambiguity(task)
}
weights = {
'length': 0.2,
'vocabulary': 0.3,
'domain_specific': 0.3,
'ambiguity': 0.2
}
return sum(factors[k] * weights[k] for k in factors)
Adaptive Thinking Depth¶
Progressive Refinement¶
class AdaptiveThinking:
"""Progressively think deeper if needed"""
def solve_adaptively(self, task):
"""Start shallow, deepen if needed"""
# Stage 1: Quick attempt
fast_solution = self.quick_solve(task)
confidence = self.assess_confidence(fast_solution)
if confidence > 0.85:
return fast_solution # Good enough!
# Stage 2: Deeper analysis
deep_solution = self.deep_solve(task)
confidence = self.assess_confidence(deep_solution)
if confidence > 0.75:
return deep_solution
# Stage 3: Very deep analysis
very_deep_solution = self.very_deep_solve(task)
return very_deep_solution
def quick_solve(self, task):
"""Fast, shallow reasoning"""
prompt = f"""
{task}
Quick answer (10 seconds of thinking):
"""
return self.fast_model.call(prompt)
def deep_solve(self, task):
"""Deeper reasoning"""
prompt = f"""
{task}
Think deeply about this. What are the key considerations?
What might be wrong with a quick answer?
"""
return self.capable_model.call(prompt)
def very_deep_solve(self, task):
"""Maximum reasoning"""
prompt = f"""
{task}
This is a hard problem. Think through it very carefully.
Consider multiple perspectives.
Check your work.
"""
return self.best_model.call(prompt)
Scaling Laws for Reasoning¶
How Much Thinking Helps?¶
class ReasoningScalingLaws:
"""Empirical cost vs benefit of thinking"""
def analyze_scaling(self):
"""Show thinking benefit curves"""
# Based on empirical observation:
scaling_laws = {
'easy_task': {
'baseline_tokens': 100,
'baseline_accuracy': 0.95,
'additional_thinking': {
'2x tokens': 0.96, # +1% accuracy, 2x cost
'5x tokens': 0.965, # +1.5% accuracy, 5x cost
'10x tokens': 0.97 # +2% accuracy, 10x cost
},
'recommendation': 'No extra thinking needed'
},
'medium_task': {
'baseline_tokens': 200,
'baseline_accuracy': 0.80,
'additional_thinking': {
'2x tokens': 0.87, # +7% accuracy, 2x cost
'5x tokens': 0.92, # +12% accuracy, 5x cost
'10x tokens': 0.95 # +15% accuracy, 10x cost
},
'recommendation': '5x thinking optimal'
},
'hard_task': {
'baseline_tokens': 300,
'baseline_accuracy': 0.40,
'additional_thinking': {
'2x tokens': 0.55, # +15% accuracy
'5x tokens': 0.72, # +32% accuracy
'10x tokens': 0.85 # +45% accuracy
},
'recommendation': '10x thinking worthwhile'
}
}
return scaling_laws
def should_think_more(self, task, confidence):
"""Decision rule: think more?"""
if confidence > 0.90:
return False # Already confident
difficulty = self.estimate_difficulty(task)
if difficulty > 0.7 and confidence < 0.60:
return True # Hard problem, low confidence → think more
return False
Efficient Reasoning¶
Selective Deep Thinking¶
class SelectiveDeepThinking:
"""Only think hard about what matters"""
def solve_selectively(self, task):
"""Think hard about critical parts"""
# Part 1: Quick overall understanding
quick_understanding = self.quick_understand(task)
# Identify critical questions
critical_questions = self.identify_critical_questions(
task,
quick_understanding
)
# Part 2: Deep thinking only on critical parts
deep_analysis = {}
for question in critical_questions:
deep_analysis[question] = self.think_deeply_about(question)
# Part 3: Synthesize
final_solution = self.synthesize(
quick_understanding,
deep_analysis
)
return final_solution
def identify_critical_questions(self, task, quick_understanding):
"""What's most important?"""
prompt = f"""
Task: {task}
Quick understanding: {quick_understanding}
What are the 2-3 most critical questions to answer deeply?
"""
response = self.llm.call(prompt)
return self.parse_questions(response)
def think_deeply_about(self, question):
"""Deep thinking on specific question"""
prompt = f"""
Question: {question}
Think through this very carefully.
Consider multiple angles.
What might go wrong?
"""
return self.best_model.call(prompt)
3 Warnings ⚠️¶
Warning 1: Overthinking Easy Problems¶
# ❌ WRONG
# Allocate lots of tokens to simple question
question = "What's 2+2?"
allocation = allocate_thinking(question)
# Uses 50% of budget thinking about arithmetic
# Wastes tokens
# ✅ RIGHT
# Quick answer for easy problems
if is_easy(question):
answer = quick_answer(question)
else:
answer = deep_think(question)
Warning 2: Underthinking Hard Problems¶
# ❌ WRONG
# Cap thinking on hard problems
if iterations > 10:
stop() # Stop thinking
# Never gets to good solution
# ✅ RIGHT
# Let hard problems get more thinking
if is_hard(question):
max_iterations = 20
max_depth = 10
else:
max_iterations = 5
max_depth = 3
Warning 3: No Diminishing Returns Detection¶
# ❌ WRONG
# Keep thinking forever
while True:
think_more()
# After point X, no more improvement
# Wastes resources
# ✅ RIGHT
# Track improvement rate
for iteration in range(max_iterations):
solution = think_more()
if improvement < minimum_threshold:
break # Diminishing returns
Last Updated: August 9, 2026