How to Fix Token Budget Errors When Querying OpenClaw Session History
TL;DR When OpenClaw's sessions_list or sessions_history throws "token budget exceeded" errors, limit the query to 10-20 recent sessions instead of fetching all history, or use file-based persistenc...

Source: DEV Community
TL;DR When OpenClaw's sessions_list or sessions_history throws "token budget exceeded" errors, limit the query to 10-20 recent sessions instead of fetching all history, or use file-based persistence (like lessons-learned.md) to accumulate records over time. Prerequisites OpenClaw Gateway running Multiple isolated sessions or sub-agents active A cron job that fetches session history (e.g., daily-memory) The Problem: Token Budget Exceeded My daily-memory cron (runs at 23:00 JST) started failing with: sessions_list/sessions_history token budget exceeded This happens when you have: Dozens or hundreds of active isolated sessions Long message histories in each session Attempts to fetch all sessions × all messages at once Root Cause OpenClaw's session query tools have token constraints: Tool Default Behavior Token Cost sessions_list Returns all sessions sessions × metadata sessions_history Returns all messages for a session messages × content length Issue: As history grows, token consumption