Skip to content

Add per-tool-type cost breakdown (top-tools command) #7

@roeimichael

Description

@roeimichael

Problem

CAT tracks cost per individual tool call and computes baselines per tool type, but never shows an aggregated view like "Bash consumed 45% of all tokens, Read consumed 30%". Users can't identify which tool types are the most expensive overall.

What to do

  1. Add a SQL query for tool-type aggregation:
    SELECT task_type, COUNT(*) as call_count, 
           SUM(estimated_tokens) as total_tokens, 
           AVG(estimated_tokens) as avg_tokens 
    FROM tasks 
    WHERE estimated_tokens IS NOT NULL 
    GROUP BY task_type 
    ORDER BY total_tokens DESC
  2. Add an API endpoint /api/tool-summary in src/context_analyzer_tool/collector/routes.py
  3. Add a CLI command top-tools in src/context_analyzer_tool/cli.py that renders a ranked Rich table
  4. (Optional) Add a panel in the TUI dashboard

Why this is a good first issue

It's a clean vertical slice: one SQL query → one API endpoint → one CLI command. Follow the pattern of existing commands like anomalies or context-cost.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions