Skip to content

fix(plugin): insights shows the keep-alive saving with the wrong sign #582

Closed

Description

@amiddavid

Summary

/context-guru:insights shows the keep-alive saving with the wrong sign. When pings save more than they cost, the "Keep-alive pings" row shows a large negative number. The rows also do not add up to the "Saved" headline.

What we found

Example /api/stats waterfall for a 7-day window (rounded numbers):

Waterfall key delta_usd
compaction -80
keepalive_saved -120
keepalive_ping 60
cg_llm 6
total_saved 134
  • Insights shows "Keep-alive pings" as -120 - 60 = -$180.
  • The correct row is 120 - 60 = +$60. The flat field keepalive_net_usd agrees.
  • With the fix, the rows add up to the headline: 80 + 60 - 6 = 134. Today they do not.

Why it happens

In the waterfall, a saving is a negative delta_usd. levers() in context-guru-plugin/scripts/cg.py negates compaction, but it uses keepalive_saved as it is:

("Keep-alive pings", w.get("keepalive_saved", 0.0) - abs(w.get("keepalive_ping", 0.0))),

Proposal

  • Use abs(w.get("keepalive_saved", 0.0)), as the other rows do.
  • Make the same fix in the Codex copy, codex-marketplace/plugins/context-guru/scripts/cg.py.
  • Add a test: the lever rows must add up to total_saved.

Open questions

  • Do cachesplit_saved, decl_filter_saved and self_removed have the same sign problem? They were 0 in the window we looked at.

Blocks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions