Context quality preservation — 4 improvements across the prompt→compact→recovery chain #20
Jianping-Xiong
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Part of an architecture improvement initiative based on Claude Code source analysis.
Related:
Four changes that work together to prevent information loss through the full context lifecycle.
1. Add reactive compact fallback
If a single tool output is huge, context can exceed the limit in one turn — before autocompact triggers. API error, session dies.
Claude Code has three layers: autocompact → blocking limit → reactive compact. The third one fires after API rejection, does emergency compression, retries. We only have the first layer.
2. Add 4 required sections to compaction summary
Our compaction already does well: code-extracted file lists, tool failures, identifier preservation, post-compaction refresh. But the summary body itself has no structure — LLM writes whatever it wants.
Suggest requiring:
3. Prompt assembly: static first, dynamic last
Prompt cache = prefix matching. First byte that differs → everything after = cache miss.
Our modular prompt is better than Claude Code's monolith for this, but only if order is right:
Need to verify current assembly order and fix if needed.
4. Add session-end as memory flush trigger
Memory flush currently only fires before compaction. Misses:
The existing session-memory hook already fires on /new and /reset. Add extraction there.
All reactions