claude-code - 💡(How to fix) Fix Compaction loses operational knowledge, causing repeated user corrections [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#55531Fetched 2026-05-03 04:50:58
View on GitHub
Comments
2
Participants
2
Timeline
7
Reactions
0
Author
Timeline (top)
labeled ×4commented ×2closed ×1

Fix Action

Fix / Workaround

Current workaround

RAW_BUFFERClick to expand / collapse

Problem

When context compaction occurs during a session, Claude Code loses all operational knowledge gained during the conversation. This forces the user to re-teach the same information repeatedly, significantly reducing productivity.

What gets lost

Compaction preserves high-level summaries (e.g., "strategy was changed from X to Y") but drops practical operational details:

  • Server connection info: SSH host, paths, node binary locations
  • Database schemas: column names, date formats (e.g., YYYYMMDD vs YYYY-MM-DD)
  • Service management: systemd service names, restart commands, which operations require sudo
  • Deploy workflows: build → scp → commit → push → restart (as a single workflow)
  • Display preferences: how the user wants data formatted and presented
  • Environment context: whether the user is on the server or local machine

Impact

In a real session today, compaction caused:

  1. Wasted ~30 minutes re-discovering VPS connection info, DB schema, and service management
  2. Incorrectly reported "zero bets today" due to wrong date format in query
  3. Manually killed a running service instead of using systemctl restart, causing a service outage
  4. Repeatedly added unnecessary ssh/! prefixes when the user was already on the server
  5. User had to correct the same mistakes 5+ times in a single session

Current workaround

Manually saving operational knowledge to the memory system. But this is reactive — knowledge only gets saved after the user corrects a mistake, not proactively when it's first learned.

Suggestions

  1. Auto-extract operational facts before compaction: Identify connection strings, paths, schemas, commands, and user-corrected behaviors and persist them automatically
  2. Compaction should preserve corrections: When a user corrects Claude's behavior, these should be treated as high-priority retention items
  3. Proactive memory saving: When Claude learns something environment-specific, save to memory immediately rather than waiting for compaction to lose it
  4. Same problem exists across agent switches and new sessions: Operational knowledge doesn't transfer, requiring re-teaching for every new context

Environment

  • Claude Code CLI on Windows 11
  • Model: Claude Opus 4.6 (1M context)
  • Project involves SSH to VPS, systemd services, SQLite databases, Node.js deployment

extent analysis

TL;DR

Implementing auto-extraction of operational facts before compaction and preserving user corrections as high-priority retention items can help mitigate the loss of operational knowledge.

Guidance

  • Identify and prioritize key operational details: Determine which specific operational facts (e.g., server connection info, database schemas) are most critical to preserve during compaction.
  • Modify compaction logic: Update the compaction process to automatically extract and retain these high-priority operational facts, ensuring they are not lost during context compaction.
  • Implement proactive memory saving: Develop a mechanism to immediately save environment-specific knowledge to memory as it is learned, rather than waiting for compaction or user corrections.
  • Test and refine: Thoroughly test these changes across various scenarios, including agent switches and new sessions, to ensure operational knowledge is retained and transferred correctly.

Example

No specific code snippet can be provided without more context on the implementation details of Claude Code. However, the approach might involve creating a separate data structure to hold critical operational facts and ensuring this structure is updated and preserved during compaction.

Notes

The effectiveness of these suggestions assumes that the compaction process can be modified to prioritize the retention of specific operational details. The implementation may require significant changes to the underlying architecture of Claude Code, particularly in how it handles context compaction and memory management.

Recommendation

Apply the workaround by implementing auto-extraction of operational facts and preserving user corrections, as this directly addresses the issue of lost operational knowledge during compaction, offering a more proactive approach to retaining critical information.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Compaction loses operational knowledge, causing repeated user corrections [2 comments, 2 participants]