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

未关闭
#4,683 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@dgageot 已经在做这个了。

开始于 2026年10月21日。

评估

这个 Issue 还没有评估数据。

描述

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.

主要语言
Go
星标
4.7k
派生
565
平均合并
18 小时 52 分钟
30 天内合并 PR
221

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

docker/docker-agent 的其他 Issue

查看 docker/docker-agent 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。