Skip to content

[aw][code health] pricing.py is dead code — not integrated into cost display #181

@microsasa

Description

@microsasa

Root Cause

pricing.py exports lookup_model_pricing, categorize_model, KNOWN_PRICING, ModelPricing, and PricingTier. These are fully tested via test_pricing.py, but zero production modules import them:

$ grep -r "from copilot_usage.pricing" src/
# (no output)

The module was built to support cost estimation (tier classification, partial model-name matching, multiplier lookup) but was never wired into the CLI.

Impact

render_cost_view in report.py shows mm.requests.cost (raw data from session.shutdown) for completed sessions — but for active sessions (no shutdown event yet), the Premium Cost column shows "—":

# report.py — active session row
table.add_row(
    "  ↳ Since last shutdown",
    s.model or "—",
    "N/A",       # Requests — no shutdown data
    "N/A",       # Premium Cost — ← this could be estimated
    str(s.active_model_calls),
    format_tokens(s.active_output_tokens),
)

Using lookup_model_pricing(model_name).multiplier * active_model_calls would give a useful estimate. The same gap exists in the live command, which shows no cost information at all.

Proposed Fix

  1. In render_cost_view (report.py): for the ↳ Since last shutdown row, replace "N/A" for Premium Cost with f"~{estimated_cost:.0f}" computed as round(active_model_calls * lookup_model_pricing(model_name).multiplier).
  2. In render_live_sessions (report.py): add an "Est. Cost" column using the same estimation.
  3. Document the estimated nature with a ~ prefix or a table footnote so users know it's an approximation, not shutdown-data truth.

If integration is out of scope for now, the module should at minimum gain a docstring note explaining it is a standalone utility API and not called by the CLI at runtime — removing the false impression that it is actively used.

Testing Requirement

  • Unit test: render_cost_view for an active session shows a numeric estimated cost (not "N/A") when a known model is set.
  • Unit test: estimated cost is 0 for gpt-5-mini (0× multiplier) and 3 * multiplier for 3 calls of a premium model.
  • Existing test_pricing.py tests must continue to pass unchanged.

Generated by Code Health Analysis ·

Metadata

Metadata

Assignees

No one assigned

    Labels

    awCreated by agentic workflowaw-dispatchedIssue has been dispatched to implementercode-healthCode cleanup and maintenance

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions