Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
Thinking Module
The thinking module provides configurable thinking budgets for LLM reasoning, allowing control over token and time budgets for extended thinking.
Installation
pip install praisonaiagents
Features
- Token budgets for extended thinking
- Time budgets for reasoning
- Adaptive budget allocation
- Budget tracking and reporting
Quick Start
from praisonaiagents import Agent
from praisonaiagents.thinking import ThinkingBudget
# Create a thinking budget
budget = ThinkingBudget(
max_tokens=16000,
max_time_seconds=60,
adaptive=True
)
# Apply to agent
agent = Agent(
name="Reasoner",
instructions="You are a reasoning assistant.",
)
# Set thinking budget via property
agent.thinking_budget = budget
Classes
ThinkingBudget
Configure thinking budgets for agents.
from praisonaiagents.thinking import ThinkingBudget
budget = ThinkingBudget(
max_tokens=16000,
max_time_seconds=60,
adaptive=True
)
Constructor
| Parameter | Type | Default | Description |
|---|
max_tokens | int | 8000 | Maximum thinking tokens |
max_time_seconds | int | 30 | Maximum thinking time |
adaptive | bool | False | Adapt budget based on task |
ThinkingConfig
Configuration for thinking behavior.
from praisonaiagents.thinking import ThinkingConfig
config = ThinkingConfig(
enabled=True,
budget=budget,
show_thinking=False
)
Attributes
| Attribute | Type | Description |
|---|
enabled | bool | Whether thinking is enabled |
budget | ThinkingBudget | Budget configuration |
show_thinking | bool | Show thinking in output |
ThinkingUsage
Track thinking usage.
from praisonaiagents.thinking import ThinkingUsage
usage = ThinkingUsage(
tokens_used=5000,
time_seconds=15.5
)
Attributes
| Attribute | Type | Description |
|---|
tokens_used | int | Tokens used for thinking |
time_seconds | float | Time spent thinking |
budget_remaining | int | Remaining token budget |
ThinkingTracker
Track thinking across multiple calls.
from praisonaiagents.thinking import ThinkingTracker
tracker = ThinkingTracker()
tracker.record(usage)
print(tracker.total_tokens)
print(tracker.total_time)
Usage Examples
Basic Thinking Budget
from praisonaiagents import Agent
from praisonaiagents.thinking import ThinkingBudget
agent = Agent(
name="Analyst",
instructions="You are an analytical assistant.",
)
agent.thinking_budget = ThinkingBudget(max_tokens=16000)
# Agent will use extended thinking for complex tasks
result = agent.chat("Analyze the implications of quantum computing on cryptography")
Adaptive Budget
from praisonaiagents.thinking import ThinkingBudget
# Budget adapts based on task complexity
budget = ThinkingBudget(
max_tokens=32000,
adaptive=True # Automatically adjusts based on task
)
agent = Agent(
name="Researcher",
instructions="You are a research assistant.",
)
agent.thinking_budget = budget
Time-Limited Thinking
from praisonaiagents.thinking import ThinkingBudget
# Limit thinking time for faster responses
budget = ThinkingBudget(
max_tokens=16000,
max_time_seconds=30 # Stop thinking after 30 seconds
)
Track Usage
from praisonaiagents.thinking import ThinkingTracker
tracker = ThinkingTracker()
# After agent runs
usage = agent.get_thinking_usage()
tracker.record(usage)
print(f"Total thinking tokens: {tracker.total_tokens}")
print(f"Total thinking time: {tracker.total_time}s")
Best Practices
- Set appropriate budgets - Balance quality vs. cost
- Use adaptive mode - Let the system optimize for task complexity
- Monitor usage - Track thinking costs over time
- Time limits - Set time limits for time-sensitive applications