Understanding the Problem
When you see "Context overflow: prompt too large for the model", your conversation history has exceeded the model's token limit. But there's a bigger issue: token burns.
What Causes Token Burns
The cost spike isn't because you "asked something big" — it's because big data was accidentally pulled into the main DM context, and then every normal message kept dragging that context along.
Common Culprits
Commands that returned huge outputs get stored in the session transcript:
openclaw config.schema → massive JSON schemaopenclaw status --all → full system dumpAfter that, even small questions cause the model to process gigantic cached context.
Symptoms
Immediate Fixes
1. Reset the Session
Stop carrying the giant context forward:
# In chat, simply say:
/new# Or via CLI:
openclaw session reset
2. Check Current Context Size
openclaw session infoLook at the token count - if it's near your model's limit (200k for Claude), that's your problem.
Prevention Strategies
Configure Aggressive Compaction
{
"agents": {
"defaults": {
"contextTokens": 50000,
"compaction": {
"mode": "safeguard"
}
}
}
}Safeguard mode automatically:
Avoid Big Outputs in Main Session
Never run "big output" tools in your main DM:
# BAD: Dumps huge output into main context
openclaw config.schema# GOOD: Run in isolated debug session
openclaw --session debug config.schema
Set History Limits
{
"session": {
"historyLimit": 50
}
}This keeps only the last 50 messages, preventing unbounded growth.
Understanding Memory vs Sessions
When compaction happens, the agent should write important facts to memory before context is cleared. Enable this with:
{
"agents": {
"defaults": {
"memory": {
"enabled": true,
"autoSave": true
}
}
}
}Monitoring Token Usage
Watch your token consumption:
# Real-time session monitoring
openclaw logs --follow | grep "tokens"Need Help Optimizing?
Contact us for help configuring optimal memory and context settings for your use case.