fix(runtime): keep unpriced turns distinguishable from free ones after reload

Đang mở
#4,683 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@dgageot đang làm issue này rồi.

Từ ngày 21/10/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

area/api area/runtime area/sessions

Problem

When a model has no known price (not in the models.dev catalogue and no cost: override), the runtime records the turn's cost as $0, with a warning (loop.go). chat.Message.Cost and the compaction item's Cost are plain float64, so the distinction is lost on save.

In memory, hooks, telemetry and the budget tracker already tell the two apart: nil means unpriced, 0 means free (BudgetUsageEvent.Unpriced). After a session is saved and reloaded, every unpriced turn reads as free, and session totals understate the real cost without saying so.

Proposal

  • Persist whether a message's (and a compaction item's) cost is known, additively, e.g. an unpriced flag next to cost in the stored JSON.
  • Surface it in session totals and the API: "$1.23 + unpriced turns" rather than "$1.23".
  • Keep old sessions readable; their missing flag means "priced".

Acceptance criteria

  • An unpriced turn stays unpriced after a SQLite save and reload, and a free one (cost: {}) stays free.
  • Session totals and the API distinguish them.
  • Old sessions load unchanged.

Found while planning #4654.

Ngôn ngữ chính
Go
Star
4.7k
Fork
565
Merge trung bình
18 giờ 52 phút
Pull request đã merge (30 ngày)
221

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

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 docker/docker-agent

Tất cả issue của docker/docker-agent

Issue tương tự

Thêm issue về Go

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.