Spaces:
Configuration error
π§ Thinking Mode Setup Guide
Overview
Gemini 2.0 Flash introduces thinking mode - the model explicitly "thinks" through problems before responding. This generates higher quality responses for complex tasks like game strategy.
π Quick Start
1. Switch to Thinking Model
Option A: Edit config.yaml (Recommended)
llm:
model_name: "gemini-2.0-flash-thinking-exp"
enable_thinking: true
thinking_budget: 16000 # Max tokens for thinking (8k-32k)
Option B: Edit config.py (For default settings)
@dataclass
class LLMConfig:
model_name: str = "gemini-2.0-flash-thinking-exp"
enable_thinking: bool = True
thinking_budget: int = 16000
2. Run Your Game
python play_catan.py
The AI will now use thinking mode automatically!
π How to Monitor Thinking
In Console Logs
Look for thinking token counts:
β
Response received: 450 tokens (+1200 thinking), 3.5s
In Log Files
JSON logs (examples/ai_testing/my_games/AI_Agent_1/prompt_1.json):
{
"tokens": {
"prompt": 1523,
"completion": 450,
"thinking": 1200,
"total": 3173
}
}
TXT logs (examples/ai_testing/my_games/AI_Agent_1/prompt_1.txt):
Tokens: prompt=1523, completion=450, thinking=1200, total=3173
In Web Viewer
Visit: http://localhost:5001
The viewer will show:
- π Token breakdown including thinking tokens
- π° Cost calculation (thinking tokens = input cost)
- π Thinking usage trends
βοΈ Configuration Options
Model Selection
| Model | Thinking | Speed | Quality |
|---|---|---|---|
gemini-2.0-flash-exp |
β | β‘ Fast | Good |
gemini-2.0-flash-thinking-exp |
β | π’ Slower | Better |
Thinking Budget
Controls max tokens the model can use for thinking:
thinking_budget: 16000 # Recommended: 8000-32000
- Lower (8k): Faster, less thorough
- Medium (16k): Balanced (default)
- Higher (32k): Slower, more thorough
Enable/Disable
enable_thinking: true # Turn on thinking mode
enable_thinking: false # Turn off (faster, cheaper)
π° Cost Impact
Thinking tokens are charged as input tokens:
Example (16k thinking budget):
- Standard mode: ~450 output tokens = $0.000034
- Thinking mode: ~1200 thinking + 450 output = $0.000056
~1.6x cost increase for better decisions π―
π Viewing the Schema
The response schema is logged in TXT files for debugging:
=== Prompt #1 (Active Turn) ===
--- Response Schema ---
{
"type": "object",
"properties": {
"internal_thinking": {
"type": "string",
"description": "Your reasoning process...",
"minLength": 200
},
...
}
}
--- Prompt Content ---
{
"meta_data": { ... }
}
Location: examples/ai_testing/my_games/AI_Agent_1/prompt_N.txt
β Testing Thinking Mode
Quick Test
Edit
pycatan/ai/config.py:model_name: str = "gemini-2.0-flash-thinking-exp" enable_thinking: bool = TrueRun a game:
python play_catan.pyCheck console output for thinking tokens:
β Response received: 450 tokens (+1200 thinking), 3.5sView logs:
# Check TXT file cat examples/ai_testing/my_games/AI_Agent_1/prompt_1.txt # Or JSON cat examples/ai_testing/my_games/AI_Agent_1/prompt_1.json
Web Viewer
cd examples/ai_testing
python web_viewer.py
Visit http://localhost:5001 to see:
- Token breakdowns with thinking
- Cost calculations
- Response quality metrics
π Troubleshooting
Not Seeing Thinking Tokens?
- Check model name: Must be
gemini-2.0-flash-thinking-exp - Check enable_thinking: Must be
truein config - Check logs: Look for "enable_thinking" in debug output
Error: "thinking_config not supported"
- Your model doesn't support thinking mode
- Switch to:
gemini-2.0-flash-thinking-exp
High Costs?
- Reduce
thinking_budget(e.g., 8000) - Or disable thinking:
enable_thinking: false
π Configuration Files
Location
- Active config:
pycatan/ai/config_dev.yaml - Example:
pycatan/ai/config_example.yaml - Defaults:
pycatan/ai/config.py
Priority
- Config YAML file (if exists)
- Default values in
config.py
π― Summary
To enable thinking mode:
- Set
model_name: "gemini-2.0-flash-thinking-exp" - Set
enable_thinking: true - Set
thinking_budget: 16000(optional) - Run your game
- Check logs for thinking token counts
Benefits:
- β Better strategic decisions
- β More thorough reasoning
- β Higher quality play
Trade-offs:
- β±οΈ Slower responses (~2-5s)
- π° Higher costs (~1.5-2x)