thinking-exhausted Hook
Metadata
name: thinking-exhausted
version: 1.0.0
category: orchestration
status: active
priority: P1
trigger: ThinkingBudget depleted
derived_from: Claude Operating Preferences v6.0
Description
Triggered when the extended thinking budget is exhausted during a task. Creates a checkpoint of current reasoning state and notifies the user.
Trigger Conditions
- Thinking token usage reaches 95% of budget
- Thinking budget fully depleted
- Interleaved thinking context about to be lost
Actions
-
Checkpoint Current State
- Save intermediate conclusions
- Preserve thinking summary
- Record current task progress
-
Notify User
- Display warning about budget exhaustion
- Show thinking utilization percentage
- Suggest continuation options
-
Recommend Next Steps
- Suggest appropriate budget for continuation
- Offer to create checkpoint file
- Provide resume instructions
Configuration
# hooks/thinking-exhausted.yaml
hook:
name: thinking-exhausted
enabled: true
triggers:
- event: thinking_budget_warning
threshold: 0.95
- event: thinking_budget_exhausted
threshold: 1.0
actions:
- type: checkpoint
include:
- thinking_summary
- current_task
- completed_steps
- decisions_made
- type: notify
message: |
Thinking budget exhausted ({utilization}% used).
Checkpoint created: {checkpoint_path}
- type: suggest
options:
- "Continue with DEEP tier (16K tokens)"
- "Continue with EXTENDED tier (32K tokens)"
- "Save and resume later"
Example Output
[HOOK: thinking-exhausted]
Thinking Budget Exhausted
-------------------------
Budget: 16,000 tokens
Used: 15,847 tokens (99.0%)
Status: EXHAUSTED
Checkpoint Created
------------------
File: checkpoints/2025-12-31T15-04-00Z-thinking-exhausted.json
Summary: "Analyzing authentication race condition. Identified 3 potential causes..."
Recommendations
---------------
1. Continue with EXTENDED tier (32K) for deeper analysis
2. Resume from checkpoint with current conclusions
3. Proceed with partial analysis
Run: /thinking-config --tier EXTENDED to continue
Integration
class ThinkingExhaustedHook:
"""Hook handler for thinking budget exhaustion"""
def __init__(self, checkpoint_dir: str = "checkpoints"):
self.checkpoint_dir = checkpoint_dir
async def on_thinking_warning(
self,
budget: int,
used: int,
thinking_summary: str
):
"""Handle 95% warning"""
utilization = used / budget
print(f"[WARN] Thinking budget at {utilization*100:.1f}%")
async def on_thinking_exhausted(
self,
budget: int,
used: int,
thinking_summary: str,
current_task: str
):
"""Handle exhaustion"""
checkpoint = self._create_checkpoint(
thinking_summary,
current_task
)
self._notify_user(checkpoint)
self._suggest_next_steps(budget)
def _create_checkpoint(self, summary: str, task: str) -> str:
"""Create checkpoint file"""
import json
from datetime import datetime
checkpoint = {
"timestamp": datetime.utcnow().isoformat() + "Z",
"thinking_summary": summary,
"current_task": task,
"status": "thinking_exhausted"
}
path = f"{self.checkpoint_dir}/thinking-exhausted-{checkpoint['timestamp']}.json"
with open(path, 'w') as f:
json.dump(checkpoint, f, indent=2)
return path
def _notify_user(self, checkpoint_path: str):
"""Notify user of exhaustion"""
print(f"\n[HOOK: thinking-exhausted]")
print(f"Checkpoint: {checkpoint_path}")
def _suggest_next_steps(self, current_budget: int):
"""Suggest continuation options"""
next_tier = "EXTENDED" if current_budget < 32000 else "MAXIMUM"
print(f"\nRecommendation: /thinking-config --tier {next_tier}")
Related Components
skills/extended-thinking-patterns/- Thinking configurationagents/thinking-budget-manager.md- Budget managementcommands/thinking-config.md- CLI configuration