[Bug]: local_runtime_token_usage keeps model NULL for historical rows, so downstream tooling cannot price them
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- sqlite, typescript
Hướng nghiên cứu
Start by locating the code that writes local_runtime_token_usage and the migration or initialization path for that table. Then inspect how session records provide history_relative_dir and how messages.jsonl stores message.model and turn_id. Decide how historical rows with missing session history should be handled; done means the chosen backfill or diagnostic makes missing model data observable and avoids misattributing rows.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Product or interface
Desktop app (the local-runtime usage ledger that third-party tooling reads).
Version
Desktop app 3.1.6 (build from 2026-10-23). The ledger lives in
~/.minimax/v2/sqlite/runtime-state.sqlite, table local_runtime_token_usage.
Platform
macOS (Apple Silicon).
OS version and architecture
macOS 27.0.1, arm64.
Issue area
Runtime / local-runtime — token usage ledger (local_runtime_token_usage).
Steps to reproduce
-
Use MCode on a build that predates the model being written, then upgrade to a
build that writes it (the fix is visible in the current build: rows written
after 2026-10-24 01:06 local carrymodel = 'minimax/MiniMax-M3.1-Flash'). -
Inspect the ledger:
sqlite3 ~/.minimax/v2/sqlite/runtime-state.sqlite \ "SELECT model, COUNT(*), SUM(input_tokens+output_tokens) FROM local_runtime_token_usage GROUP BY model;"On my machine:
| | 2928 | 30859470 | minimax/MiniMax-M3.1-Flash | 105 | 5845270Every row written before the fix has
model IS NULL; only rows written after
it carry a model.
Expected and actual behavior
Expected: the ledger records the model for every usage row, so downstream
tooling can attribute usage to a model.
Actual: historical rows keep model IS NULL forever. Third-party usage
trackers that read this ledger (for example vibe-usage, which reads
local_runtime_token_usage and prices each bucket by its model string) show
those rows as model unknown and therefore cost $0.00, even though the model
is unambiguous.
Why it matters
The model is recoverable from data the runtime already keeps: the per-session
history files under ~/.minimax/v2/sessions/<history_relative_dir>/messages.jsonl
carry message.model and turn_id for every assistant turn. Joining those to
the ledger rows by session_id + turn_id recovers the model for 100% of the
rows I could check (2 621 / 2 621 exact matches by turn_id, the remainder
recovered from the session's dominant model).
Proposal
- One-off backfill. A migration that fills
modelfor rows where it is
NULL, reading the model from the session history files (the runtime owns
those files, so this does not widen any privacy boundary). A reference
implementation is available — happy to open a PR if this is welcome, but I
understand the repository currently only accepts contributions from
collaborators, so an issue is the right route. - Or: surface it. When the ledger has rows with a NULL model, report the
count somewhere observable (astatus/diagnostics command or a log line),
so tooling and users can tell "no model recorded" apart from "zero usage". - Or: both.
Reference implementation
The recovery I used (Python 3, read-only on the ledger, writes only the model
column of rows where it is NULL):
# 1. (session_id, turn_id) -> model, from the session history files
for session_id, rel in sqlite3.connect(DB).execute(
"SELECT session_id, history_relative_dir FROM local_runtime_sessions "
"WHERE history_relative_dir IS NOT NULL"):
for line in open(f"~/.minimax/v2/sessions/{rel}/messages.jsonl"):
obj = json.loads(line)
msg = obj.get("message") or {}
if msg.get("model"):
turn2model[(session_id, obj.get("turn_id"))] = msg["model"]
# 2. fill the NULL rows
UPDATE local_runtime_token_usage SET model = ? WHERE id = ? # turn_id match
# (fallback: the session's dominant model, for rows whose turn is gone)
Related
- Third-party tracker side:
vibe-cafe/vibe-usage#127adds mcode session
records; the missingmodelon historical rows is the remaining reason those
rows still price at $0.00.
- Ngôn ngữ chính
- TypeScript
- Star
- 2k
- Fork
- 259
- Merge trung bình
- 14 giờ 20 phút
- Pull request đã merge (30 ngày)
- 56
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của MiniMax-AI/minimax-code
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
MiniMax-AI/minimax-code#507 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug needs-triage tui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
MiniMax-AI/minimax-code#481 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug cli documentation needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
MiniMax-AI/minimax-code#299 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
MiniMax-AI/minimax-code#539 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage question
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 25/100
MiniMax-AI/minimax-code#537 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của MiniMax-AI/minimax-code
Issue tương tự
-
freshness freshness:observed-only
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
thoroc/context-radar#282 ·
-
bug P2 rust
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area: web
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
gabe-santana/arkdraw#25 ·
-
bug require-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
expressjs/expressjs.com#2549 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug good first issue hacktoberfest
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
codercops/discord-bot#101 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày