cost: sidebar session cost inflated ~10⁶× for cortecs/glm-5.2 (catalog rates treated as $/token instead of $/M tokens)
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ó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/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ệ
- typescript
- Lĩnh vực
- backend
Hướng nghiên cứu
Tìm trong mã theo dõi chi phí các chỗ sử dụng catalog cost[].input và cost[].output, sau đó truy vết cách số lượng token được nhân với các mức giá đó. Kiểm tra phát biểu trong schema của catalog rằng giá được tính bằng USD cho mỗi triệu token, rồi so sánh kết quả của bộ tích lũy với ví dụ tính toán trong issue. Hoàn thành khi phép tính cho kết quả khoảng $9.14 với 8M token đầu vào và 600K token đầu ra theo các mức giá đã nêu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
The TUI sidebar cost accumulator produces an absurdly inflated session cost (~$8.3M) for a cortecs/glm-5.2 session, consistent with treating the model catalog's cost[].input / cost[].output values as USD per token instead of USD per million tokens as the schema declares. The displayed figure is off by ~10⁶ from the real cost.
Environment
- opencode version: v2.2.0
- OS: Linux 6.12.113+deb13-amd64 (linux x64)
- Terminal: TERM=xterm-256color, COLORTERM=truecolor
- Shell: /usr/bin/bash
- Install/channel: latest
- Active plugins: None found in config
- Provider/model:
cortecs/glm-5.2(variant in use: default)
Reproduction
- Configure the
cortecsprovider and usecortecs/glm-5.2as the model. - Run a heavy session — file reads, PDF conversions, long doc drafting — such that several million input tokens and a few hundred thousand output tokens accumulate (this session had ~8M input / ~600k output).
- Observe the sidebar/session cost figure: it shows $8,386,053.00.
Expected Behavior
The cost accumulator should treat catalog cost[].input and cost[].output as USD per million tokens (per the schema documentation: "Pricing in USD per million tokens"). For a session of ~8M input + ~600k output tokens at the reported rates (input=0.9, output=3.24), the correct cost is roughly $9.14, i.e. (8_000_000 × 0.9 + 600_000 × 3.24) / 1_000_000.
Actual Behavior
The accumulator appears to use the catalog values directly as USD per token, producing (8_000_000 × 0.9 + 600_000 × 3.24) = $9,144,000 — matching the order of magnitude of the displayed $8,386,053.00. The figure is off by a factor of ~1,000,000 from the real cost on a €50/month plan, where such a spend would be impossible.
Additional Context
Catalog evidence
The models tool returns the following for cortecs/glm-5.2:
{
"id": "cortecs/glm-5.2",
"name": "GLM-5.2",
"cost": [
{
"input": 0.9,
"output": 3.24,
"cache": { "read": 0.189, "write": 0 }
}
],
"status": "active"
}
The schema (per https://opencode.ai/config.json) documents cost[].input and cost[].output as "Pricing in USD per million tokens." The values themselves ($0.9/M input, $3.24/M output) are normal, plausible LLM prices — they only become absurd when interpreted as per-token.
Worked example of the off-by-10⁶ hypothesis
| Scenario | Tokens in | Tokens out | If $/M tokens (correct) | If $/token (buggy) |
|---|---|---|---|---|
| low | 2,000,000 | 200,000 | $2.45 | $2,448,000 |
| high | 8,000,000 | 600,000 | $9.14 | $9,144,000 |
The reported $8,386,053.00 sits squarely in the "high" buggy range, consistent with a long heavy session.
Why this matters
- The displayed number is OpenCode's local accumulator, not a bill from the gateway (Cortecs here). Users on capped plans (e.g. €50/month) see a meaningless eight-figure "spend" that obscures the real, useful signal of how much of their budget a session consumed.
- It is the opposite failure mode of recent issues #59634 / #59627 (cost stays at 0) and #59671 (6× undercount for Copilot tiered pricing), so it does not appear to duplicate them.
Likely fix location
Wherever the cost accumulator multiplies token counts by catalog cost[].input / cost[].output, it should divide by 1,000,000 (or the rates should be pre-converted to per-token) before multiplication. A grep for cost.input / cost.output in the cost-tracking code path should locate it quickly.
Notes
- The reported figure ($8,386,053.00) is taken from the TUI sidebar at the end of a long session; I have not captured a token-by-token log, but the order of magnitude is the diagnostic, not the exact cents.
- I have not redacted the provider name or model id as these are needed to reproduce.
- Ngôn ngữ chính
- TypeScript
- Star
- 221k
- Fork
- 29.6k
- Merge trung bình
- 7 giờ 41 phút
- Pull request đã merge (30 ngày)
- 510
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 anomalyco/opencode
-
core: OpenRouter BYOK sessions record cost = 0 since v2.2.0 (ignores cost_details.upstream_inference_cost)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởreproduced
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
anomalyco/opencode#60558 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
anomalyco/opencode#60541 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
anomalyco/opencode#60529 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
anomalyco/opencode#60469 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
TUI permission prompt for MCP tools doesn't show the call argumentsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
anomalyco/opencode#60350 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của anomalyco/opencode
Issue tương tự
-
bug triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Export the Hemi Earn Router address and the Router and Agent ABIs from `@vetro-protocol/earn`Đang mởhemi-earn
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
vetro-protocol/vetro-monorepo#1043 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
stage 2: bare names resolve against PATH differently from the shell (empty and relative entries)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
STRML/omp-classifier#206 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
atlassian-labs/mermaid-diagrams-viewer#188 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
dashboard enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Olanetsoft/agent-lookout#225 ·
Maintainer thường phản hồi trong vòng 1 ngày