Skip to content

feat: token savings tracking and metrics #434

@bug-ops

Description

@bug-ops

Parent

Epic: #426

Summary

Track token savings from output filtering and expose via metrics for monitoring and tuning.

Design

  • Extend FilterResult with raw_chars and filtered_chars
  • Token estimation: chars / 4 (standard heuristic)
  • Record per-filter stats in MetricsCollector:
    • tool_output_raw_tokens (counter)
    • tool_output_filtered_tokens (counter)
    • tool_output_savings_pct (gauge, rolling average)
    • tool_output_filter_hits (counter per filter name)
  • Surface in TUI dashboard (tools panel)
  • Log summary at session end: "Tool output filtering saved ~X tokens (Y%)"

Acceptance Criteria

  • FilterResult carries raw/filtered sizes
  • MetricsCollector updated per tool execution
  • Session-end summary logged
  • TUI display (optional, if TUI feature enabled)
  • Unit tests for metric recording

Metadata

Metadata

Assignees

No one assigned

    Labels

    M26Milestone 26: Smart tool output filteringP2Nice-to-have prioritysize/Stoken-savingsToken economy improvementstoolsTool execution and MCP integration

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions