fix: populate model in _last_usage so usage-by-model records correctly (#273)

* fix: populate model in _last_usage so usage-by-model records correctly

_last_usage was built purely from UsageInfo token counts, never
including a "model" key.  server.py's on_status() fell back to
model="" for every record_usage_event call, so GROUP BY model
collapsed all rows into a single empty-key bucket.

* fix: inject model at emission time, preserve dict[str, int] typing

Address Copilot review: keep _last_usage as dict[str, int] for type
safety, inject "model" from self.model when passing to on_status().
This also fixes stale model after /model switch since the value is
read fresh each time.
This commit is contained in:
Patrick Buckley
2026-04-01 13:21:48 -07:00
committed by GitHub
parent 651c4d98cd
commit 5df37f83a7
+2 -1
View File
@@ -2335,7 +2335,8 @@ class ChatSession:
"""Emit status info via the UI."""
if not self._last_usage:
return
self.ui.on_status(self._last_usage, self.context_window, self.reasoning_effort)
usage: dict[str, Any] = {**self._last_usage, "model": self.model}
self.ui.on_status(usage, self.context_window, self.reasoning_effort)
# -- Conversation compaction ------------------------------------------------