feat: add rule-based tool-output compressor for extraction pipeline#308
Merged
win4r merged 1 commit intoCortexReach:masterfrom Mar 23, 2026
Merged
Conversation
Add tool-output-compressor.ts that pre-processes conversation text before LLM extraction to reduce token costs and improve quality. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
src/tool-output-compressor.ts: rule-based pre-processor that compresses tool output noise in conversation text before it reaches the extraction LLMsmart-extractor.tsalongsidestripEnvelopeMetadata()— same pattern, minimal change (3 lines)test/tool-output-compressor.test.mjs, all passingMotivation
AI coding agents (Claude Code, Codex, Gemini CLI) produce conversations full of tool output noise — git push boilerplate, passing test logs, base64 screenshots, large file dumps. When this text flows into
extractAndPersist(), it:Design
Inspired by RTK (Rust Token Killer), which uses 50+ hardcoded rules to compress CLI outputs. We adapted the concept for the extraction pipeline:
$,❯,>)stripEnvelopeMetadata(): same integration patternCompression strategies
[image: ~NKB base64]placeholder[git: ok main][test: 15 passed][...N chars truncated...]Benchmark (from downstream testing on 3,584 transcripts)
Test plan
strip-envelope-metadatatests still pass (12/12)🤖 Generated with Claude Code