You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Context-guru: Remove the old savings calculations after the accountant integration #2001
After #1956 (accountant integration) merges, remove the old savings calculations. The accountant library (github.com/rossoctl/accountant) must be the only source of savings figures. Two code paths that compute a saving can give different answers.
Background
Before #1956, Cortex priced the tool-prune saving itself. It converted the removed bytes to tokens with a byte-to-token ratio, then priced those tokens at the prompt tier. #1956 replaces this with core/accounting, which uses the accountant library.
Scope
Remove the pre-accountant code, and the fields and branches that exist only for it. Check these places:
core/cost/settle/avoided.go: Avoided, pruneFacts, factsFrom, and the settle/decode.go helpers if nothing else uses them.
core/cost/pricing/estimate.go: EstimateTokensFromBytes and AvoidedUsage.
core/cost/event/event.go: fields of Saving that only the byte-ratio path sets (for example Estimated), and their comments.
core/cost/ledger and core/cost/usage: columns and queries that only read the old figure.
cmd/agentop/tui/prune_saving.go and cmd/agentop/money: code that reads or formats the old figure.
tool-prune: fields it publishes only for settle.Avoided (bytesRemoved, bodyBytesAfter), if no other consumer reads them.
Docs: docs/tool-prune-plugin.md and any other doc that describes the byte-ratio pricing.
Tests that cover only the removed code.
Some of this may already be gone in #1956. If so, close the item with a reference to the commit.
Decide
Do we still need to read ledger records that the old path wrote? If yes, keep a read-only path for them and say so where the code is.
Done when
git grep finds no byte-ratio savings code outside history.
All savings figures in the ledger, /v1/usage, the sessions list and agentop come from core/accounting.
All packages pass, with and without the workspace.
changed the title [-]Remove the old savings calculations after the accountant integration[/-][+]Context-guru: Remove the old savings calculations after the accountant integration[/+]on Nov 19, 2026
Resolved. No byte-ratio savings code remains: settle.Avoided, pruneFacts, EstimateTokensFromBytes and AvoidedUsage are all gone. cmd/agentop/tui/prune_saving.go now carries this comment:
This file used to turn tool-prune's byte saving into tokens and dollars. It no longer does any of that arithmetic. The proxy prices the saving where both halves are in hand ... Doing it here meant agentop held a rate table's worth of assumptions ...
All savings figures now come from core/accounting (the accountant library). tool-prune's bytesRemoved/bodyBytesAfter fields remain only as informational metrics, not as pricing input.
Activity
[-]Remove the old savings calculations after the accountant integration[/-][+]Context-guru: Remove the old savings calculations after the accountant integration[/+]boazdavid commentedon Nov 26, 2026
Resolved. No byte-ratio savings code remains: settle.Avoided, pruneFacts, EstimateTokensFromBytes and AvoidedUsage are all gone. cmd/agentop/tui/prune_saving.go now carries this comment:
All savings figures now come from core/accounting (the accountant library). tool-prune's bytesRemoved/bodyBytesAfter fields remain only as informational metrics, not as pricing input.