Summary
Gortex's precompact hook correctly fires distill_session before context compaction, preserving decisions and pinned notes across sessions. However, it has no authority over what Claude Code's harness re-injects as system-reminder blocks into the new context window after compaction. When the tail of the pre-compaction session included raw Read tool results on large indexed files, those full file contents are replayed verbatim — bypassing gortex enforcement hooks and re-inflating the context with content that gortex could have served at 30–40% of the tokens.
Observed behavior
After a session compaction, the resumed context contained system-reminder blocks replaying:
CosmosCommands.cpp (~10 KB, full file) — readable via get_symbol_source + compress_bodies: true at ~3–4 KB
- Three Python helper scripts written during the session
The gortex pre-tool enforcement hooks (which deny Read on indexed source) do not fire on auto-injected system-reminder content, so there is no interception point.
Root cause
The precompact hook fires before summarization — at that point the Read results are already in context. The harness's decision about what to carry forward into the new window happens after the hook returns, outside gortex's reach.
Proposed fix
One or more of:
-
Postcompact hook — a hook that fires after the new context window is initialized, receiving a list of re-injected tool results. Gortex could replace any re-injected Read result for an indexed file with a get_symbol_source / get_file_summary compressed equivalent, emitted as a leaner system-reminder substitute.
-
Precompact content advisory — gortex emits a structured hint during precompact (e.g. a session_files_accessed note) that Claude Code's harness can use to decide not to re-inject raw file content for those paths, trusting the agent to re-fetch via graph tools.
-
resume_context MCP tool — a dedicated tool the agent calls at session start (prompted by distill_session output) that takes a list of previously-accessed paths/symbols and returns them in compressed form, allowing the agent to explicitly swap injected content for a cheaper equivalent.
Environment
- OS: Windows 11
- Gortex daemon:
vv0.41.0+29a0849
- Host: Claude Code (claude-sonnet-4-6)
Summary
Gortex's precompact hook correctly fires
distill_sessionbefore context compaction, preserving decisions and pinned notes across sessions. However, it has no authority over what Claude Code's harness re-injects assystem-reminderblocks into the new context window after compaction. When the tail of the pre-compaction session included rawReadtool results on large indexed files, those full file contents are replayed verbatim — bypassing gortex enforcement hooks and re-inflating the context with content that gortex could have served at 30–40% of the tokens.Observed behavior
After a session compaction, the resumed context contained
system-reminderblocks replaying:CosmosCommands.cpp(~10 KB, full file) — readable viaget_symbol_source+compress_bodies: trueat ~3–4 KBThe gortex pre-tool enforcement hooks (which deny
Readon indexed source) do not fire on auto-injectedsystem-remindercontent, so there is no interception point.Root cause
The precompact hook fires before summarization — at that point the Read results are already in context. The harness's decision about what to carry forward into the new window happens after the hook returns, outside gortex's reach.
Proposed fix
One or more of:
Postcompact hook — a hook that fires after the new context window is initialized, receiving a list of re-injected tool results. Gortex could replace any re-injected
Readresult for an indexed file with aget_symbol_source/get_file_summarycompressed equivalent, emitted as a leanersystem-remindersubstitute.Precompact content advisory — gortex emits a structured hint during precompact (e.g. a
session_files_accessednote) that Claude Code's harness can use to decide not to re-inject raw file content for those paths, trusting the agent to re-fetch via graph tools.resume_contextMCP tool — a dedicated tool the agent calls at session start (prompted bydistill_sessionoutput) that takes a list of previously-accessed paths/symbols and returns them in compressed form, allowing the agent to explicitly swap injected content for a cheaper equivalent.Environment
vv0.41.0+29a0849