Problem
Every message resumes the full conversation history, causing token usage to grow O(N²) with turn count. There's currently no mechanism to bound session lifetime or notify users of context usage.
Proposed solution
- Session TTL — auto-clear session after N hours of idle (env:
SESSION_TTL_HOURS, default 24, 0 = disable)
- Turn limit — auto-clear session after N turns (env:
SESSION_MAX_TURNS, default 50, 0 = disable)
/usage command — show session age, idle time, turn count, and cumulative cost
DB: two new columns (turn_count, total_cost_usd) added via migration — fully backwards compatible.
I've implemented this in my fork: https://github.com/oct26th/claudecode-discord — happy to open a PR if there's interest.
Problem
Every message resumes the full conversation history, causing token usage to grow O(N²) with turn count. There's currently no mechanism to bound session lifetime or notify users of context usage.
Proposed solution
SESSION_TTL_HOURS, default 24, 0 = disable)SESSION_MAX_TURNS, default 50, 0 = disable)/usagecommand — show session age, idle time, turn count, and cumulative costDB: two new columns (
turn_count,total_cost_usd) added via migration — fully backwards compatible.I've implemented this in my fork: https://github.com/oct26th/claudecode-discord — happy to open a PR if there's interest.