Skip to content

feat: query-aware, lossless trimming (get_full_context intent + capture relevant:) - #110

Merged
Mibayy merged 2 commits into
mainfrom
feat/intent-aware-trim
Jul 28, 2026
Merged

feat: query-aware, lossless trimming (get_full_context intent + capture relevant:)#110
Mibayy merged 2 commits into
mainfrom
feat/intent-aware-trim

Conversation

@Mibayy

@Mibayy Mibayy commented Jul 28, 2026

Copy link
Copy Markdown
Owner

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. Without intent, 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 via range='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.

Mibayy and others added 2 commits July 28, 2026 18:45
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>
@Mibayy
Mibayy merged commit 0358751 into main Jul 28, 2026
4 checks passed
@Mibayy
Mibayy deleted the feat/intent-aware-trim branch July 28, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant