Skip to content

Chat memory: context meter, Compress button and auto-compress for long chats - #224

Merged
danielehrhardt merged 1 commit into
mainfrom
feat/chat-compress
Oct 23, 2026
Merged

danielehrhardt merged 1 commit into
mainfrom
feat/chat-compress

Conversation

@danielehrhardt

Copy link
Copy Markdown
Contributor

Long chats get slow and expensive, and today the only way out is typing /compact (only mentioned in the "too long" error). This makes chat memory visible and compressing a one-click thing.

What changes

  • Context meter in the composer toolbar (also in Easy mode): a ring that fills with the chat's Claude session. Click for a popover with tokens of the window, the share, a tick at the auto-compress point and Compress now.
  • "This chat is getting long" bar above the composer at 75% of the auto threshold (amber, red near it): Compress now, or hide until it grows another 20%.
  • /compress works as an alias of /compact (runner rewrites it, the slash menu offers it, extra text is passed on as focus).
  • Compressed divider in the thread instead of a plain notice: "Chat compressed · 422k → 9k (−98%)", or "Compressed automatically". The duplicate /compact command card is hidden.
  • Too-long turn end now has a Compress button next to New chat.
  • Auto-compress setting (Settings → AI & Claude → Limits → Compress long chats): 30–80% (default 50%), "When nearly full" (Claude Code's own threshold) or "Never by itself". Passed as CLAUDE_AUTOCOMPACT_PCT_OVERRIDE / DISABLE_AUTO_COMPACT; Claude Code uses min(window × pct, its own threshold). Open to settings_update and the phone scope.

How

  • StreamAccumulator tracks contextTokens (input + cache read/write + output of the latest top-level message, the summary size after compact_boundary, cleared on /clear) and contextWindow (from modelUsage of the main model).
  • Migration 100: conversations.context_tokens/context_window, exposed as Conversation.context, written at the end of each stretch and live during a run (at most every 30 s and +2k tokens, right away after a compaction). Runner chats carry it in runner_state.

Checks

  • pnpm -r typecheck clean.
  • New tests: accumulator context/window (subagent models ignored), and a run test: BIG_CONTEXT turn stores 421.6k/1M with the env set to 50, then /compress keep the open tasks reaches Claude Code as /compact keep the open tasks and the context drops to the summary.
  • slash-commands, mcp, mobile, runner, replica, conversations, remote-mirror, backup, settings-audit suites pass (pinned conversation shape updated with context).
  • Real Claude Code 2.1.308 in -p mode: CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=1 triggers status: compacting on the next turn.

Screenshots (sandbox core with the fake Claude)

Saved locally in ~/.godmode/agents/godmode/workspace/godmode-bot/chat-compress/: s-bar.png, s-popover.png, s-after.png, s-after-dark.png, s-settings.png.

…g chats

- Track how full a chat's Claude session is (latest top-level message usage, the main model's context window), saved per chat (migration 100), mirrored for runner chats and pushed live during a run
- Composer ring with a popover (tokens, share, auto threshold) and Compress now; a bar above the composer once the chat gets long; Compress on the too-long turn end
- /compress is an alias of /compact (also offered in the slash menu); the compaction notice renders as a divider with before/after tokens
- Settings: Compress long chats at 30-80% (default 50%), when nearly full or never, via CLAUDE_AUTOCOMPACT_PCT_OVERRIDE / DISABLE_AUTO_COMPACT; open to agents and the phone
@danielehrhardt
danielehrhardt merged commit 77e773d into main Oct 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant