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

Aperta
#4,683 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@dgageot ci sta già lavorando.

Dal 21/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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.

Lingua principale
Go
Stelle
4.7k
Fork
565
Merge medio
18h 52m
PR unite (30g)
221

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di docker/docker-agent

Tutte le issue di docker/docker-agent

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.