Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

cost: sidebar session cost inflated ~10⁶× for cortecs/glm-5.2 (catalog rates treated as $/token instead of $/M tokens)

Đang mở Phù hợp với người mới
#59,677 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

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

  1. Configure the cortecs provider and use cortecs/glm-5.2 as the model.
  2. 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).
  3. 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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của anomalyco/opencode

Tất cả issue của anomalyco/opencode

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.