nudge full-body Gortex reads toward compress_bodies (#40)#43
Merged
Conversation
Issue #40: Claude Code burns context reading whole files via Gortex's own read tools. The PreToolUse hook redirects native Read/Grep/Glob to graph tools, but its matcher (Read|Grep|Glob|Task|Bash|Edit|Write) never matched mcp__gortex__read_file — once the agent was inside a Gortex read tool, nothing guarded how it was called, and read_file defaults to compress_bodies:false. So the expensive path was the default path with no forcing function. Close the gap: - Add mcp__gortex__read_file and mcp__gortex__get_editing_context to the PreToolUse matcher; existing installs upgrade in place (the previous matcher joins the legacy set). - enrichGortexRead nudges a full-body read on a source file toward search_text (locate sites, no bodies) or compress_bodies:true (+keep). Soft additionalContext by default; hard deny behind GORTEX_HOOK_FORCE_COMPRESS, mirroring GORTEX_HOOK_BLOCK_EDIT. The decision is made purely from the tool input — no daemon round-trip — so the hook stays sub-millisecond. Already-economical calls (compressed, size-capped, non-source) pass silently. The nudge also rides along with the permissive-mode auto-approve as soft context. - Derive the marketplace plugin's hooks.json matcher from the constant so it can't drift from gortex init. Adds bench/issue40_context_repro.py, which drives the live daemon to measure the full-vs-compressed read gap (~2x) that motivates the fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #40: Claude Code burns context reading whole files via Gortex's own read tools.
The
PreToolUsehook redirects nativeRead/Grep/Globto graph tools, but its matcher (Read|Grep|Glob|Task|Bash|Edit|Write) never matchedmcp__gortex__read_file— once the agent was inside a Gortex read tool, nothing guarded how it was called, andread_filedefaults tocompress_bodies:false. So the expensive path was the default path with no forcing function.Close the gap:
mcp__gortex__read_fileandmcp__gortex__get_editing_contextto thePreToolUsematcher; existing installs upgrade in place (the previous matcher joins the legacy set).enrichGortexReadnudges a full-body read on a source file towardsearch_text(locate sites, no bodies) orcompress_bodies:true(+keep). SoftadditionalContextby default; hard deny behindGORTEX_HOOK_FORCE_COMPRESS, mirroringGORTEX_HOOK_BLOCK_EDIT. The decision is made purely from the tool input — no daemon round-trip — so the hook stays sub-millisecond. Already-economical calls (compressed, size-capped, non-source) pass silently. The nudge also rides along with the permissive-mode auto-approve as soft context.Adds
bench/issue40_context_repro.py, which drives the live daemon to measure the full-vs-compressed read gap (~2x)bench/issue40_context_repro.py— drives the real tools through the running daemon (gortex mcp --proxy) and measures actual wire bytes for the three access patterns.What it shows (4 mid-size Go files ≈ reporter's 16–20KB C++ files)