fix(proxy): drop the cost-tracker totals() switch, which belongs to #2852

This branch called `self.cost_tracker.totals()`, but that method does not exist
on main -- #2852 adds it. Merging this first would have sent every call into the
bare `except Exception` below and silently returned the fallback, so the
savings-history offset would stop being applied with nothing above debug to say
so.

#2852 already makes this exact change at this exact call site, so the hunk was
never this branch's to carry. Reverted to main's `stats()`; #2852 still delivers
the optimisation, and lands cleanly on top because these lines are now untouched
here. The file is back to being pure addition -- the beacon fan-out only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tejas Chopra 2026-08-09 10:11:11 -07:00
parent 32e83bd689
commit 23ef787d77

View file

@ -417,14 +417,14 @@ class PrometheusMetrics:
return total_input_tokens, total_input_cost_usd
try:
# totals() rather than stats(): identical numbers, without the
# 31-day cost-record walk that stats()["budget_basis"] performs and
# this caller throws away. See CostTracker.totals.
tracked_input_tokens, tracked_input_cost_usd = self.cost_tracker.totals()
cost_stats = self.cost_tracker.stats()
except Exception:
logger.debug("Failed to read cost tracker totals for savings history", exc_info=True)
return total_input_tokens, total_input_cost_usd
tracked_input_tokens = cost_stats.get("total_input_tokens")
tracked_input_cost_usd = cost_stats.get("total_input_cost_usd")
if tracked_input_tokens is not None:
try:
total_input_tokens = self._savings_tracker_input_tokens_offset + max(