Thinking Budgets

Extended thinking token budgets for complex reasoning

Control how many tokens an agent spends on extended reasoning before producing a response.

python
from praisonaiagents import Agent
from praisonaiagents.thinking import ThinkingBudget

agent = Agent(
    name="DeepThinker",
    instructions="Solve problems step by step.",
)
agent.thinking_budget = ThinkingBudget.high()
agent.start("Solve this optimisation problem...")

The user asks a hard reasoning question; the agent spends extended thinking tokens up to the configured ThinkingBudget before answering.

Diagram

Thinking Budget Flow

๐Ÿ“‹ Complex Task

๐Ÿง  ThinkingBudget

๐Ÿค– Agent

๐Ÿ’ญ Extended Thinking

โœ… Final Answer

Quick Start

  1. Set a Budget Level

    Use predefined levels via the thinking_budget property after creating the agent.

    python
    from praisonaiagents import Agent
    from praisonaiagents.thinking import ThinkingBudget
    
    agent = Agent(name="Thinker", instructions="Reason carefully.")
    agent.thinking_budget = ThinkingBudget.medium()  # 8,000 tokens
    agent.start("Explain quantum entanglement simply.")
  2. Custom Budget

    Fine-tune token limits and adaptive scaling.

    python
    from praisonaiagents import Agent
    from praisonaiagents.thinking import ThinkingBudget
    
    budget = ThinkingBudget(
        max_tokens=12000,
        min_tokens=1000,
        adaptive=True,
        max_time_seconds=120.0,
    )
    
    agent = Agent(name="CustomThinker", instructions="Solve complex problems.")
    agent.thinking_budget = budget
    agent.start("Design a load-balancing strategy.")

How It Works

Diagram
LLMAgentUserLLMAgentUserComplex reasoning questionPrompt + thinking budget (max_tokens)Extended thinking (up to budget)Reasoned answerFinal response
PhaseWhat happens
1. SetYou assign a ThinkingBudget to the agent
2. ThinkThe model reasons up to the token limit
3. AnswerThe agent returns the reasoned response

Budget Levels

Pre-configured levels for different task complexity:

LevelTokensUse case
minimal()2,000Quick answers
low()4,000Simple reasoning
medium()8,000Default balance
high()16,000Complex analysis
maximum()32,000Deep research
python
from praisonaiagents.thinking import ThinkingBudget

budget = ThinkingBudget.high()
tokens = budget.get_tokens_for_complexity(0.9)  # scales with complexity

CLI Usage

bash
praisonai thinking status      # Show current budget
praisonai thinking set high    # Set budget level
praisonai thinking stats       # Show usage statistics

praisonai run --thinking

Pass --thinking <budget> on the praisonai run command to set an exact token budget for a one-off prompt:

bash
# Use a numeric token budget
praisonai run --thinking 4096 "Explain quantum entanglement"

# Use a named level
praisonai run --thinking high "Solve this optimisation problem: ..."

# Use in --command mode
praisonai run --command my_agent.py --thinking 8000
ValueTokensNotes
off0Disable extended thinking
minimal2,000Quick answers
low4,000Simple reasoning
medium8,000Balanced
high16,000Complex analysis
<int>ExactAny positive integer token budget

For persistent sessions, use praisonai thinking set <level> instead.


Usage Tracking

Track thinking utilisation across sessions:

python
from praisonaiagents.thinking import ThinkingBudget, ThinkingTracker

tracker = ThinkingTracker()
session = tracker.start_session(budget_tokens=8000)
tracker.end_session(session, tokens_used=5000, time_seconds=30.0)

summary = tracker.get_summary()
print(f"Average utilisation: {summary['average_utilization']:.1%}")

Best Practices

Match budget to task complexity

Use minimal() or low() for quick lookups; reserve high() or maximum() for multi-step analysis where reasoning depth matters.

Set via property, not constructor

Assign agent.thinking_budget after creating the agent โ€” budgets are applied lazily with zero overhead when unset.

Enable adaptive scaling

Set adaptive=True so token allocation scales with task complexity via get_tokens_for_complexity().

Monitor with CLI

Use praisonai thinking stats to review utilisation before increasing budgets in production.


Related