claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Memory Loss After Auto-compact

Open diegonix opened this issue 6 months ago • 1 comments

Environment

  • Platform (select one):
    • [ x ] Anthropic API
    • [ ] AWS Bedrock
    • [ ] Google Vertex AI
    • [ ] Other:
  • Claude CLI version: 1.0.9 (Claude Code)
  • Operating System: Ubuntu 24.04
  • Terminal: Konsole

Overview

First, I'd like to express my appreciation for Claude Code - it's an excellent tool that has significantly improved my development workflow. The auto-compact feature is particularly valuable for maintaining long-running conversations on track.

I understand that Claude's 200K token context window has received criticism from some users who consider it insufficient. However, I believe the context size isn't the core issue - rather, it's about applying effective techniques to manage context properly. The auto-compact feature has been tremendously helpful in this regard. Having 2M tokens of context wouldn't necessarily be better if attention gets lost among so many tokens. It's more valuable to have a smaller, focused context window with a tool that maintains complete attention on the problem being discussed and solved.

Bug Description

After an auto-compact operation occurs, Claude Code appears to lose its working memory completely. While the system can read memory when explicitly prompted, it doesn't proactively apply previously established context, project settings, or environment configurations without manual intervention.

Steps to Reproduce

  1. Start a Claude Code session and establish project configuration (environment variables, project keys, etc.)
  2. Continue working until auto-compact is triggered
  3. Attempt to continue with tasks that rely on previously established context

Expected Behavior

After auto-compact, the session should:

  • Automatically restore essential memory and context
  • Maintain awareness of project settings and environment variables
  • Continue the conversation seamlessly without requiring manual context restoration
  • Preserve the established workflow and configurations

Actual Behavior

After auto-compact:

  • Claude appears to lose all working memory
  • Manual prompting is required: "Please read the memory again"
  • Even after reading memory, Claude doesn't apply the context effectively
  • Additional manual prompts needed: "Did you read the project keys and settings from environment variables?"
  • The session becomes less productive until all context is manually re-established

Impact

This significantly disrupts the development workflow, as users must repeatedly stop productive work to restore context that should persist automatically after compaction.

Suggested Resolution

Implement a post-compact memory restoration process that automatically reloads and applies essential context, ensuring continuity in long-running development sessions.

diegonix avatar Jun 03 '25 16:06 diegonix

Temporary fix:

npm i -g @anthropic-ai/[email protected]
claude config set -g autoUpdaterStatus disabled

ulshv avatar Jun 04 '25 11:06 ulshv

We've pushed out some auto-compact fixes recently and this should hopefully feel much better. Feel free to reopen if you're still issues

sid374 avatar Jun 10 '25 07:06 sid374

@sid374 What were these fixes and what should we notice that's different? Also, is there a way for us to use variables to control how the /compact executes and maintains system and project based memory (outside CLAUDE.md, Global etc.) when bridging to a new session/chat?

My biggest request is being able to control whether custom instructions are persisted per conversation turn, per session or manually.

QuicksilverSlick avatar Jun 19 '25 13:06 QuicksilverSlick

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Aug 11 '25 14:08 github-actions[bot]