Skip to content

feat: smart tool output filtering for token savings (M26)#437

Merged
bug-ops merged 2 commits intomainfrom
feat/m26/smart-output-filtering
Feb 17, 2026
Merged

feat: smart tool output filtering for token savings (M26)#437
bug-ops merged 2 commits intomainfrom
feat/m26/smart-output-filtering

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Feb 17, 2026

Summary

  • Add command-aware output filter pipeline in ShellExecutor that compresses tool output before context insertion
  • OutputFilter trait with OutputFilterRegistry (first-match-wins dispatch)
  • sanitize_output() strips ANSI escapes and progress bars on all output
  • 5 built-in filters: test (failures-only), git (compact stats), clippy (group by rule), dir listing (noise removal), log dedup (normalize+count)
  • Configurable via [tools.filters] in config

Token Savings Estimates

Filter Scenario Savings
Test Green suite (200 tests) 94-99%
Git diff Large diff 80-99%
Clippy 20+ warnings 70-90%
Log dedup Repetitive logs 70-85%
Dir listing With target/node_modules 50-70%
ANSI strip All output 5-15% baseline

Test plan

  • 1418 unit tests pass (20 new filter tests)
  • Clippy zero warnings
  • Security audit: no ReDoS, bounded HashMap (10K cap), zero info loss on errors
  • Performance audit: all O(n), LazyLock regexes, no hot-path compilation
  • Code review: all 4 issues fixed (dead metrics removed, HashMap cap, test gaps filled, match tightened)

Closes #426, closes #427, closes #428, closes #429, closes #430, closes #431, closes #432, closes #433

@github-actions github-actions Bot added enhancement New feature or request size/XL Extra large PR (500+ lines) documentation Improvements or additions to documentation rust Rust code changes config Configuration file changes and removed size/XL Extra large PR (500+ lines) labels Feb 17, 2026
Add command-aware output filter pipeline in ShellExecutor that compresses
tool output before context insertion. Filters: test (failures-only),
git (compact stats), clippy (group by rule), dir listing (noise removal),
log dedup (normalize+count). ANSI stripping runs unconditionally.

Closes #427, closes #428, closes #429, closes #430, closes #431,
closes #432, closes #433
@bug-ops bug-ops force-pushed the feat/m26/smart-output-filtering branch from 5b6c51c to 3fb8be9 Compare February 17, 2026 13:08
@github-actions github-actions Bot added the size/XL Extra large PR (500+ lines) label Feb 17, 2026
@bug-ops bug-ops enabled auto-merge (squash) February 17, 2026 13:21
@bug-ops bug-ops disabled auto-merge February 17, 2026 13:23
@bug-ops bug-ops merged commit 2f36a45 into main Feb 17, 2026
18 checks passed
@bug-ops bug-ops deleted the feat/m26/smart-output-filtering branch February 17, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration file changes documentation Improvements or additions to documentation enhancement New feature or request rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

1 participant