feat: query-aware, lossless trimming (get_full_context intent + capture relevant:) - #110
Merged
Conversation
Optional 'intent' param: when set, long dependencies/dependents lists are ranked by deterministic lexical relevance to the intent and trimmed to the top _INTENT_KEEP (12), with a recovery pointer appended. Lossless (the rest stays reachable via mode='full') and model-free. Without 'intent', behaviour is byte-identical to before. First step of the query-aware-trim direction: same pattern generalizes to search_codebase hits and large tool outputs (the non-code 80%). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Generalizes intent-aware trimming (A) beyond code to arbitrary large tool outputs — logs, JSON, API responses, docs (the non-code 80%). capture_get gains range='relevant:<question>': keeps only the lines matching the question (deterministic lexical scoring, no model), in original order, with a '+N less-relevant lines omitted (range=all for full)' recovery pointer. Lossless — the full text stays reachable via range='all'. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jul 28, 2026
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.
Adopts the useful principle from prompt-compression tools (trim to the current query) without going lossy or model-based — the trimmed content always stays retrievable. Works across any MCP client (not tied to a harness hook).
A — get_full_context
intent. Optional param: long dependencies/dependents lists are ranked by deterministic lexical relevance to the intent and trimmed to the top 12, with a# +N ranked out by intent (mode='full' to expand)pointer. Withoutintent, byte-identical to before.Generalized — capture_get
range='relevant:<question>'. The same idea applied to arbitrary large tool outputs (logs, JSON, API responses, docs — the non-code majority): keep only the lines matching the question, in original order, with a+N less-relevant lines omitted (range='all' for full)pointer. On a 60-line log where 2 lines matter, that's ~2 lines returned vs 60. Full text stays reachable viarange='all'.Both use one shared idea: deterministic lexical relevance, no trained model, lossless recovery pointer. That keeps Token Savior's edge over lossy prompt-compression: nothing is ever permanently dropped.
Tests: get_full_context intent trim + stable ranking; capture relevant selection + 'all' still returns everything; determinism. ruff clean.