Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
Bug Report: Agent session history grows unbounded → exponential token consumption
Submit to: Bug Reports - Cursor - Community Forum
Title
Agent session history grows unbounded in state.vscdb, causing exponential token consumption
Severity
High — financial impact (silent token burn) + degraded UX (slower responses over time)
Where does the bug appear?
Cursor IDE — Agent / Composer mode (all platforms)
Summary
The agentKv table in state.vscdb accumulates agent conversation history indefinitely with no eviction, pruning, or user-visible warning. Long-running sessions cause exponential token growth because the entire uncapped history is sent as context with each new message.
Evidence (from my machine after ~2 weeks of use)
Metric
Value
state.vscdb file size
389 MB
agentKv entries
16,273 (197.6 MB)
bubbleId entries
7,250 (114 MB)
Total KV entries
25,090
Worst single session
873 messages / 43.6 MB
2nd worst session
371 messages / 31.7 MB
SQL to reproduce:
– File: ~/Library/Application Support/Cursor/User/globalStorage/state.vscdb
SELECT
CASE
WHEN key LIKE ‘agentKv:%’ THEN ‘agentKv’
WHEN key LIKE ‘bubbleId:%’ THEN ‘bubbleId’
ELSE ‘other’
END AS category,
COUNT(*) AS count,
ROUND(SUM(LENGTH(value))/1024.0/1024.0, 2) AS total_mb
FROM cursorDiskKV
GROUP BY category
ORDER BY total_mb DESC;
Steps to reproduce
Use Agent/Composer mode for many turns in a project
Observe state.vscdb grow without bound
Run the SQL query above to see the accumulated data
Note that each new message in a long session incurs linearly growing context overhead
Root cause
No per-session message cap — sessions grow to 873+ messages
No client-side context budget enforcement — server-side limits arrive too late (tokens already consumed)
No visible indicator of session size or context usage
No automatic eviction of old/inactive agent sessions
Expected behavior
Enforce a per-session message or token budget, auto-summarize or trim beyond a threshold
Show context usage % in the composer UI (similar to the existing contextUsagePercent field already stored in the DB)
Auto-prune old/inactive agent sessions from state.vscdb (e.g., keep last N sessions, age-based TTL)
Warn the user when a session exceeds a threshold: “This conversation has 800+ messages. Start a new session to reduce token usage and improve response quality?”
Impact
Users unknowingly burn through monthly token/request quotas
Response quality degrades as context window fills with stale history
389 MB of SSD wasted on stale conversation data that is never cleaned up
No way for users to know which sessions are consuming their budget without manually querying SQLite
Environment
macOS 15.5 (arm64, M4)
Cursor version: latest (as of 2026-05-30)
Steps to Reproduce
yes
Expected Behavior
yes
Operating System
MacOS
Version Information
202605302026053020260530
For AI issues: which model did you use?
202605302026053020260530
Does this stop you from using Cursor
Sometimes - I can sometimes use Cursor