Skip to content

feat: token savings tracking and metrics (M26)#445

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

feat: token savings tracking and metrics (M26)#445
bug-ops merged 6 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 FilterStats struct to ToolOutput carrying raw/filtered char counts with savings_pct() and estimated_tokens_saved() methods
  • Extend MetricsSnapshot with filter_raw_tokens, filter_saved_tokens, filter_applications counters
  • Record filter metrics in agent on each tool execution
  • Log session-end filtering summary on agent shutdown
  • Display filter savings in TUI Resources panel when active

Test plan

  • FilterStats::savings_pct correctness
  • FilterStats::savings_pct zero-division safety
  • FilterStats::estimated_tokens_saved calculation
  • MetricsCollector filter metrics accumulation
  • All 1422 existing tests pass
  • clippy clean, fmt clean

Closes #434

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
Add FilterStats to ToolOutput for per-execution filter metrics.
Record cumulative filter_raw_tokens, filter_saved_tokens, and
filter_applications in MetricsSnapshot. Log session-end summary
on agent shutdown. Display savings in TUI Resources panel.

Closes #434
@github-actions github-actions Bot added enhancement New feature or request rust Rust code changes core zeph-core crate size/M Medium PR (51-200 lines) and removed enhancement New feature or request labels Feb 17, 2026
@github-actions github-actions Bot added the enhancement New feature or request label Feb 17, 2026
@bug-ops bug-ops enabled auto-merge (squash) February 17, 2026 14:23
Add mock feature to full feature set so integration tests compile.
Add filter_stats: None to all test ToolOutput constructors.
Gate unused OllamaProvider import behind a2a feature.
@github-actions github-actions Bot added tests Test-related changes dependencies Dependency updates labels Feb 17, 2026
@bug-ops bug-ops merged commit 147db8d into main Feb 17, 2026
18 checks passed
@bug-ops bug-ops deleted the feat/m26/smart-output-filtering branch February 17, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate dependencies Dependency updates enhancement New feature or request rust Rust code changes size/M Medium PR (51-200 lines) tests Test-related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: token savings tracking and metrics

1 participant