[FEATURE] Need a way to control exactly what goes into the context at a newsession, and avoid autocompact.
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
I have created my own context approach that layers information I want Claude Code to have during the start of a new session. The process is painful, however, as the autocompact has to be turned off.. and when I run out of context, I need to clear the context to start back with a new fresh context and a new session. The problems come in because once you hit your context limit, there isn't a hook firing.. so you can lose context of your last actions and the system cannot work continuously because you cannot programmatically clear the context.
Proposed Solution
What would be incredibly valuable is to leave the autocompact feature on, but be able to override what the compaction actually is. Then all of the hooks and workarounds would go away, and we can have total control over what is in the context. The default configuration can be the current compaction process. For those that want to override it, we could more easily adjust how the context works to get better control over how the changes impact claude code.
Alternative Solutions
I currently have setup a graph memory system where information is stored as the session progresses. I have start session hooks, stop hooks, tool hooks in place to capture relevant information. unfortunately, the lack of programmatic ability to clear the context after compaction means I cannot use autocompaction... and I must issue /clear every time to get a clean context. The workarounds are clunky and prone to error, so absolute and consistent results are not easy to obtain.
Priority
High - Significant impact on productivity
Feature Category
Configuration and settings
Use Case Example
I am not satisfied with the default context system that exists.
So, I created a layered approach:
L0 - Personality. Lives in a markdown file. Who is the AI, what are its values, What is its working style, what it knows about me and how I work? This is loaded every session.
L1 - System information. Injected by the start hook. Today's date, working directory, git branch. Fresh each session, no persistence needed.
L2 - Projects. Pulled from a knowledge graph on startup. What I'm working on, status, key decisions. Changes over days/weeks.
L3 - Tasks-active and pending. Also from the graph. Background work, things to check on later, callbacks. Changes over hours.
L4 - Story Arc. The session narrative. Where we started, topic transitions, what we're building toward. Restored/updated on start.
L5 - Summary. Compressed older conversation. Facts and decisions. What auto-compaction would create, but controlled.
L6 - Conversation. Raw recent exchanges. Last ~100 messages verbatim. Carries the warmth that summaries lose and allows the conversation to continue more naturally.
I can take and paste L6 and get better responses than if I just have the auto compaction. Claude needs to know what it has done and what is remaining. Plan files and other references.. todo lists.. all can be restored and progress continues.
This is significantly better than the standard context at producing results. The process of creating this structure is harder than it needs to be.
Additional Context
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗